plint

French poetry validator (local mirror of https://gitlab.com/a3nm/plint)
git clone https://a3nm.net/git/plint/
Log | Files | Refs | README

commit d04c54c6498c18dcc2e5ffb3ad226e69d4fd4568
parent ef3830806ac06c8f38b9f61d9d4ac1514e6a0e0d
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Mon, 12 Aug 2019 18:33:26 +0200

do not crash on only hyphens

Diffstat:
common.py | 1+
versetest.py | 4++++
2 files changed, 5 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("^--*\s", " ", text) # no isolated dashes text = re.sub("--*\s", " ", text) # no trailing dashes text = re.sub("^\s*-\s*$", " ", text) # no lone dash + text = re.sub("^--*$", "", text) # no only dashes #TODO rather: keep only good chars if not rm_all: diff --git a/versetest.py b/versetest.py @@ -39,6 +39,10 @@ class SanityCheck(unittest.TestCase): v.parse() self.assertEqual(text, v.line) + def testOnlyHyphens(self): + text = "-----" + self.assertEqual(common.normalize(text), "") + def testLoneHyphens(self): text = " - - -- -- - - - --" self.assertEqual(common.normalize(text), "")