18 from .htmlformatters
import LinkFormatter, HtmlFormatter
28 _generic_escapes = ((
'&',
'&'), (
'<',
'<'), (
'>',
'>'))
32 _attribute_escapes = _generic_escapes \
33 + ((
'"',
'"'), (
'\n',
' '), (
'\r',
' '), (
'\t',
'	'))
37 _illegal_chars_in_xml = re.compile(
u'[\x00-\x08\x0B\x0C\x0E-\x1F\uFFFE\uFFFF]')
42 if linkify
and '://' in text:
48 return _illegal_chars_in_xml.sub(
'',
_escape(text))
56 attr =
_escape(attr, _attribute_escapes)
57 return _illegal_chars_in_xml.sub(
'', attr)
60 def _escape(text, escapes=_generic_escapes):
61 for name, value
in escapes:
63 text = text.replace(name, value)
def _escape(text, escapes=_generic_escapes)
def html_escape(text, linkify=True)
def attribute_escape(attr)