Added more characters as valid word separators to the highlighter regex
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user