Added support for hard line breaks, with higlighting and export support

This commit is contained in:
Veronica K. B. Olsen
2019-10-28 21:30:46 +01:00
parent 59e5a584f2
commit 57bc837056
7 changed files with 38 additions and 20 deletions
+6 -2
View File
@@ -67,7 +67,8 @@ class ToHtml(Tokenizer):
if tType == self.T_EMPTY:
if len(thisPar) > 0:
self.theResult += "<p%s>%s</p>\n" % (hStyle," ".join(thisPar))
tTemp = "".join(thisPar)
self.theResult += "<p%s>%s</p>\n" % (hStyle,tTemp.rstrip())
thisPar = []
elif tType == self.T_HEAD1:
@@ -92,7 +93,10 @@ class ToHtml(Tokenizer):
tTemp = tText
for xPos, xLen, xFmt in reversed(tFormat):
tTemp = tTemp[:xPos]+htmlTags[xFmt]+tTemp[xPos+xLen:]
thisPar.append(tTemp)
if tText.endswith(" "):
thisPar.append(tTemp.rstrip()+"<br/>")
else:
thisPar.append(tTemp.rstrip()+" ")
elif tType == self.T_COMMENT and self.doComments:
self.theResult += "<div class='comment'>%s</div>\n" % tText
+4 -1
View File
@@ -95,7 +95,10 @@ class ToLaTeX(Tokenizer):
self.theResult += "\\bigskip\n\n"
elif tType == self.T_TEXT:
thisPar.append(self._escapeUnicode(tText))
if tText.endswith(" "):
thisPar.append(self._escapeUnicode(tText.rstrip())+"\\newline")
else:
thisPar.append(self._escapeUnicode(tText.rstrip()))
elif tType == self.T_PBREAK:
self.theResult += "\\newpage\n\n"
+2 -1
View File
@@ -80,7 +80,8 @@ class ToText(Tokenizer):
# indicating a new paragraph.
if tType == self.T_EMPTY:
if len(thisPar) > 0:
self.theResult += "%s\n\n" % " ".join(thisPar)
tTemp = " ".join(thisPar)
self.theResult += "%s\n\n" % tTemp.rstrip())
thisPar = []
elif tType == self.T_HEAD1: