Set mark colour in viewer, not in html generator
This commit is contained in:
@@ -29,9 +29,7 @@ import logging
|
|||||||
from time import time
|
from time import time
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from PyQt5.QtGui import QColor
|
from novelwriter import CONFIG
|
||||||
|
|
||||||
from novelwriter import CONFIG, SHARED
|
|
||||||
from novelwriter.common import formatTimeStamp
|
from novelwriter.common import formatTimeStamp
|
||||||
from novelwriter.constants import nwHeadFmt, nwKeyWords, nwLabels, nwHtmlUnicode
|
from novelwriter.constants import nwHeadFmt, nwKeyWords, nwLabels, nwHtmlUnicode
|
||||||
from novelwriter.core.project import NWProject
|
from novelwriter.core.project import NWProject
|
||||||
@@ -126,7 +124,6 @@ class ToHtml(Tokenizer):
|
|||||||
def doConvert(self) -> None:
|
def doConvert(self) -> None:
|
||||||
"""Convert the list of text tokens into an HTML document."""
|
"""Convert the list of text tokens into an HTML document."""
|
||||||
if self._genMode == self.M_PREVIEW:
|
if self._genMode == self.M_PREVIEW:
|
||||||
colMark = SHARED.theme.colMark.name(QColor.NameFormat.HexArgb)
|
|
||||||
htmlTags = { # HTML4 + CSS2 (for Qt)
|
htmlTags = { # HTML4 + CSS2 (for Qt)
|
||||||
self.FMT_B_B: "<b>",
|
self.FMT_B_B: "<b>",
|
||||||
self.FMT_B_E: "</b>",
|
self.FMT_B_E: "</b>",
|
||||||
@@ -136,8 +133,8 @@ class ToHtml(Tokenizer):
|
|||||||
self.FMT_D_E: "</span>",
|
self.FMT_D_E: "</span>",
|
||||||
self.FMT_U_B: "<u>",
|
self.FMT_U_B: "<u>",
|
||||||
self.FMT_U_E: "</u>",
|
self.FMT_U_E: "</u>",
|
||||||
self.FMT_M_B: f"<span style='background-color: {colMark};'>",
|
self.FMT_M_B: "<mark>",
|
||||||
self.FMT_M_E: "</span>",
|
self.FMT_M_E: "</mark>",
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
htmlTags = { # HTML5 (for export)
|
htmlTags = { # HTML5 (for export)
|
||||||
|
|||||||
@@ -466,48 +466,30 @@ class GuiDocViewer(QTextBrowser):
|
|||||||
colText = SHARED.theme.colText
|
colText = SHARED.theme.colText
|
||||||
colHead = SHARED.theme.colHead
|
colHead = SHARED.theme.colHead
|
||||||
colVals = SHARED.theme.colVal
|
colVals = SHARED.theme.colVal
|
||||||
colEmph = SHARED.theme.colEmph
|
colMark = SHARED.theme.colMark
|
||||||
colKeys = SHARED.theme.colKey
|
colKeys = SHARED.theme.colKey
|
||||||
colHide = SHARED.theme.colHidden
|
colHide = SHARED.theme.colHidden
|
||||||
colMods = SHARED.theme.colMod
|
colMods = SHARED.theme.colMod
|
||||||
colOpts = SHARED.theme.colOpt
|
colOpts = SHARED.theme.colOpt
|
||||||
styleSheet = (
|
styleSheet = (
|
||||||
"body {{"
|
"body {{color: rgb({rT}, {gT}, {bT});}}\n"
|
||||||
" color: rgb({tColR}, {tColG}, {tColB});"
|
"h1, h2, h3, h4 {{color: rgb({rH}, {gH}, {bH});}}\n"
|
||||||
"}}\n"
|
"a {{color: rgb({rA}, {gA}, {bA});}}\n"
|
||||||
"h1, h2, h3, h4 {{"
|
"mark {{background-color: rgba({rE}, {gE}, {bE}, {aE});}}\n"
|
||||||
" color: rgb({hColR}, {hColG}, {hColB});"
|
".tags {{color: rgb({rK}, {gK}, {bK});}}\n"
|
||||||
"}}\n"
|
".optional {{color: rgb({rO}, {gO}, {bO});}}\n"
|
||||||
"a {{"
|
".comment {{color: rgb({rC}, {gC}, {bC});}}\n"
|
||||||
" color: rgb({aColR}, {aColG}, {aColB});"
|
".synopsis {{color: rgb({rM}, {gM}, {bM});}}\n"
|
||||||
"}}\n"
|
".title {{text-align: center;}}\n"
|
||||||
"mark {{"
|
|
||||||
" color: rgb({eColR}, {eColG}, {eColB});"
|
|
||||||
"}}\n"
|
|
||||||
".tags {{"
|
|
||||||
" color: rgb({kColR}, {kColG}, {kColB});"
|
|
||||||
"}}\n"
|
|
||||||
".optional {{"
|
|
||||||
" color: rgb({oColR}, {oColG}, {oColB});"
|
|
||||||
"}}\n"
|
|
||||||
".comment {{"
|
|
||||||
" color: rgb({cColR}, {cColG}, {cColB});"
|
|
||||||
"}}\n"
|
|
||||||
".synopsis {{"
|
|
||||||
" color: rgb({mColR}, {mColG}, {mColB});"
|
|
||||||
"}}\n"
|
|
||||||
".title {{"
|
|
||||||
" text-align: center;"
|
|
||||||
"}}\n"
|
|
||||||
).format(
|
).format(
|
||||||
tColR=colText.red(), tColG=colText.green(), tColB=colText.blue(),
|
rT=colText.red(), gT=colText.green(), bT=colText.blue(),
|
||||||
hColR=colHead.red(), hColG=colHead.green(), hColB=colHead.blue(),
|
rH=colHead.red(), gH=colHead.green(), bH=colHead.blue(),
|
||||||
aColR=colVals.red(), aColG=colVals.green(), aColB=colVals.blue(),
|
rA=colVals.red(), gA=colVals.green(), bA=colVals.blue(),
|
||||||
eColR=colEmph.red(), eColG=colEmph.green(), eColB=colEmph.blue(),
|
rE=colMark.red(), gE=colMark.green(), bE=colMark.blue(), aE=colMark.alpha(),
|
||||||
kColR=colKeys.red(), kColG=colKeys.green(), kColB=colKeys.blue(),
|
rK=colKeys.red(), gK=colKeys.green(), bK=colKeys.blue(),
|
||||||
cColR=colHide.red(), cColG=colHide.green(), cColB=colHide.blue(),
|
rC=colHide.red(), gC=colHide.green(), bC=colHide.blue(),
|
||||||
mColR=colMods.red(), mColG=colMods.green(), mColB=colMods.blue(),
|
rM=colMods.red(), gM=colMods.green(), bM=colMods.blue(),
|
||||||
oColR=colOpts.red(), oColG=colOpts.green(), oColB=colOpts.blue(),
|
rO=colOpts.red(), gO=colOpts.green(), bO=colOpts.blue(),
|
||||||
)
|
)
|
||||||
self.document().setDefaultStyleSheet(styleSheet)
|
self.document().setDefaultStyleSheet(styleSheet)
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -20,7 +20,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
"""
|
"""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from PyQt5.QtGui import QColor, QPixmap
|
from PyQt5.QtGui import QPixmap
|
||||||
from PyQt5.QtWidgets import QWidget
|
from PyQt5.QtWidgets import QWidget
|
||||||
|
|
||||||
|
|
||||||
@@ -76,7 +76,6 @@ class MockTheme:
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.baseIconSize = 10
|
self.baseIconSize = 10
|
||||||
self.colMark = QColor(255, 255, 166, 128)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def getPixmap(self, *a):
|
def getPixmap(self, *a):
|
||||||
|
|||||||
Reference in New Issue
Block a user