1
0
mirror of https://github.com/gryf/ebook-converter.git synced 2026-03-24 03:13:34 +01:00

Moved prepare_string_for_xml to utils.entities.

This commit is contained in:
2021-01-03 19:47:49 +01:00
parent 8be21d878d
commit 018676c026
8 changed files with 45 additions and 49 deletions

View File

@@ -24,14 +24,3 @@ class CurrentDir(object):
except EnvironmentError:
# The previous CWD no longer exists
pass
_ent_pat = re.compile(r'&(\S+?);')
def prepare_string_for_xml(raw, attribute=False):
raw = _ent_pat.sub(entities.entity_to_unicode, raw)
raw = raw.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;')
if attribute:
raw = raw.replace('"', '&quot;').replace("'", '&apos;')
return raw