diff --git a/nw/core/tohtml.py b/nw/core/tohtml.py
index 180c2da8..5586575d 100644
--- a/nw/core/tohtml.py
+++ b/nw/core/tohtml.py
@@ -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 = "
".join(thisPar)
tmpResult.append("
%s
\n" % (parStyle, parClass, tTemp.rstrip()))
thisPar = []
parStyle = None
- hasHardBreak = False
elif tType == self.T_TITLE:
tHead = tText.replace(r"\\", "
")
@@ -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() + "
")
- hasHardBreak = True
- else:
- thisPar.append(tTemp.rstrip() + " ")
+ thisPar.append(tTemp.rstrip())
elif tType == self.T_SYNOPSIS and self.doSynopsis:
tmpResult.append(self._formatSynopsis(tText))
diff --git a/nw/core/tomd.py b/nw/core/tomd.py
index 684a23fb..05645a67 100644
--- a/nw/core/tomd.py
+++ b/nw/core/tomd.py
@@ -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))
diff --git a/nw/core/toodt.py b/nw/core/toodt.py
index ce67e8c0..7fdb91bf 100644
--- a/nw/core/toodt.py
+++ b/nw/core/toodt.py
@@ -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)