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:
|
||||
|
||||
@@ -459,28 +459,16 @@ class Tokenizer():
|
||||
if aLine.startswith(">>"):
|
||||
tagRight = True
|
||||
aLine = aLine[2:].lstrip(" ")
|
||||
elif aLine.startswith(">>"):
|
||||
tagRight = True
|
||||
aLine = aLine[8:].lstrip(" ")
|
||||
elif aLine.startswith(">"):
|
||||
indLeft = True
|
||||
aLine = aLine[1:].lstrip(" ")
|
||||
elif aLine.startswith(">"):
|
||||
indLeft = True
|
||||
aLine = aLine[4:].lstrip(" ")
|
||||
|
||||
if aLine.endswith("<<"):
|
||||
tagLeft = True
|
||||
aLine = aLine[:-2].rstrip(" ")
|
||||
elif aLine.endswith("<<"):
|
||||
tagLeft = True
|
||||
aLine = aLine[:-8].rstrip(" ")
|
||||
elif aLine.endswith("<"):
|
||||
indRight = True
|
||||
aLine = aLine[:-1].rstrip(" ")
|
||||
elif aLine.endswith("<"):
|
||||
indRight = True
|
||||
aLine = aLine[:-4].rstrip(" ")
|
||||
|
||||
textAlign = defAlign
|
||||
if tagLeft and tagRight:
|
||||
|
||||
Reference in New Issue
Block a user