mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 17:07:07 +00:00
bugdown: Fix fenced_code for Python-Markdown 2.3
(imported from commit 3954444708e222217407df228f07d2cad402a02b)
This commit is contained in:
@@ -82,9 +82,15 @@ class FencedCodeExtension(markdown.Extension):
|
|||||||
""" Add FencedBlockPreprocessor to the Markdown instance. """
|
""" Add FencedBlockPreprocessor to the Markdown instance. """
|
||||||
md.registerExtension(self)
|
md.registerExtension(self)
|
||||||
|
|
||||||
|
# Newer versions of Python-Markdown (starting at 2.3?) have
|
||||||
|
# a normalize_whitespace preprocessor that needs to go first.
|
||||||
|
position = ('>normalize_whitespace'
|
||||||
|
if 'normalize_whitespace' in md.preprocessors
|
||||||
|
else '_begin')
|
||||||
|
|
||||||
md.preprocessors.add('fenced_code_block',
|
md.preprocessors.add('fenced_code_block',
|
||||||
FencedBlockPreprocessor(md),
|
FencedBlockPreprocessor(md),
|
||||||
"_begin")
|
position)
|
||||||
|
|
||||||
|
|
||||||
class FencedBlockPreprocessor(markdown.preprocessors.Preprocessor):
|
class FencedBlockPreprocessor(markdown.preprocessors.Preprocessor):
|
||||||
|
|||||||
Reference in New Issue
Block a user