Added more characters as valid word separators to the highlighter regex

This commit is contained in:
Veronica K. B. Olsen
2019-11-16 12:31:49 +01:00
parent 82aa1ad0a9
commit 2ab7828179
4 changed files with 19 additions and 11 deletions
+8 -2
View File
@@ -18,6 +18,8 @@ from PyQt5.QtGui import (
QColor, QTextCharFormat, QFont, QSyntaxHighlighter, QBrush
)
from nw.constants import nwUnicode
logger = logging.getLogger(__name__)
class GuiDocHighlighter(QSyntaxHighlighter):
@@ -150,7 +152,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
# Non-breaking Space
self.hRules.append((
"[\u00a0]+", {
"[%s]+" % nwUnicode.U_NBSP, {
0 : self.hStyles["nobreak"],
}
))
@@ -209,7 +211,11 @@ class GuiDocHighlighter(QSyntaxHighlighter):
self.rxRules.append((hReg, regRules))
# Build a QRegExp for spell checker
self.spellRx = QRegularExpression(r"\b[^\s]+\b")
# Include additional characters that the highlighter should
# consider to be word separators
wordSep = "_+"
wordSep += nwUnicode.U_EMDASH
self.spellRx = QRegularExpression("\\b[^\\s%s]+\\b" % wordSep)
self.spellRx.setPatternOptions(QRegularExpression.UseUnicodePropertiesOption)
return True