MCPcopy Index your code
hub / github.com/ronreiter/interactive-tutorials / _escape_cdata

Function _escape_cdata

markdown/html4.py:80–94  ·  view source on GitHub ↗
(text, encoding)

Source from the content-addressed store, hash-verified

78 _raise_serialization_error(text)
79
80def _escape_cdata(text, encoding):
81 # escape character data
82 try:
83 # it's worth avoiding do-nothing calls for strings that are
84 # shorter than 500 character, or so. assume that's, by far,
85 # the most common case in most applications.
86 if "&" in text:
87 text = text.replace("&", "&")
88 if "<" in text:
89 text = text.replace("<", "&lt;")
90 if ">" in text:
91 text = text.replace(">", "&gt;")
92 return text.encode(encoding, "xmlcharrefreplace")
93 except (TypeError, AttributeError):
94 _raise_serialization_error(text)
95
96
97def _escape_attrib(text, encoding):

Callers 1

_serialize_htmlFunction · 0.85

Calls 2

encodeMethod · 0.45

Tested by

no test coverage detected