markdown: Migrate off deprecated extension registration interface.

Fixes #15205.

https://python-markdown.github.io/change_log/release-3.0/#homegrown-ordereddict-has-been-replaced-with-a-purpose-built-registry
https://python-markdown.github.io/change_log/release-3.0/#md_globals-keyword-deprecated-from-extension-api

The priority numbers are arbitrarily chosen to preserve the existing
order.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2020-10-19 16:28:13 -07:00
committed by Anders Kaseorg
parent 84142df152
commit 254b904965
10 changed files with 34 additions and 33 deletions

View File

@@ -8,11 +8,11 @@ from zerver.lib.markdown import ResultWithFamily, walk_tree_with_family
class NestedCodeBlocksRenderer(Extension):
def extendMarkdown(self, md: markdown.Markdown, md_globals: Dict[str, Any]) -> None:
md.treeprocessors.add(
'nested_code_blocks',
def extendMarkdown(self, md: markdown.Markdown) -> None:
md.treeprocessors.register(
NestedCodeBlocksRendererTreeProcessor(md, self.getConfigs()),
'_end',
'nested_code_blocks',
-500,
)
class NestedCodeBlocksRendererTreeProcessor(markdown.treeprocessors.Treeprocessor):