From ff8a2c90fa9681fea0be937dbd2c897d1240d144 Mon Sep 17 00:00:00 2001 From: Nigel Date: Wed, 29 Jan 2025 17:27:39 +0000 Subject: [PATCH] Report curly quotes preceded by punctuation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Example: `based on nature.“[A]` Fixes #704 --- src/guiguts/misc_tools.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/guiguts/misc_tools.py b/src/guiguts/misc_tools.py index abe0ebda..2b4d7306 100644 --- a/src/guiguts/misc_tools.py +++ b/src/guiguts/misc_tools.py @@ -1910,6 +1910,7 @@ def populate(self) -> None: search_start = maintext().start() search_end = maintext().index(tk.END) last_open_double_idx = "" + punctuation = ".,;:!?" while match := maintext().find_match( rf"^$|[{DQUOTES}{SQUOTES}\"']", IndexRange(search_start, search_end), @@ -1950,6 +1951,8 @@ def add_quote_entry(prefix: str) -> None: add_quote_entry("DOUBLE OPEN QUOTE FOLLOWED BY SPACE: ") elif context[0].isalnum(): add_quote_entry("DOUBLE OPEN QUOTE PRECEDED BY WORD CHARACTER: ") + elif context[0] in punctuation: + add_quote_entry("DOUBLE OPEN QUOTE PRECEDED BY PUNCTUATION: ") dqtype = 1 last_open_double_idx = match.rowcol.index() elif match_text == DQUOTES[1]: # Close double @@ -1985,6 +1988,8 @@ def add_quote_entry(prefix: str) -> None: add_quote_entry("SINGLE OPEN QUOTE FOLLOWED BY SPACE: ") elif context[0].isalnum(): add_quote_entry("SINGLE OPEN QUOTE PRECEDED BY WORD CHARACTER: ") + elif context[0] in punctuation: + add_quote_entry("SINGLE OPEN QUOTE PRECEDED BY PUNCTUATION: ") elif match_text == SQUOTES[1]: # Close single pass # Close singles/apostrophes can go almost anywhere elif match_text == '"': # Straight double