From 7c2a82327dc6aabca25cd42bf9cce4f0c237fd80 Mon Sep 17 00:00:00 2001
From: Dmitry Shachnev <mitya57@gmail.com>
Date: Sat, 3 Nov 2018 10:29:43 +0300
Subject: [PATCH] Fix deprecation warnings with Python-Markdown 3.x

Fixes #21.
---
 mdx_math.py | 7 ++++---
 setup.py    | 1 +
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/mdx_math.py b/mdx_math.py
index 342117b..1c1df52 100644
--- a/mdx_math.py
+++ b/mdx_math.py
@@ -31,7 +31,7 @@ def _get_content_type(self):
             return 'math/asciimath'
         return 'math/tex'
 
-    def extendMarkdown(self, md, md_globals):
+    def extendMarkdown(self, md):
         def _wrap_node(node, preview_text, wrapper_tag):
             if not self.getConfig('add_preview'):
                 return node
@@ -72,10 +72,11 @@ def handle_match(m):
             mathpatterns = mathpatterns[:-1]  # \begin...\end is TeX only
         for i, pattern in enumerate(mathpatterns):
             pattern.handleMatch = handle_match
-            md.inlinePatterns.add('math-%d' % i, pattern, '<escape')
+            # we should have higher priority than 'escape' which has 180
+            md.inlinePatterns.register(pattern, 'math-%d' % i, 185)
         for i, pattern in enumerate(inlinemathpatterns):
             pattern.handleMatch = handle_match_inline
-            md.inlinePatterns.add('math-inline-%d' % i, pattern, '<escape')
+            md.inlinePatterns.register(pattern, 'math-inline-%d' % i, 185)
         if self.getConfig('enable_dollar_delimiter'):
             md.ESCAPED_CHARS.append('$')
 
diff --git a/setup.py b/setup.py
index 4e5f2a1..3050f61 100644
--- a/setup.py
+++ b/setup.py
@@ -14,6 +14,7 @@
       version='0.6',
       url='https://github.com/mitya57/python-markdown-math',
       py_modules=['mdx_math'],
+      install_requires=['Markdown>=3.0'],
       entry_points={
           'markdown.extensions': [
               'mdx_math = mdx_math:MathExtension',
