commit 1d542f3cfb7e2afa3f6c8aa2445bdcb024507300
parent fd1fdb7995891c4bbaff8e83808915a73a9d7e41
Author: Antoine Amarilli <a3nm@a3nm.net>
Date: Mon, 22 Jan 2018 22:27:17 +0100
fix crash on lone dashes
Diffstat:
2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/common.py b/common.py
@@ -54,6 +54,7 @@ def rm_punct(text, rm_all=False, rm_apostrophe=False, rm_apostrophe_end=True):
text = re.sub("[‒–—―⁓⸺⸻]", " ", text) # no weird dashes
text = re.sub("^--*\s", " ", text) # no isolated dashes
text = re.sub("--*\s", " ", text) # no trailing dashes
+ text = re.sub("^\s*-\s*$", " ", text) # no lone dash
#TODO rather: keep only good chars
if not rm_all:
diff --git a/versetest.py b/versetest.py
@@ -295,6 +295,12 @@ class SanityCheck2(unittest.TestCase):
self.assertEqual(1, len(gend))
self.assertEqual('F', next(iter(gend)))
+class TemplateTest(unittest.TestCase):
+ def testSingleHyphens(self):
+ t = template.Template("12")
+ text = "-"
+ t.check(text)
+
if __name__ == "__main__":
diaeresis.load_diaeresis('diaeresis.json')
unittest.main()