From: Vladimír Vondruš Date: Tue, 6 Apr 2021 15:28:45 +0000 (+0200) Subject: m.htmlsanity: drop Flash-related code and fix compat with docutils 0.17. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=f9ec8ea832313d37789ed078f5def98908b4be08;p=blog.git m.htmlsanity: drop Flash-related code and fix compat with docutils 0.17. That thing is DEAD so there's no reason to bother. This changed in docutils 0.17, making the current version fail there. Funnily enough, https://github.com/live-clones/docutils/commit/659c3f1e46f0c86609936c987b7e2a7a6ef89cb2 looks like they still seem to preserve that somehow. I won't, so all the related code isn't needed. The code here was originally taken from docutils but diverged significantly and given that they still use the deprecated width/height attribute I see no reason to even attempt cherry-picking their changes. --- diff --git a/plugins/m/htmlsanity.py b/plugins/m/htmlsanity.py index 987c56ca..7c77adf2 100644 --- a/plugins/m/htmlsanity.py +++ b/plugins/m/htmlsanity.py @@ -292,12 +292,8 @@ class SaneHtmlTranslator(HTMLTranslator): atts = {} uri = node['uri'] ext = os.path.splitext(uri)[1].lower() - if ext in self.object_image_types: - atts['data'] = uri - atts['type'] = self.object_image_types[ext] - else: - atts['src'] = uri - if 'alt' in node: atts['alt'] = node['alt'] + atts['src'] = uri + if 'alt' in node: atts['alt'] = node['alt'] style = [] if node.get('width'): style += ['width: {}'.format(node['width'])] @@ -312,12 +308,7 @@ class SaneHtmlTranslator(HTMLTranslator): suffix = '' else: suffix = '\n' - if ext in self.object_image_types: - # do NOT use an empty tag: incorrect rendering in browsers - self.body.append(self.starttag(node, 'object', suffix, **atts) + - node.get('alt', uri) + '' + suffix) - else: - self.body.append(self.emptytag(node, 'img', suffix, **atts)) + self.body.append(self.emptytag(node, 'img', suffix, **atts)) def depart_image(self, node): pass