lepture/mistune

3.0a1: breaks `markdown-code-blocks`

asottile opened this issue · 2 comments

hi! thanks again for the project! I just noticed markdown-code-blocks breaks with 3.0a1 -- looks like double-escaping. I'm going to exclude 3.x right now to fix the breakage

example failure:

$ git rev-parse HEAD
1241638124ff838fc90b38816c325206550e6d9c
$ tox --devenv venv >& /dev/null
$ ./venv/bin/pip install mistune --upgrade --pre
Requirement already satisfied: mistune in ./venv/lib/python3.8/site-packages (2.0.3)
Collecting mistune
  Using cached mistune-3.0.0a1-py2.py3-none-any.whl (33 kB)
Installing collected packages: mistune
  Attempting uninstall: mistune
    Found existing installation: mistune 2.0.3
    Uninstalling mistune-2.0.3:
      Successfully uninstalled mistune-2.0.3
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
markdown-code-blocks 3.1.0 requires mistune<3,>=2, but you have mistune 3.0.0a1 which is incompatible.
Successfully installed mistune-3.0.0a1
$ ./venv/bin/pytest tests
============================= test session starts ==============================
platform linux -- Python 3.8.10, pytest-7.1.2, pluggy-1.0.0
rootdir: /tmp/markdown-code-blocks
collected 6 items                                                              

tests/markdown_code_blocks_test.py .FF...                                [100%]

=================================== FAILURES ===================================
____________________________ test_highlight_python _____________________________

    def test_highlight_python():
        ret = highlight(
            '```python\n'
            'print("hello world")\n'
            '```\n',
        )
>       assert ret == (
            '<div class="highlight python"><pre>'
            '<span></span>'
            '<span class="nb">print</span>'
            '<span class="p">(</span>'
            '<span class="s2">&quot;hello world&quot;</span>'
            '<span class="p">)</span>\n'
            '</pre></div>\n'
        )
E       assert '<div class=".../pre></div>\n' == '<div class=".../pre></div>\n'
E         Skipping 38 identical leading characters in diff, use -v to show
E         - an></span><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;hello world&quot;</span><span class="p">)</span>
E         + an></span>
E         + <span class="nb">print</span><span class="p">(</span><span class="o">&amp;</span><span class="n">quot</span><span class="p">;</span><span class="n">hello</span> <span class="n">world</span><span class="o">&amp;</span><span class="n">quot</span><span class="p">;)</span>
E           </pre></div>

tests/markdown_code_blocks_test.py:19: AssertionError
__________________________ test_highlight_plain_text ___________________________

    def test_highlight_plain_text():
        ret = highlight(
            '```\n'
            'this is plain text, such class.\n'
            '```\n',
        )
>       assert ret == (
            '<div class="highlight"><pre>'
            '<span></span>'
            'this is plain text, such class.\n'
            '</pre></div>\n'
        )
E       assert '<div class=".../pre></div>\n' == '<div class=".../pre></div>\n'
E         - <div class="highlight"><pre><span></span>this is plain text, such class.
E         + <div class="highlight"><pre><span></span>
E         + this is plain text, such class.
E           </pre></div>

tests/markdown_code_blocks_test.py:36: AssertionError
=========================== short test summary info ============================
FAILED tests/markdown_code_blocks_test.py::test_highlight_python - assert '<d...
FAILED tests/markdown_code_blocks_test.py::test_highlight_plain_text - assert...
========================= 2 failed, 4 passed in 0.15s ==========================

is this change expected? how should I adjust my usage of mistune?

@asottile 3.0.0a2 should fix the issue.

@lepture awesome -- thank you for the quick fix!