Added unicode constants class, and support for non-breaking spaces, which aren't preserved on save.

This commit is contained in:
Veronica K. B. Olsen
2019-10-29 11:35:40 +01:00
parent 2c63d1fbf2
commit 146756a395
6 changed files with 111 additions and 35 deletions
+10
View File
@@ -16,6 +16,8 @@ import nw
from PyQt5.QtCore import Qt, QRegularExpression
from PyQt5.QtGui import QColor, QTextCharFormat, QFont, QSyntaxHighlighter, QBrush
from nw.constants import nwUnicode
logger = logging.getLogger(__name__)
class GuiDocHighlighter(QSyntaxHighlighter):
@@ -87,6 +89,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
"strike" : self._makeFormat(self.colEmph, "strike"),
"underline" : self._makeFormat(self.colEmph, "underline"),
"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),
@@ -145,6 +148,13 @@ class GuiDocHighlighter(QSyntaxHighlighter):
}
))
# Non-breaking Space
self.hRules.append((
"[\u00a0]+", {
0 : self.hStyles["nobreak"],
}
))
# Markdown
self.hRules.append((
r"(?<![\w|\\])([\*]{2})(?!\s)(?m:(.+?))(?<![\s|\\])(\1)(?!\w)", {