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

Function _escape_cdata

markdown/serializers.py:86–101  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

84
85
86def _escape_cdata(text) -> str:
87 # escape character data
88 try:
89 # it's worth avoiding do-nothing calls for strings that are
90 # shorter than 500 character, or so. assume that's, by far,
91 # the most common case in most applications.
92 if "&" in text:
93 # Only replace & when not part of an entity
94 text = RE_AMP.sub('&', text)
95 if "<" in text:
96 text = text.replace("<", "&lt;")
97 if ">" in text:
98 text = text.replace(">", "&gt;")
99 return text
100 except (TypeError, AttributeError): # pragma: no cover
101 _raise_serialization_error(text)
102
103
104def _escape_attrib(text: str) -> str:

Callers 1

_serialize_htmlFunction · 0.85

Calls 1

Tested by

no test coverage detected