Skip to content

Commit 7c2a823

Browse files
committed
Fix deprecation warnings with Python-Markdown 3.x
Fixes #21.
1 parent cfd83b0 commit 7c2a823

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

mdx_math.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def _get_content_type(self):
3131
return 'math/asciimath'
3232
return 'math/tex'
3333

34-
def extendMarkdown(self, md, md_globals):
34+
def extendMarkdown(self, md):
3535
def _wrap_node(node, preview_text, wrapper_tag):
3636
if not self.getConfig('add_preview'):
3737
return node
@@ -72,10 +72,11 @@ def handle_match(m):
7272
mathpatterns = mathpatterns[:-1] # \begin...\end is TeX only
7373
for i, pattern in enumerate(mathpatterns):
7474
pattern.handleMatch = handle_match
75-
md.inlinePatterns.add('math-%d' % i, pattern, '<escape')
75+
# we should have higher priority than 'escape' which has 180
76+
md.inlinePatterns.register(pattern, 'math-%d' % i, 185)
7677
for i, pattern in enumerate(inlinemathpatterns):
7778
pattern.handleMatch = handle_match_inline
78-
md.inlinePatterns.add('math-inline-%d' % i, pattern, '<escape')
79+
md.inlinePatterns.register(pattern, 'math-inline-%d' % i, 185)
7980
if self.getConfig('enable_dollar_delimiter'):
8081
md.ESCAPED_CHARS.append('$')
8182

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
version='0.6',
1515
url='https://github.com/mitya57/python-markdown-math',
1616
py_modules=['mdx_math'],
17+
install_requires=['Markdown>=3.0'],
1718
entry_points={
1819
'markdown.extensions': [
1920
'mdx_math = mdx_math:MathExtension',

0 commit comments

Comments
 (0)