From 4ba1dc7704e2199bef5409bcb21357e952a48fc6 Mon Sep 17 00:00:00 2001 From: wo Date: Sun, 25 Sep 2016 05:23:44 +0100 Subject: [PATCH] quick fix for #95 --- opp/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/opp/models.py b/opp/models.py index fbbefb8..5753018 100644 --- a/opp/models.py +++ b/opp/models.py @@ -257,7 +257,10 @@ def html_context(self): if len(el._text) - len(self.element._text) < 5: par._outerHTML = par.get_attribute('outerHTML') el._outerHTML = el.get_attribute('outerHTML') - l,r = par._outerHTML.split(el._outerHTML, 1) + try: + l,r = par._outerHTML.split(el._outerHTML, 1) + except ValueError: # no split, what now? + return el._text if re.search(r'\w\s*$', l) or re.search(r'^\s*\w', r): debug(5, 'argh: case (3)') for pat in (r'', r'
\s*
', r'
'):