Merge pull request #113 from vkbo/export_changes

Export Fixes
This commit is contained in:
Veronica K. Berglyd Olsen
2019-11-01 19:46:50 +01:00
committed by GitHub
7 changed files with 39 additions and 41 deletions
+9 -3
View File
@@ -40,10 +40,16 @@ class ToHtml(Tokenizer):
def doAutoReplace(self): def doAutoReplace(self):
Tokenizer.doAutoReplace(self) Tokenizer.doAutoReplace(self)
if self.forPreview:
tabFmt = " "*8
else:
tabFmt = " "
repDict = { repDict = {
"<" : "&lt;", "<" : "&lt;",
">" : "&gt;", ">" : "&gt;",
"&" : "&amp;", "&" : "&amp;",
"\t" : tabFmt,
nwUnicode.U_ENDASH : nwUnicode.H_ENDASH, nwUnicode.U_ENDASH : nwUnicode.H_ENDASH,
nwUnicode.U_EMDASH : nwUnicode.H_EMDASH, nwUnicode.U_EMDASH : nwUnicode.H_EMDASH,
nwUnicode.U_HELLIP : nwUnicode.H_HELLIP, nwUnicode.U_HELLIP : nwUnicode.H_HELLIP,
+2 -1
View File
@@ -30,6 +30,7 @@ class ToText(Tokenizer):
Tokenizer.doAutoReplace(self) Tokenizer.doAutoReplace(self)
repDict = { repDict = {
"\t" : " ",
nwUnicode.U_NBSP : " ", nwUnicode.U_NBSP : " ",
} }
xRep = re.compile("|".join([re.escape(k) for k in repDict.keys()]), flags=re.DOTALL) 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. # indicating a new paragraph.
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)
self.theResult += "%s\n\n" % tTemp.rstrip() self.theResult += "%s\n\n" % tTemp.rstrip()
thisPar = [] thisPar = []
+5 -5
View File
@@ -62,14 +62,14 @@ class Tokenizer():
self.theTokens = None self.theTokens = None
self.theResult = None self.theResult = None
self.wordWrap = 80 self.wordWrap = 0
self.doComments = False self.doComments = False
self.doKeywords = False self.doKeywords = False
self.fmtTitle = "%title%" self.fmtTitle = "%title%"
self.fmtChapter = "Chapter %numword%: %title%" self.fmtChapter = "%title%"
self.fmtUnNum = "%title%" self.fmtUnNum = "%title%"
self.fmtScene = "* * *" self.fmtScene = "%title%"
self.fmtSection = "%title%" self.fmtSection = "%title%"
self.hideScene = False self.hideScene = False
@@ -224,7 +224,7 @@ class Tokenizer():
isScene = self.theItem.itemLayout == nwItemLayout.SCENE isScene = self.theItem.itemLayout == nwItemLayout.SCENE
isNote = self.theItem.itemLayout == nwItemLayout.NOTE 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 isNone: return
if isNote: return if isNote: return
@@ -285,7 +285,7 @@ class Tokenizer():
tFormat = tToken[2] tFormat = tToken[2]
self.theTokens[n] = (tType,tText,tFormat,self.A_CENTRE) self.theTokens[n] = (tType,tText,tFormat,self.A_CENTRE)
self.theTokens[n] = (self.T_PBREAK,"",None,self.A_LEFT) self.theTokens.append((self.T_PBREAK,"",None,self.A_LEFT))
return return
+3 -19
View File
@@ -39,6 +39,7 @@ class GuiDocViewer(QTextBrowser):
self.qDocument = self.document() self.qDocument = self.document()
self.setMinimumWidth(300) self.setMinimumWidth(300)
self.setOpenExternalLinks(False)
self.initViewer() self.initViewer()
theOpt = QTextOption() theOpt = QTextOption()
@@ -170,24 +171,11 @@ class GuiDocViewer(QTextBrowser):
styleSheet = ( styleSheet = (
"body {{" "body {{"
" font-size: {textSize:.1f}pt;"
" color: rgb({tColR},{tColG},{tColB});" " color: rgb({tColR},{tColG},{tColB});"
" font-size: {textSize:.1f}pt;"
"}}\n" "}}\n"
"h1 {{" "h1, h2, h3, h4 {{"
" color: rgb({hColR},{hColG},{hColB});" " color: rgb({hColR},{hColG},{hColB});"
" font-size: {h1Size:.1f}pt;"
"}}\n"
"h2 {{"
" color: rgb({hColR},{hColG},{hColB});"
" font-size: {h2Size:.1f}pt;"
"}}\n"
"h3 {{"
" color: rgb({hColR},{hColG},{hColB});"
" font-size: {h3Size:.1f}pt;"
"}}\n"
"h4 {{"
" color: rgb({hColR},{hColG},{hColB});"
" font-size: {h4Size:.1f}pt;"
"}}\n" "}}\n"
"a {{" "a {{"
" color: rgb({aColR},{aColG},{aColB});" " color: rgb({aColR},{aColG},{aColB});"
@@ -212,10 +200,6 @@ class GuiDocViewer(QTextBrowser):
).format( ).format(
textSize = self.mainConf.textSize, textSize = self.mainConf.textSize,
preSize = self.mainConf.textSize*0.9, preSize = self.mainConf.textSize*0.9,
h1Size = self.mainConf.textSize*1.8,
h2Size = self.mainConf.textSize*1.6,
h3Size = self.mainConf.textSize*1.4,
h4Size = self.mainConf.textSize*1.2,
tColR = self.theTheme.colText[0], tColR = self.theTheme.colText[0],
tColG = self.theTheme.colText[1], tColG = self.theTheme.colText[1],
tColB = self.theTheme.colText[2], tColB = self.theTheme.colText[2],
@@ -2,3 +2,10 @@
**By Jane Doh** **By Jane Doh**
More Text
Even More Text
What is this?
Where is this?
@@ -10,6 +10,6 @@ I understand equations, both the simple and quadratical
About binomial theorem I'm teeming with a lot o news About binomial theorem I'm teeming with a lot o news
With many cheerful facts about the square of the hypotenuse With many cheerful facts about the square of the hypotenuse
With many cheerful facts about the square of the hypotenuse With many cheerful facts about the square of the hypotenuse
With many cheerful facts about the square of the hypotenuse With many cheerful facts about the square of the hypotenuse
With many cheerful facts about the square of the hypotepotenuse With many cheerful facts about the square of the hypotepotenuse
+10 -10
View File
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?> <?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> <project>
<name>Sample Project</name> <name>Sample Project</name>
<title>Sample Project</title> <title>Sample Project</title>
@@ -9,9 +9,9 @@
</project> </project>
<settings> <settings>
<spellCheck>True</spellCheck> <spellCheck>True</spellCheck>
<lastEdited>b8136a5a774a0</lastEdited> <lastEdited>53b69b83cdafc</lastEdited>
<lastViewed>ba8a28a246524</lastViewed> <lastViewed>ba8a28a246524</lastViewed>
<lastWordCount>884</lastWordCount> <lastWordCount>895</lastWordCount>
<autoReplace> <autoReplace>
<A>B</A> <A>B</A>
<B>E</B> <B>E</B>
@@ -48,10 +48,10 @@
<status>Started</status> <status>Started</status>
<expanded>False</expanded> <expanded>False</expanded>
<layout>TITLE</layout> <layout>TITLE</layout>
<charCount>23</charCount> <charCount>73</charCount>
<wordCount>5</wordCount> <wordCount>16</wordCount>
<paraCount>1</paraCount> <paraCount>5</paraCount>
<cursorPos>16</cursorPos> <cursorPos>85</cursorPos>
</item> </item>
<item handle="e7ded148d6e4a" order="1" parent="7031beac91f75"> <item handle="e7ded148d6e4a" order="1" parent="7031beac91f75">
<name>Some Chapter</name> <name>Some Chapter</name>
@@ -94,7 +94,7 @@
<charCount>412</charCount> <charCount>412</charCount>
<wordCount>82</wordCount> <wordCount>82</wordCount>
<paraCount>2</paraCount> <paraCount>2</paraCount>
<cursorPos>448</cursorPos> <cursorPos>43</cursorPos>
</item> </item>
<item handle="ba8a28a246524" order="3" parent="e7ded148d6e4a"> <item handle="ba8a28a246524" order="3" parent="e7ded148d6e4a">
<name>Interlude</name> <name>Interlude</name>
@@ -103,10 +103,10 @@
<status>Finished</status> <status>Finished</status>
<expanded>False</expanded> <expanded>False</expanded>
<layout>UNNUMBERED</layout> <layout>UNNUMBERED</layout>
<charCount>630</charCount> <charCount>633</charCount>
<wordCount>101</wordCount> <wordCount>101</wordCount>
<paraCount>3</paraCount> <paraCount>3</paraCount>
<cursorPos>648</cursorPos> <cursorPos>164</cursorPos>
</item> </item>
<item handle="96b68994dfa3d" order="4" parent="e7ded148d6e4a"> <item handle="96b68994dfa3d" order="4" parent="e7ded148d6e4a">
<name>A Note on Ipsums</name> <name>A Note on Ipsums</name>