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

Function _escape_attrib_html

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

Source from the content-addressed store, hash-verified

121
122
123def _escape_attrib_html(text: str) -> str:
124 # escape attribute value
125 try:
126 if "&" in text:
127 # Only replace & when not part of an entity
128 text = RE_AMP.sub('&', text)
129 if "<" in text:
130 text = text.replace("<", "&lt;")
131 if ">" in text:
132 text = text.replace(">", "&gt;")
133 if "\"" in text:
134 text = text.replace("\"", "&quot;")
135 return text
136 except (TypeError, AttributeError): # pragma: no cover
137 _raise_serialization_error(text)
138
139
140def _serialize_html(write: Callable[[str], None], elem: Element, format: Literal["html", "xhtml"]) -> None:

Callers 3

_serialize_htmlFunction · 0.85
runMethod · 0.85
hiliteMethod · 0.85

Calls 1

Tested by

no test coverage detected