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