chiark / gitweb /
m.htmlsanity: drop Flash-related code and fix compat with docutils 0.17.
authorVladimír Vondruš <mosra@centrum.cz>
Tue, 6 Apr 2021 15:28:45 +0000 (17:28 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Tue, 6 Apr 2021 15:28:45 +0000 (17:28 +0200)
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.

plugins/m/htmlsanity.py

index 987c56ca93ea73bfd09c2d2a3b0be6acecb85c60..7c77adf2c94d8e6833b97bd78fbd8330dc971243 100644 (file)
@@ -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) + '</object>' + 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