Fix greater/lesser symbol bug in HTML conversion (#928)

* Fix issue with greater or lesser symbol in paragraph with formatting
* Add test coverage and make another fix to special case of mixing formats
This commit is contained in:
Veronica Berglyd Olsen
2021-11-10 00:26:07 +01:00
committed by GitHub
parent 32d6583ae3
commit 67d2e266fd
2 changed files with 60 additions and 3 deletions
+18 -3
View File
@@ -146,10 +146,25 @@ class ToHtml(Tokenizer):
parStyle = None
tmpResult = []
for tType, tLine, tText, tFormat, tStyle in self.theTokens:
for tType, tLine, tDirty, tFormat, tStyle in self.theTokens:
# Replace < and > before adding html tags
tText = tText.replace("<", "&lt;").replace(">", "&gt;")
# Replace < and > and recompute formatting positions
cText = []
i = 0
for c in tDirty:
if c == "<":
cText.append("&lt;")
tFormat = [[a + 3 if a > i else a, b, c] for a, b, c in tFormat]
i += 4
elif c == ">":
cText.append("&gt;")
tFormat = [[a + 3 if a > i else a, b, c] for a, b, c in tFormat]
i += 4
else:
cText.append(c)
i += 1
tText = "".join(cText)
# Styles
aStyle = []