Allow line breaks in paragraphs
This commit is contained in:
+3
-9
@@ -151,7 +151,6 @@ class ToHtml(Tokenizer):
|
||||
thisPar = []
|
||||
parStyle = None
|
||||
tmpResult = []
|
||||
hasHardBreak = False
|
||||
|
||||
for tType, tLine, tText, tFormat, tStyle in self.theTokens:
|
||||
|
||||
@@ -196,16 +195,15 @@ class ToHtml(Tokenizer):
|
||||
if tType == self.T_EMPTY:
|
||||
if parStyle is None:
|
||||
parStyle = ""
|
||||
if hasHardBreak and self.cssStyles:
|
||||
if len(thisPar) > 1 and self.cssStyles:
|
||||
parClass = " class='break'"
|
||||
else:
|
||||
parClass = ""
|
||||
if len(thisPar) > 0:
|
||||
tTemp = "".join(thisPar)
|
||||
tTemp = "<br/>".join(thisPar)
|
||||
tmpResult.append("<p%s%s>%s</p>\n" % (parStyle, parClass, tTemp.rstrip()))
|
||||
thisPar = []
|
||||
parStyle = None
|
||||
hasHardBreak = False
|
||||
|
||||
elif tType == self.T_TITLE:
|
||||
tHead = tText.replace(r"\\", "<br/>")
|
||||
@@ -239,11 +237,7 @@ class ToHtml(Tokenizer):
|
||||
parStyle = hStyle
|
||||
for xPos, xLen, xFmt in reversed(tFormat):
|
||||
tTemp = tTemp[:xPos] + htmlTags[xFmt] + tTemp[xPos+xLen:]
|
||||
if tText.endswith(" "):
|
||||
thisPar.append(tTemp.rstrip() + "<br/>")
|
||||
hasHardBreak = True
|
||||
else:
|
||||
thisPar.append(tTemp.rstrip() + " ")
|
||||
thisPar.append(tTemp.rstrip())
|
||||
|
||||
elif tType == self.T_SYNOPSIS and self.doSynopsis:
|
||||
tmpResult.append(self._formatSynopsis(tText))
|
||||
|
||||
+3
-6
@@ -89,12 +89,12 @@ class ToMarkdown(Tokenizer):
|
||||
thisPar = []
|
||||
tmpResult = []
|
||||
|
||||
for tType, tLine, tText, tFormat, tStyle in self.theTokens:
|
||||
for tType, _, tText, tFormat, tStyle in self.theTokens:
|
||||
|
||||
# Process Text Type
|
||||
if tType == self.T_EMPTY:
|
||||
if len(thisPar) > 0:
|
||||
tTemp = "".join(thisPar)
|
||||
tTemp = "\n".join(thisPar)
|
||||
tmpResult.append("%s\n\n" % tTemp.rstrip(" "))
|
||||
thisPar = []
|
||||
|
||||
@@ -128,10 +128,7 @@ class ToMarkdown(Tokenizer):
|
||||
tTemp = tText
|
||||
for xPos, xLen, xFmt in reversed(tFormat):
|
||||
tTemp = tTemp[:xPos] + mdTags[xFmt] + tTemp[xPos+xLen:]
|
||||
if tText.endswith(" "):
|
||||
thisPar.append(tTemp.rstrip() + " \n")
|
||||
else:
|
||||
thisPar.append(tTemp.rstrip() + " ")
|
||||
thisPar.append(tTemp.rstrip())
|
||||
|
||||
elif tType == self.T_SYNOPSIS and self.doSynopsis:
|
||||
tmpResult.append("**%s:** %s\n\n" % (self._localLookup("Synopsis"), tText))
|
||||
|
||||
+6
-13
@@ -327,8 +327,7 @@ class ToOdt(Tokenizer):
|
||||
thisPar = []
|
||||
thisFmt = []
|
||||
parStyle = None
|
||||
hasHardBreak = False
|
||||
for tType, tLine, tText, tFormat, tStyle in self.theTokens:
|
||||
for tType, _, tText, tFormat, tStyle in self.theTokens:
|
||||
|
||||
# Styles
|
||||
oStyle = ODTParagraphStyle()
|
||||
@@ -359,13 +358,13 @@ class ToOdt(Tokenizer):
|
||||
|
||||
# Process Text Types
|
||||
if tType == self.T_EMPTY:
|
||||
if hasHardBreak and parStyle is not None:
|
||||
if len(thisPar) > 1 and parStyle is not None:
|
||||
if self.doJustify:
|
||||
parStyle.setTextAlign("left")
|
||||
|
||||
if len(thisPar) > 0:
|
||||
tTemp = "".join(thisPar)
|
||||
fTemp = "".join(thisFmt)
|
||||
tTemp = "\n".join(thisPar)
|
||||
fTemp = " ".join(thisFmt)
|
||||
tTxt = tTemp.rstrip()
|
||||
tFmt = fTemp[:len(tTxt)]
|
||||
self._addTextPar("Text_Body", parStyle, tTxt, theFmt=tFmt)
|
||||
@@ -373,7 +372,6 @@ class ToOdt(Tokenizer):
|
||||
thisPar = []
|
||||
thisFmt = []
|
||||
parStyle = None
|
||||
hasHardBreak = False
|
||||
|
||||
elif tType == self.T_TITLE:
|
||||
tHead = tText.replace(r"\\", "\n")
|
||||
@@ -412,13 +410,8 @@ class ToOdt(Tokenizer):
|
||||
|
||||
tTxt = tTemp.rstrip()
|
||||
tFmt = tFmt[:len(tTxt)]
|
||||
if tText.endswith(" "):
|
||||
thisPar.append(tTxt + "\n")
|
||||
thisFmt.append(tFmt + " ")
|
||||
hasHardBreak = True
|
||||
else:
|
||||
thisPar.append(tTxt + " ")
|
||||
thisFmt.append(tFmt + " ")
|
||||
thisPar.append(tTxt)
|
||||
thisFmt.append(tFmt)
|
||||
|
||||
elif tType == self.T_SYNOPSIS and self.doSynopsis:
|
||||
tTemp, fTemp = self._formatSynopsis(tText)
|
||||
|
||||
Reference in New Issue
Block a user