Some improvements and added comments to the converter classes

This commit is contained in:
Veronica K. B. Olsen
2019-10-18 22:41:54 +02:00
parent f8878535ba
commit d4e74848bc
3 changed files with 88 additions and 42 deletions
+6 -6
View File
@@ -53,19 +53,19 @@ class ToHtml(Tokenizer):
thisPar = []
for tType, tText, tFormat in self.theTokens:
if tType == "empty":
if tType == self.T_EMPTY:
if len(thisPar) > 0:
self.theResult += "<p>%s</p>\n" % " ".join(thisPar)
thisPar = []
elif tType == "header1":
elif tType == self.T_HEAD1:
self.theResult += "<h1>%s</h1>\n" % tText
elif tType == "header2":
elif tType == self.T_HEAD2:
self.theResult += "<h2>%s</h2>\n" % tText
elif tType == "header3":
elif tType == self.T_HEAD3:
self.theResult += "<h3>%s</h3>\n" % tText
elif tType == "header4":
elif tType == self.T_HEAD4:
self.theResult += "<h4>%s</h4>\n" % tText
elif tType == "text":
elif tType == self.T_TEXT:
tTemp = tText
for xPos, xLen, xFmt in reversed(tFormat):
tTemp = tTemp[:xPos]+htmlTags[xFmt]+tTemp[xPos+xLen:]