Move the coding of angle brackets in HTML to the innermost function in the chain (#821)
This commit is contained in:
committed by
GitHub
parent
72fd2990e7
commit
1d16cc2a03
+7
-10
@@ -74,19 +74,13 @@ class ToHtml(Tokenizer):
|
||||
return
|
||||
|
||||
def setReplaceUnicode(self, doReplace):
|
||||
"""Set the translation map to either minimal or full unicode to
|
||||
"""Set the translation map to either minimal or full unicode for
|
||||
html entities replacement.
|
||||
"""
|
||||
# Control characters must always be replaced
|
||||
# This affects alignment and indenting code, so the Tokenizer
|
||||
# must take this into account when parsing for markup using
|
||||
# angle brackets.
|
||||
self._trMap = str.maketrans({
|
||||
"<": "<",
|
||||
">": ">",
|
||||
"&": "&",
|
||||
})
|
||||
|
||||
# Angle brackets are replaced later as they are also used in
|
||||
# formatting codes
|
||||
self._trMap = str.maketrans({"&": "&"})
|
||||
if doReplace:
|
||||
# Extend to all relevant Unicode characters
|
||||
self._trMap.update(str.maketrans(nwHtmlUnicode.U_TO_H))
|
||||
@@ -157,6 +151,9 @@ class ToHtml(Tokenizer):
|
||||
|
||||
for tType, tLine, tText, tFormat, tStyle in self.theTokens:
|
||||
|
||||
# Replace < and > before adding html tags
|
||||
tText = tText.replace("<", "<").replace(">", ">")
|
||||
|
||||
# Styles
|
||||
aStyle = []
|
||||
if tStyle is not None and self.cssStyles:
|
||||
|
||||
Reference in New Issue
Block a user