From fbab930c447ccfcb975be3f40b59acf397f44cfb Mon Sep 17 00:00:00 2001 From: Shadow Date: Tue, 12 Sep 2023 18:57:03 -0700 Subject: [PATCH 1/3] Update spellchecker.py Corrected issue where words within certain quotations would show up as incorrectly spelled (ex: 'I'm fine') would indicate both words are misspelled --- manuskript/functions/spellchecker.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/manuskript/functions/spellchecker.py b/manuskript/functions/spellchecker.py index b4ae0d2c..d98fdd9a 100644 --- a/manuskript/functions/spellchecker.py +++ b/manuskript/functions/spellchecker.py @@ -187,6 +187,7 @@ def availableDictionaries(): def checkText(self, text): # Based on http://john.nachtimwald.com/2009/08/22/qplaintextedit-with-in-line-spell-check/ WORDS = r'(?iu)((?:[^_\W]|\')+)[^A-Za-z0-9\']' + # (?iu) means case insensitive and Unicode # ((?:[^_\W]|\')+) means words exclude underscores but include apostrophes # [^A-Za-z0-9\'] used with above hack to prevent spellcheck while typing word @@ -197,8 +198,27 @@ def checkText(self, text): for word_object in re.finditer(WORDS, text): word = word_object.group(1) + mispelled = self.isMisspelled(word) + if mispelled == False: + continue + #inorder to prevent apostrophes causing false positives and keep the same functionality otherwise, + #check that the word doesn't have any additional punctuation on it. + if re.match("^[^\w]|([\p{P}'])$", word): + + # ^[^\w] checks that it doesn't start with a word character + # ([\p{P}'])$ checks it doesn't end with punctuation characters + + apostrophe_WORDS = r'(?iu)\b(?<=[\s\'"(])((?:[a-zA-Z]|\')+)(?=\b)' + + # \b(?<=[\s\'"(]) looks for nonword characters and starts grouping after + # (?=\b) looks for the word boundary + # ((?:[a-zA-Z]|\')+) greedily matches for letters and apostrophes + + temp = re.match(apostrophe_WORDS, word) + mispelled = self.isMisspelled(temp.group(1)) + + if (mispelled and not self.isCustomWord(word)): - if (self.isMisspelled(word) and not self.isCustomWord(word)): matches.append(BasicMatch( word_object.start(1), word_object.end(1) )) From 7d3162897737a4c0010a465f704362d35b15d383 Mon Sep 17 00:00:00 2001 From: Shadow Date: Mon, 18 Sep 2023 14:11:30 -0700 Subject: [PATCH 2/3] Resolved critical error that crashes textColor isn't always set to a value and whenever it was used as an empty variable the program would crash. I'm uncertain as to whether or not this solution is appropriate, but this is one way to handle it and maintain functionality. Another would be setting textColor to a default value, but this default would have to depend on the theme set by the user. --- manuskript/ui/views/corkDelegate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manuskript/ui/views/corkDelegate.py b/manuskript/ui/views/corkDelegate.py index fc63c28e..99850e79 100644 --- a/manuskript/ui/views/corkDelegate.py +++ b/manuskript/ui/views/corkDelegate.py @@ -384,7 +384,7 @@ def drawRect(r): # Draw Summary # One line - if lineSummary: + if lineSummary and textColor: p.save() f = QFont(option.font) f.setBold(True) @@ -396,7 +396,7 @@ def drawRect(r): p.restore() # Full summary - if fullSummary: + if fullSummary and textColor: p.save() p.setFont(option.font) p.setPen(textColor) From 161290686b4e81f4c89ee3064ef5ec84db87ee51 Mon Sep 17 00:00:00 2001 From: Shadow Date: Mon, 18 Sep 2023 14:28:30 -0700 Subject: [PATCH 3/3] Update corkDelegate.py --- manuskript/ui/views/corkDelegate.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/manuskript/ui/views/corkDelegate.py b/manuskript/ui/views/corkDelegate.py index 99850e79..e6c7aa5d 100644 --- a/manuskript/ui/views/corkDelegate.py +++ b/manuskript/ui/views/corkDelegate.py @@ -384,6 +384,11 @@ def drawRect(r): # Draw Summary # One line + #checking that textColor is actually defined before we use it + try: + textColor + except: + textColor = None if lineSummary and textColor: p.save() f = QFont(option.font)