bugdown: Fix fenced_code for Python-Markdown 2.3

(imported from commit 3954444708e222217407df228f07d2cad402a02b)
This commit is contained in:
Keegan McAllister 2013-04-04 17:14:33 -04:00
parent 64b0106e47
commit 3c40dd3bf3
1 changed files with 7 additions and 1 deletions

View File

@ -82,9 +82,15 @@ class FencedCodeExtension(markdown.Extension):
""" Add FencedBlockPreprocessor to the Markdown instance. """
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',
FencedBlockPreprocessor(md),
"_begin")
position)
class FencedBlockPreprocessor(markdown.preprocessors.Preprocessor):