Merge pull request #476 from vkbo/syntax
Syntax Highlighting of Strikethrough
This commit is contained in:
@@ -41,8 +41,8 @@ class nwConst():
|
||||
|
||||
class nwRegEx():
|
||||
|
||||
FMT_I = r"(?<![\w\\])(_)(?![\s_])(.+?)(?<![\s\\])(\1)(?!\w)"
|
||||
FMT_B = r"(?<![\w\\])([\*]{2})(?![\s\*])(.+?)(?<![\s\\])(\1)(?!\w)"
|
||||
FMT_EI = r"(?<![\w\\])(_)(?![\s_])(.+?)(?<![\s\\])(\1)(?!\w)"
|
||||
FMT_EB = r"(?<![\w\\])([\*]{2})(?![\s\*])(.+?)(?<![\s\\])(\1)(?!\w)"
|
||||
FMT_ST = r"(?<![\w\\])([~]{2})(?![\s~])(.+?)(?<![\s\\])(\1)(?!\w)"
|
||||
|
||||
# END Class nwRegEx
|
||||
|
||||
@@ -297,8 +297,8 @@ class Tokenizer():
|
||||
"""
|
||||
# RegExes for adding formatting tags within text lines
|
||||
rxFormats = [
|
||||
(QRegularExpression(nwRegEx.FMT_I), [None, self.FMT_I_B, None, self.FMT_I_E]),
|
||||
(QRegularExpression(nwRegEx.FMT_B), [None, self.FMT_B_B, None, self.FMT_B_E]),
|
||||
(QRegularExpression(nwRegEx.FMT_EI), [None, self.FMT_I_B, None, self.FMT_I_E]),
|
||||
(QRegularExpression(nwRegEx.FMT_EB), [None, self.FMT_B_B, None, self.FMT_B_E]),
|
||||
(QRegularExpression(nwRegEx.FMT_ST), [None, self.FMT_D_B, None, self.FMT_D_E]),
|
||||
]
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
self.colDialN = QColor(0, 0, 0)
|
||||
self.colDialD = QColor(0, 0, 0)
|
||||
self.colDialS = QColor(0, 0, 0)
|
||||
self.colComm = QColor(0, 0, 0)
|
||||
self.colHidden = QColor(0, 0, 0)
|
||||
self.colKey = QColor(0, 0, 0)
|
||||
self.colVal = QColor(0, 0, 0)
|
||||
self.colSpell = QColor(0, 0, 0)
|
||||
@@ -92,7 +92,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
self.colDialN = QColor(*self.theTheme.colDialN)
|
||||
self.colDialD = QColor(*self.theTheme.colDialD)
|
||||
self.colDialS = QColor(*self.theTheme.colDialS)
|
||||
self.colComm = QColor(*self.theTheme.colComm)
|
||||
self.colHidden = QColor(*self.theTheme.colHidden)
|
||||
self.colKey = QColor(*self.theTheme.colKey)
|
||||
self.colVal = QColor(*self.theTheme.colVal)
|
||||
self.colSpell = QColor(*self.theTheme.colSpell)
|
||||
@@ -118,14 +118,14 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
"header4h" : self._makeFormat(self.colHeadH, "bold", 1.2),
|
||||
"bold" : self._makeFormat(self.colEmph, "bold"),
|
||||
"italic" : self._makeFormat(self.colEmph, "italic"),
|
||||
"strike" : self._makeFormat(self.colEmph, "strike"),
|
||||
"strike" : self._makeFormat(self.colHidden, "strike"),
|
||||
"trailing" : self._makeFormat(self.colTrail, "background"),
|
||||
"nobreak" : self._makeFormat(self.colTrail, "background"),
|
||||
"dialogue1" : self._makeFormat(self.colDialN),
|
||||
"dialogue2" : self._makeFormat(self.colDialD),
|
||||
"dialogue3" : self._makeFormat(self.colDialS),
|
||||
"replace" : self._makeFormat(self.colRepTag),
|
||||
"hidden" : self._makeFormat(self.colComm),
|
||||
"hidden" : self._makeFormat(self.colHidden),
|
||||
"keyword" : self._makeFormat(self.colKey),
|
||||
"modifier" : self._makeFormat(self.colMod),
|
||||
"value" : self._makeFormat(self.colVal, "underline"),
|
||||
@@ -167,14 +167,14 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
|
||||
# Markdown
|
||||
self.hRules.append((
|
||||
nwRegEx.FMT_I, {
|
||||
nwRegEx.FMT_EI, {
|
||||
1 : self.hStyles["hidden"],
|
||||
2 : self.hStyles["italic"],
|
||||
3 : self.hStyles["hidden"],
|
||||
}
|
||||
))
|
||||
self.hRules.append((
|
||||
nwRegEx.FMT_B, {
|
||||
nwRegEx.FMT_EB, {
|
||||
1 : self.hStyles["hidden"],
|
||||
2 : self.hStyles["bold"],
|
||||
3 : self.hStyles["hidden"],
|
||||
|
||||
+3
-3
@@ -532,9 +532,9 @@ class GuiDocViewer(QTextBrowser):
|
||||
hColR = self.theTheme.colHead[0],
|
||||
hColG = self.theTheme.colHead[1],
|
||||
hColB = self.theTheme.colHead[2],
|
||||
cColR = self.theTheme.colComm[0],
|
||||
cColG = self.theTheme.colComm[1],
|
||||
cColB = self.theTheme.colComm[2],
|
||||
cColR = self.theTheme.colHidden[0],
|
||||
cColG = self.theTheme.colHidden[1],
|
||||
cColB = self.theTheme.colHidden[2],
|
||||
eColR = self.theTheme.colEmph[0],
|
||||
eColG = self.theTheme.colEmph[1],
|
||||
eColB = self.theTheme.colEmph[2],
|
||||
|
||||
+2
-2
@@ -103,7 +103,7 @@ class GuiTheme:
|
||||
self.colDialN = [0, 0, 0]
|
||||
self.colDialD = [0, 0, 0]
|
||||
self.colDialS = [0, 0, 0]
|
||||
self.colComm = [0, 0, 0]
|
||||
self.colHidden = [0, 0, 0]
|
||||
self.colKey = [0, 0, 0]
|
||||
self.colVal = [0, 0, 0]
|
||||
self.colSpell = [0, 0, 0]
|
||||
@@ -356,7 +356,7 @@ class GuiTheme:
|
||||
self.colDialN = self._loadColour(confParser, cnfSec, "straightquotes")
|
||||
self.colDialD = self._loadColour(confParser, cnfSec, "doublequotes")
|
||||
self.colDialS = self._loadColour(confParser, cnfSec, "singlequotes")
|
||||
self.colComm = self._loadColour(confParser, cnfSec, "hidden")
|
||||
self.colHidden = self._loadColour(confParser, cnfSec, "hidden")
|
||||
self.colKey = self._loadColour(confParser, cnfSec, "keyword")
|
||||
self.colVal = self._loadColour(confParser, cnfSec, "value")
|
||||
self.colSpell = self._loadColour(confParser, cnfSec, "spellcheckline")
|
||||
|
||||
+1
-1
@@ -1484,7 +1484,7 @@ def testThemes(qtbot, yesToAll, nwMinimal, nwTemp):
|
||||
assert nwGUI.theTheme.colDialN == [242, 119, 122]
|
||||
assert nwGUI.theTheme.colDialD == [153, 204, 153]
|
||||
assert nwGUI.theTheme.colDialS == [255, 204, 102]
|
||||
assert nwGUI.theTheme.colComm == [153, 153, 153]
|
||||
assert nwGUI.theTheme.colHidden == [153, 153, 153]
|
||||
assert nwGUI.theTheme.colKey == [242, 119, 122]
|
||||
assert nwGUI.theTheme.colVal == [204, 153, 204]
|
||||
assert nwGUI.theTheme.colSpell == [242, 119, 122]
|
||||
|
||||
Reference in New Issue
Block a user