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