diff --git a/nw/core/tohtml.py b/nw/core/tohtml.py
index 0c6199c2..bfb60984 100644
--- a/nw/core/tohtml.py
+++ b/nw/core/tohtml.py
@@ -48,7 +48,7 @@ class ToHtml(Tokenizer):
"<" : "<",
">" : ">",
"&" : "&",
- "\t" : " "*2,
+ # "\t" : "!!tab!!", # " "*2,
nwUnicode.U_ENDASH : nwUnicode.H_ENDASH,
nwUnicode.U_EMDASH : nwUnicode.H_EMDASH,
nwUnicode.U_HELLIP : nwUnicode.H_HELLIP,
@@ -77,7 +77,7 @@ class ToHtml(Tokenizer):
self.doKeywords = True
self.doComments = doComments
self.doSynopsis = doSynopsis
- self.repDict["\t"] = r"!!tab!!" # The viewer replaces these
+ # self.repDict["\t"] = r"!!tab!!" # The viewer replaces these
self._buildRegEx()
return
diff --git a/nw/gui/build.py b/nw/gui/build.py
index 81af3fa4..c13a3911 100644
--- a/nw/gui/build.py
+++ b/nw/gui/build.py
@@ -551,7 +551,6 @@ class GuiBuildNovel(QDialog):
isNone |= theItem.itemClass == nwItemClass.NO_CLASS
isNone |= theItem.itemClass == nwItemClass.TRASH
isNone |= theItem.parHandle == self.theProject.projTree.trashRoot()
- isNone |= theItem.parHandle == self.theProject.projTree.archiveRoot()
isNone |= theItem.parHandle is None
isNote = theItem.itemLayout == nwItemLayout.NOTE
isNovel = not isNone and not isNote
@@ -563,6 +562,10 @@ class GuiBuildNovel(QDialog):
if isNovel and not novelFiles:
return False
+ rootItem = self.theProject.projTree.getRootItem(theItem.itemHandle)
+ if rootItem.itemClass == nwItemClass.ARCHIVE:
+ return False
+
return True
def _saveDocument(self, theFormat):
@@ -1014,13 +1017,33 @@ class GuiBuildNovelDocView(QTextBrowser):
theText = "".join(theText)
self.buildTime = timeStamp
+ sPos = self.verticalScrollBar().value()
- theText = theText.replace(" ", " "*4)
+ # Refresh the tab stops
+ if self.mainConf.verQtValue >= 51000:
+ self.setTabStopDistance(self.mainConf.getTabWidth())
+ else:
+ self.setTabStopWidth(self.mainConf.getTabWidth())
+
+ theText = theText.replace("\t", "!!tab!!")
theText = theText.replace("", "")
theText = theText.replace("", "")
self.setHtml(theText)
+
+ while self.find("!!tab!!"):
+ theCursor = self.textCursor()
+ theCursor.insertText("\t")
+
+ self.verticalScrollBar().setValue(sPos)
self._updateBuildAge()
+ # This forces a repaint of the text, It's a hack to fix an occational
+ # issue where the find/replace above interfers with the rendering and
+ # leaves parts of the document blank.
+ textWidth = self.qDocument.textWidth()
+ self.qDocument.setTextWidth(textWidth - 5)
+ self.qDocument.setTextWidth(textWidth)
+
return
def setStyleSheet(self, theStyles=[]):
diff --git a/nw/gui/docviewer.py b/nw/gui/docviewer.py
index 3c7c9795..0f7e81cd 100644
--- a/nw/gui/docviewer.py
+++ b/nw/gui/docviewer.py
@@ -156,7 +156,20 @@ class GuiDocViewer(QTextBrowser):
self.setText("An error occurred while generating the preview.")
return False
- self.setHtml(aDoc.theResult)
+ # Refresh the tab stops
+ if self.mainConf.verQtValue >= 51000:
+ self.setTabStopDistance(self.mainConf.getTabWidth())
+ else:
+ self.setTabStopWidth(self.mainConf.getTabWidth())
+
+ self.setHtml(aDoc.theResult.replace("\t", "!!tab!!"))
+
+ # Loop through the text and put back in the tabs. Tabs are removed by
+ # the setHtml function, so the ToHtml class puts in a placeholder.
+ while self.find("!!tab!!"):
+ theCursor = self.textCursor()
+ theCursor.insertText("\t")
+
if self.theHandle == tHandle:
self.verticalScrollBar().setValue(sPos)
self.theHandle = tHandle
@@ -167,17 +180,12 @@ class GuiDocViewer(QTextBrowser):
# Make sure the main GUI knows we changed the content
self.theParent.viewMeta.refreshReferences(tHandle)
- # Loop through the text and put back in the tabs. Tabs are removed by
- # the setHtml function, so the ToHtml class puts in a placeholder.
- while self.find("!!tab!!"):
- theCursor = self.textCursor()
- theCursor.insertText("\t")
-
- # Refresh the tab stops
- if self.mainConf.verQtValue >= 51000:
- self.setTabStopDistance(self.mainConf.getTabWidth())
- else:
- self.setTabStopWidth(self.mainConf.getTabWidth())
+ # This forces a repaint of the text, It's a hack to fix an occational
+ # issue where the find/replace above interfers with the rendering and
+ # leaves parts of the document blank.
+ textWidth = self.qDocument.textWidth()
+ self.qDocument.setTextWidth(textWidth - 5)
+ self.qDocument.setTextWidth(textWidth)
return True
@@ -369,8 +377,6 @@ class GuiDocViewer(QTextBrowser):
"}}\n"
".comment {{"
" color: rgb({cColR},{cColG},{cColB});"
- " margin-left: 1em;"
- " margin-right: 1em;"
"}}\n"
".synopsis {{"
" color: rgb({mColR},{mColG},{mColB});"