chiark / gitweb /
m.htmlsanity: adapt to changes in docutils 0.18+.
authorVladimír Vondruš <mosra@centrum.cz>
Tue, 4 Jan 2022 15:08:15 +0000 (16:08 +0100)
committerVladimír Vondruš <mosra@centrum.cz>
Tue, 4 Jan 2022 15:10:39 +0000 (16:10 +0100)
And explicitly test for 0.14, 0,17.1 and 0.18.0 on the CI.

package/ci/circleci.yml
plugins/m/htmlsanity.py
plugins/m/test/__init__.py

index 26d299421544cab13783ae4e90548ce11a1d38cb..9b3f86dee2fed84151f239c5086ca37f8705b48b 100644 (file)
@@ -48,6 +48,9 @@ commands:
       attrs-version:
         type: string
         default: ""
+      docutils-version:
+        type: string
+        default: ""
       matplotlib-version:
         type: string
         default: ""
@@ -59,10 +62,8 @@ commands:
         name: Install Python dependencies
         # Pygments 2.11 (and apparently 2.10 as well) treats certain whitespace
         # differently, I have to update the expected output first.
-        # Docutils 0.18 drops some attribute that htmlsanity relies on, I need
-        # to update the code first.
         command: |
-          pip install jinja2 docutils==0.17.1 pygments==2.9.0 pelican<< parameters.pelican-version >> Pyphen Pillow coverage codecov qrcode matplotlib<< parameters.matplotlib-version >> attrs<< parameters.attrs-version >>
+          pip install jinja2 docutils<< parameters.docutils-version >> pygments==2.9.0 pelican<< parameters.pelican-version >> Pyphen Pillow coverage codecov qrcode matplotlib<< parameters.matplotlib-version >> attrs<< parameters.attrs-version >>
     - run:
         name: Fix unheard-of cursed issues
         # otherwise i get Error: unsupported locale setting
@@ -188,6 +189,8 @@ jobs:
         attrs-version: ==19.3.0
         matplotlib-version: ==3.3.4
         pelican-version: ==4.2.0
+        # Ubuntu 18.04 has docutils 0.14
+        docutils-version: ==0.14
     - checkout
     - test-theme
     - test-plugins
@@ -207,6 +210,8 @@ jobs:
         # Matplotlib 3.5 has significantly different output, be sure to have
         # at least one job testing 3.4 so we don't regress
         matplotlib-version: ==3.4.3
+        # Docutils 0.17 dropped `object_image_types`, test that it works there
+        docutils-version: ==0.17.1
     - checkout
     - test-theme
     - test-plugins
@@ -220,7 +225,10 @@ jobs:
     steps:
     - install-base:
         extra: graphviz cmake ninja-build wget
-    - install-python-deps
+    - install-python-deps:
+        # Docutils 0.18.0 dropped `in_footnote_list` and made some changes that
+        # 0.18.1 reverted again, test we're not affected by those
+        docutils-version: ==0.18.0
     - checkout
     - test-theme
     - test-plugins
index 9fbc6b3eea4972a3d2106ec58213794539169c6d..049cbc723d437689cb3c592592dc9fe424b48de2 100644 (file)
@@ -468,16 +468,15 @@ class SaneHtmlTranslator(HTMLTranslator):
 
     # Footnote list. Replacing the classes with just .m-footnote.
     def visit_footnote(self, node):
-        if not self.in_footnote_list:
+        previous_node = node.parent[node.parent.index(node)-1]
+        if not isinstance(previous_node, type(node)):
             self.body.append('<dl class="m-footnote">\n')
-            self.in_footnote_list = True
 
     def depart_footnote(self, node):
         self.body.append('</dd>\n')
         if not isinstance(node.next_node(descend=False, siblings=True),
-                          nodes.footnote):
+                          type(node)):
             self.body.append('</dl>\n')
-            self.in_footnote_list = False
 
     # Footnote reference
     def visit_footnote_reference(self, node):
index b638fbf029cbc2f1a571cb60676c457119a27322..d923a2f7cdc3b7c92f638f7089a84384b361ea73 100644 (file)
@@ -69,7 +69,14 @@ class PelicanPluginTestCase(unittest.TestCase):
             'M_FINE_PRINT': None,
             'M_DISABLE_SOCIAL_META_TAGS': True,
             'DIRECT_TEMPLATES': [],
-            'SLUGIFY_SOURCE': 'basename'
+            'SLUGIFY_SOURCE': 'basename',
+
+            'DOCUTILS_SETTINGS': {
+                # Default changed to '%' in 0.18, keep the old setting to
+                # have consistent output across versions
+                # TODO maybe change this to '%' everywhere instead?
+                'auto_id_prefix': 'id'
+            }
         }
         implicit_settings.update(settings)
         settings = read_settings(path=None, override=implicit_settings)