Update tokenizer and html converter

This commit is contained in:
Veronica K. B. Olsen
2019-10-25 00:07:37 +02:00
parent a67d3ed599
commit 01dde7c8a4
2 changed files with 30 additions and 22 deletions
+7 -3
View File
@@ -28,9 +28,13 @@ class ToHtml(Tokenizer):
Tokenizer.doAutoReplace(self)
repDict = {
"<" : "&lt;",
">" : "&gt;",
"&" : "&amp;",
"<" : "&lt;",
">" : "&gt;",
"&" : "&amp;",
"\u2013" : "&endash;",
"\u2014" : "$emdash;",
"\u2500" : "$emdash;",
"\u2026" : "&hellip;",
}
xRep = re.compile("|".join([re.escape(k) for k in repDict.keys()]), flags=re.DOTALL)
self.theText = xRep.sub(lambda x: repDict[x.group(0)], self.theText)