mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-17 11:22:28 +12:00
Skip comments in word count.
This commit is contained in:
parent
6ee7e881be
commit
80e90b5ddc
|
@ -30,7 +30,19 @@ def safeTranslate(qApp, group, text):
|
||||||
return text
|
return text
|
||||||
|
|
||||||
def wordCount(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 == '<!--':
|
||||||
|
in_comment = True
|
||||||
|
else:
|
||||||
|
count += 1
|
||||||
|
return count
|
||||||
|
|
||||||
|
|
||||||
def charCount(text, use_spaces = True):
|
def charCount(text, use_spaces = True):
|
||||||
|
|
Loading…
Reference in a new issue