From: Vladimír Vondruš Date: Mon, 11 Sep 2017 15:14:00 +0000 (+0200) Subject: m.htmlsanity: patch for difference between docutils 0.13 and 0.14. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=d41fc8a1157e001343649c23b23117a2afce0be5;p=blog.git m.htmlsanity: patch for difference between docutils 0.13 and 0.14. With the default being for 0.14 (forward-compatible). --- 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: