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

Function _escape_attrib

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

Source from the content-addressed store, hash-verified

102
103
104def _escape_attrib(text: str) -> str:
105 # escape attribute value
106 try:
107 if "&" in text:
108 # Only replace & when not part of an entity
109 text = RE_AMP.sub('&', text)
110 if "<" in text:
111 text = text.replace("<", "&lt;")
112 if ">" in text:
113 text = text.replace(">", "&gt;")
114 if "\"" in text:
115 text = text.replace("\"", "&quot;")
116 if "\n" in text:
117 text = text.replace("\n", "&#10;")
118 return text
119 except (TypeError, AttributeError): # pragma: no cover
120 _raise_serialization_error(text)
121
122
123def _escape_attrib_html(text: str) -> str:

Callers 1

_serialize_htmlFunction · 0.85

Calls 1

Tested by

no test coverage detected