Skip to content

Commit

Permalink
New function
Browse files Browse the repository at this point in the history
  • Loading branch information
kthoden committed Dec 17, 2019
1 parent ee954e8 commit 22bce0b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/utils/libeoaconvert.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,8 @@ def translate(term, publang, translation_file):
else:
return translated_term
# def translate ends here


def restore_xml_tags(text):
"""Convert XML entities back to code
Expand All @@ -463,3 +465,20 @@ def restore_xml_tags(text):
return text
# def restore_xml_tags ends here


def escape_xml(text):
"""Convert xml markup to entities"""

replacements = {
"<" : "&lt;" ,
">" : "&gt;",
"'" : "&apos;",
"&" : "&amp;"
'"' : "&quot;",
}

for item in replacements:
text = text.replace(item, replacements[item])

return text
# def escape_xml ends here

0 comments on commit 22bce0b

Please sign in to comment.