Fixed rendering of tabs in the document viewer

This commit is contained in:
Veronica K. B. Olsen
2019-11-01 18:24:42 +01:00
parent 36ce75e937
commit f823367917
2 changed files with 22 additions and 19 deletions
+6 -1
View File
@@ -40,11 +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" : "&emsp;", "\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,
+16 -18
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()
@@ -116,6 +117,18 @@ class GuiDocViewer(QTextBrowser):
self.theHandle = tHandle self.theHandle = tHandle
self.theProject.setLastViewed(tHandle) self.theProject.setLastViewed(tHandle)
print("")
print("*"*140)
print("")
print(aDoc.theResult)
print("")
print("*"*140)
print("")
print(self.toHtml())
print("")
print("*"*140)
print("")
self.theParent.docMeta.refreshReferences(tHandle) self.theParent.docMeta.refreshReferences(tHandle)
return True return True
@@ -173,21 +186,8 @@ class GuiDocViewer(QTextBrowser):
" font-size: {textSize:.1f}pt;" " font-size: {textSize:.1f}pt;"
" color: rgb({tColR},{tColG},{tColB});" " color: rgb({tColR},{tColG},{tColB});"
"}}\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 +212,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],
@@ -237,6 +233,8 @@ class GuiDocViewer(QTextBrowser):
) )
self.qDocument.setDefaultStyleSheet(styleSheet) self.qDocument.setDefaultStyleSheet(styleSheet)
print(styleSheet)
return True return True
# END Class GuiDocViewer # END Class GuiDocViewer