MCPcopy Create free account
hub / github.com/Python-Markdown/markdown / _escape_attrib

Function _escape_attrib

markdown/serializers.py:82–98  ·  view source on GitHub ↗
(text: str)

Source from the content-addressed store, hash-verified

80
81
82def _escape_attrib(text: str) -> str:
83 # escape attribute value
84 try:
85 if "&" in text:
86 # Only replace & when not part of an entity
87 text = RE_AMP.sub('&', text)
88 if "<" in text:
89 text = text.replace("<", "&lt;")
90 if ">" in text:
91 text = text.replace(">", "&gt;")
92 if "\"" in text:
93 text = text.replace("\"", "&quot;")
94 if "\n" in text:
95 text = text.replace("\n", "&#10;")
96 return text
97 except (TypeError, AttributeError): # pragma: no cover
98 _raise_serialization_error(text)
99
100
101def _escape_attrib_html(text: str) -> str:

Callers 1

_serialize_htmlFunction · 0.85

Calls 1

Tested by

no test coverage detected