From 5f4370f9539a1e55d1fffeab3894b3076b9ee9f5 Mon Sep 17 00:00:00 2001 From: Mattia Succurro Date: Sun, 12 Mar 2023 10:03:01 +0100 Subject: [PATCH] =?UTF-8?q?Extensions=20don=E2=80=99t=20work=20anymore=20o?= =?UTF-8?q?n=20Python=203.10=20(Markdown=203.4.1),=20adding=20a=20way=20to?= =?UTF-8?q?=20disable=20them.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 ++ app.py | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17b4aa3..78205c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 0.7 ++ XXX Custom Markdown extensions are broken with Markdown 3.4.1. While we find a workaround to it, + use the config `[markdown]disable_custom_extensions` set to 1. + Schema changes: + Removed `PagePolicy` and `PagePolicyKey` tables altogether. They were never useful. + Added `calendar` field to `Page`. diff --git a/app.py b/app.py index 9460d11..7d41b12 100644 --- a/app.py +++ b/app.py @@ -95,7 +95,7 @@ def _makelist(l): #### MARKDOWN EXTENSIONS #### class StrikethroughExtension(markdown.extensions.Extension): - def extendMarkdown(self, md, md_globals): + def extendMarkdown(self, md, md_globals=None): postprocessor = StrikethroughPostprocessor(md) md.postprocessors.add('strikethrough', postprocessor, '>raw_html') @@ -114,7 +114,7 @@ BlockQuoteProcessor.RE = re.compile(r'(^|\n)[ ]{0,3}>(?!!)[ ]?(.*)') ### XXX it currently only detects spoilers that are not at the beginning of the line. To be fixed. class SpoilerExtension(markdown.extensions.Extension): - def extendMarkdown(self, md, md_globals): + def extendMarkdown(self, md, md_globals=None): md.inlinePatterns.register(markdown.inlinepatterns.SimpleTagInlineProcessor(r'()>!(.*?)!<', 'span class="spoiler"'), 'spoiler', 14) @@ -390,8 +390,11 @@ def md(text, expand_magic=False, toc=True, math=True): if expand_magic: # DEPRECATED seeking for a better solution. warnings.warn('Magic words are no more supported.', DeprecationWarning) - extensions = ['tables', 'footnotes', 'fenced_code', 'sane_lists', StrikethroughExtension(), SpoilerExtension()] + extensions = ['tables', 'footnotes', 'fenced_code', 'sane_lists'] extension_configs = {} + if not _getconf('markdown', 'disable_custom_extensions'): + extensions.append(StrikethroughExtension()) + extensions.append(SpoilerExtension()) if toc: extensions.append('toc') if math and markdown_katex and ('$`' in text or '```math' in text):