From 63b471e10d9b282e8c6c98a2ce032dab68fcc467 Mon Sep 17 00:00:00 2001 From: Curtis Gedak Date: Thu, 15 Feb 2018 12:46:22 -0700 Subject: [PATCH] Make word match for spell check exclude underscore from words See issue #283. Adds (?!_) to perform negative lookahead to exclude "_" from pattern match. https://stackoverflow.com/questions/14858346/regular-expressions-how-to-express-w-without-underscore --- manuskript/ui/highlighters/basicHighlighter.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/manuskript/ui/highlighters/basicHighlighter.py b/manuskript/ui/highlighters/basicHighlighter.py index 960b7201..6e45eba2 100644 --- a/manuskript/ui/highlighters/basicHighlighter.py +++ b/manuskript/ui/highlighters/basicHighlighter.py @@ -146,8 +146,9 @@ class BasicHighlighter(QSyntaxHighlighter): textedText = text + " " # Based on http://john.nachtimwald.com/2009/08/22/qplaintextedit-with-in-line-spell-check/ - WORDS = r'(?iu)([\w\']+)[^\'\w]' - # (?iu) means case insensitive and unicode + WORDS = r'(?iu)(((?!_)[\w\'])+)' + # (?iu) means case insensitive and Unicode + # (?!_) means perform negative lookahead to exclude "_" from pattern match. See issue #283 if hasattr(self.editor, "spellcheck") and self.editor.spellcheck: for word_object in re.finditer(WORDS, textedText): if (self.editor._dict