Properly export tabs to text and html

This commit is contained in:
Veronica K. B. Olsen
2019-11-01 17:13:47 +01:00
parent c4e090b5eb
commit 36ce75e937
6 changed files with 30 additions and 21 deletions
+1
View File
@@ -44,6 +44,7 @@ class ToHtml(Tokenizer):
"<" : "&lt;",
">" : "&gt;",
"&" : "&amp;",
"\t" : "&emsp;",
nwUnicode.U_ENDASH : nwUnicode.H_ENDASH,
nwUnicode.U_EMDASH : nwUnicode.H_EMDASH,
nwUnicode.U_HELLIP : nwUnicode.H_HELLIP,
+2 -1
View File
@@ -30,6 +30,7 @@ class ToText(Tokenizer):
Tokenizer.doAutoReplace(self)
repDict = {
"\t" : " ",
nwUnicode.U_NBSP : " ",
}
xRep = re.compile("|".join([re.escape(k) for k in repDict.keys()]), flags=re.DOTALL)
@@ -92,7 +93,7 @@ class ToText(Tokenizer):
# indicating a new paragraph.
if tType == self.T_EMPTY:
if len(thisPar) > 0:
tTemp = " ".join(thisPar)
tTemp = "\n".join(thisPar)
self.theResult += "%s\n\n" % tTemp.rstrip()
thisPar = []
+4 -4
View File
@@ -62,14 +62,14 @@ class Tokenizer():
self.theTokens = None
self.theResult = None
self.wordWrap = 80
self.wordWrap = 0
self.doComments = False
self.doKeywords = False
self.fmtTitle = "%title%"
self.fmtChapter = "Chapter %numword%: %title%"
self.fmtChapter = "%title%"
self.fmtUnNum = "%title%"
self.fmtScene = "* * *"
self.fmtScene = "%title%"
self.fmtSection = "%title%"
self.hideScene = False
@@ -224,7 +224,7 @@ class Tokenizer():
isScene = self.theItem.itemLayout == nwItemLayout.SCENE
isNote = self.theItem.itemLayout == nwItemLayout.NOTE
# No special header formatting for notes and no layout files
# No special header formatting for notes and no-layout files
if isNone: return
if isNote: return
@@ -2,3 +2,10 @@
**By Jane Doh**
More Text
Even More Text
What is this?
Where is this?
+10 -10
View File
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="0.3.2" fileVersion="1.0" timeStamp="2019-10-31 16:42:12">
<novelWriterXML appVersion="0.3.2" fileVersion="1.0" timeStamp="2019-11-01 16:56:25">
<project>
<name>Sample Project</name>
<title>Sample Project</title>
@@ -9,9 +9,9 @@
</project>
<settings>
<spellCheck>True</spellCheck>
<lastEdited>b8136a5a774a0</lastEdited>
<lastEdited>53b69b83cdafc</lastEdited>
<lastViewed>ba8a28a246524</lastViewed>
<lastWordCount>884</lastWordCount>
<lastWordCount>895</lastWordCount>
<autoReplace>
<A>B</A>
<B>E</B>
@@ -48,10 +48,10 @@
<status>Started</status>
<expanded>False</expanded>
<layout>TITLE</layout>
<charCount>23</charCount>
<wordCount>5</wordCount>
<paraCount>1</paraCount>
<cursorPos>16</cursorPos>
<charCount>73</charCount>
<wordCount>16</wordCount>
<paraCount>5</paraCount>
<cursorPos>85</cursorPos>
</item>
<item handle="e7ded148d6e4a" order="1" parent="7031beac91f75">
<name>Some Chapter</name>
@@ -94,7 +94,7 @@
<charCount>412</charCount>
<wordCount>82</wordCount>
<paraCount>2</paraCount>
<cursorPos>448</cursorPos>
<cursorPos>43</cursorPos>
</item>
<item handle="ba8a28a246524" order="3" parent="e7ded148d6e4a">
<name>Interlude</name>
@@ -103,10 +103,10 @@
<status>Finished</status>
<expanded>False</expanded>
<layout>UNNUMBERED</layout>
<charCount>630</charCount>
<charCount>633</charCount>
<wordCount>101</wordCount>
<paraCount>3</paraCount>
<cursorPos>648</cursorPos>
<cursorPos>164</cursorPos>
</item>
<item handle="96b68994dfa3d" order="4" parent="e7ded148d6e4a">
<name>A Note on Ipsums</name>