Resolve HTML render bug (#951)
* Fix bug breaking HTML rendering with angle brackets in other blocks than normal text * Restore cursor if document viewer fails to load * Improve test coverage
This commit is contained in:
committed by
GitHub
parent
59e10fbf0a
commit
9be2519406
+23
-17
@@ -154,25 +154,31 @@ class ToHtml(Tokenizer):
|
||||
parStyle = None
|
||||
tmpResult = []
|
||||
|
||||
for tType, tLine, tDirty, tFormat, tStyle in self._theTokens:
|
||||
for tType, tLine, tText, tFormat, tStyle in self._theTokens:
|
||||
|
||||
# Replace < and > and recompute formatting positions
|
||||
cText = []
|
||||
i = 0
|
||||
for c in tDirty:
|
||||
if c == "<":
|
||||
cText.append("<")
|
||||
tFormat = [[a + 3 if a > i else a, b, c] for a, b, c in tFormat]
|
||||
i += 4
|
||||
elif c == ">":
|
||||
cText.append(">")
|
||||
tFormat = [[a + 3 if a > i else a, b, c] for a, b, c in tFormat]
|
||||
i += 4
|
||||
else:
|
||||
cText.append(c)
|
||||
i += 1
|
||||
# Replace < and > with HTML entities
|
||||
if tFormat:
|
||||
# If we have formatting, we must recompute the locations
|
||||
cText = []
|
||||
i = 0
|
||||
for c in tText:
|
||||
if c == "<":
|
||||
cText.append("<")
|
||||
tFormat = [[a + 3 if a > i else a, b, c] for a, b, c in tFormat]
|
||||
i += 4
|
||||
elif c == ">":
|
||||
cText.append(">")
|
||||
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)
|
||||
tText = "".join(cText)
|
||||
|
||||
else:
|
||||
# If we don't have formatting, we can do a plain replace
|
||||
tText = tText.replace("<", "<").replace(">", ">")
|
||||
|
||||
# Styles
|
||||
aStyle = []
|
||||
|
||||
Reference in New Issue
Block a user