From 80e90b5ddc3b60f0a1de7074691c2247c448dd73 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Sat, 19 Aug 2023 21:36:13 -0400 Subject: [PATCH] Skip comments in word count. --- manuskript/functions/__init__.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/manuskript/functions/__init__.py b/manuskript/functions/__init__.py index eb96253..e5a0e6c 100644 --- a/manuskript/functions/__init__.py +++ b/manuskript/functions/__init__.py @@ -30,7 +30,19 @@ def safeTranslate(qApp, group, text): return text def wordCount(text): - return len(re.findall(r"\S+", text)) + words = re.findall(r"\S+", text) + count = 0 + in_comment = False + for word in words: + if in_comment: + if word == '-->': + in_comment = False + else: + if word == '