From d41fc8a1157e001343649c23b23117a2afce0be5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 11 Sep 2017 17:14:00 +0200 Subject: [PATCH] m.htmlsanity: patch for difference between docutils 0.13 and 0.14. With the default being for 0.14 (forward-compatible). --- pelican-plugins/m/htmlsanity.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pelican-plugins/m/htmlsanity.py b/pelican-plugins/m/htmlsanity.py index 172df564..18172d58 100644 --- a/pelican-plugins/m/htmlsanity.py +++ b/pelican-plugins/m/htmlsanity.py @@ -163,6 +163,14 @@ class SaneHtmlTranslator(HTMLTranslator): ord('@'): '@', # may thwart address harvesters ord('\u00AD'): '­'} + def __init__(self, document): + HTMLTranslator.__init__(self, document) + + # There's a minor difference between docutils 0.13 and 0.14 that breaks + # stuff. Monkey-patch it here. + if not hasattr(self, 'in_word_wrap_point'): + self.in_word_wrap_point = HTMLTranslator.sollbruchstelle + # Somehow this does the trick and removes docinfo from the body. Was # present in the HTML4 translator but not in the HTML5 one, so copying it # verbatim over @@ -211,7 +219,7 @@ class SaneHtmlTranslator(HTMLTranslator): # Protect text like ``--an-option`` and the regular expression # ``[+]?(\d+(\.\d*)?|\.\d+)`` from bad line wrapping for token in self.words_and_spaces.findall(text): - if token.strip() and self.sollbruchstelle.search(token): + if token.strip() and self.in_word_wrap_point.search(token): self.body.append('%s' % self.encode(token)) else: -- 2.30.2