Extensions don’t work anymore on Python 3.10 (Markdown 3.4.1), adding a way to disable them.
This commit is contained in:
parent
6f53cd3836
commit
5f4370f953
2 changed files with 8 additions and 3 deletions
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
## 0.7
|
## 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:
|
+ Schema changes:
|
||||||
+ Removed `PagePolicy` and `PagePolicyKey` tables altogether. They were never useful.
|
+ Removed `PagePolicy` and `PagePolicyKey` tables altogether. They were never useful.
|
||||||
+ Added `calendar` field to `Page`.
|
+ Added `calendar` field to `Page`.
|
||||||
|
|
|
||||||
9
app.py
9
app.py
|
|
@ -95,7 +95,7 @@ def _makelist(l):
|
||||||
#### MARKDOWN EXTENSIONS ####
|
#### MARKDOWN EXTENSIONS ####
|
||||||
|
|
||||||
class StrikethroughExtension(markdown.extensions.Extension):
|
class StrikethroughExtension(markdown.extensions.Extension):
|
||||||
def extendMarkdown(self, md, md_globals):
|
def extendMarkdown(self, md, md_globals=None):
|
||||||
postprocessor = StrikethroughPostprocessor(md)
|
postprocessor = StrikethroughPostprocessor(md)
|
||||||
md.postprocessors.add('strikethrough', postprocessor, '>raw_html')
|
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.
|
### XXX it currently only detects spoilers that are not at the beginning of the line. To be fixed.
|
||||||
class SpoilerExtension(markdown.extensions.Extension):
|
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)
|
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:
|
if expand_magic:
|
||||||
# DEPRECATED seeking for a better solution.
|
# DEPRECATED seeking for a better solution.
|
||||||
warnings.warn('Magic words are no more supported.', DeprecationWarning)
|
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 = {}
|
extension_configs = {}
|
||||||
|
if not _getconf('markdown', 'disable_custom_extensions'):
|
||||||
|
extensions.append(StrikethroughExtension())
|
||||||
|
extensions.append(SpoilerExtension())
|
||||||
if toc:
|
if toc:
|
||||||
extensions.append('toc')
|
extensions.append('toc')
|
||||||
if math and markdown_katex and ('$`' in text or '```math' in text):
|
if math and markdown_katex and ('$`' in text or '```math' in text):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue