spanezz / staticsite

Static site generator
GNU General Public License v3.0
47 stars 7 forks source link

Support Python Markdown Extension API 3.4 #58

Closed DonKult closed 2 years ago

DonKult commented 2 years ago

Hi,

the API was changed in 3.0 already, but with 3.4 the old APIs (and deprecation warnings I at least haven't seen) were removed.

References:

This diff seems to work for me, but as I have no idea what a good int value for priority should be (as _end is not accepted) I am just dropping this here – also, no idea how backward compatible that API is and/or if that is a concern.

diff --git a/staticsite/features/markdown.py b/staticsite/features/markdown.py
--- a/staticsite/features/markdown.py
+++ b/staticsite/features/markdown.py
@@ -120,10 +120,10 @@ class LinkResolver(markdown.treeprocessors.Treeprocessor):

 class StaticSiteExtension(markdown.extensions.Extension):
-    def extendMarkdown(self, md, md_globals):
+    def extendMarkdown(self, md):
         self.link_resolver = LinkResolver(md)
         # Insert instance of 'mypattern' before 'references' pattern
-        md.treeprocessors.add('staticsite', self.link_resolver, '_end')
+        md.treeprocessors.register(self.link_resolver, 'staticsite', 50)
         md.registerExtension(self)

     def reset(self):