Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssertionError: assert re.match(r'^<(?:ul|ol).*?>', cuddled_list) when two list items are on the same line #577

Open
edufresne opened this issue May 1, 2024 · 2 comments · May be fixed by #578
Labels

Comments

@edufresne
Copy link

Describe the bug
The cuddled list extra seems to crash with the following error:

Traceback (most recent call last):
  File "/.venv/lib/python3.11/site-packages/markdown2.py", line 411, in convert
    text = self._run_block_gamut(text)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.venv/lib/python3.11/site-packages/markdown2.py", line 1172, in _run_block_gamut
    text = self._form_paragraphs(text)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.venv/lib/python3.11/site-packages/markdown2.py", line 2570, in _form_paragraphs
    assert re.match(r'^<(?:ul|ol).*?>', cuddled_list)
AssertionError

when passed text to convert that has two list items on the same line.

To Reproduce

markdown_input = '- - Test'
markdowner = markdown2.Markdown(
        tab_width=2, extras=["tables", "break-on-newline", "fenced-code-blocks", "strike", "cuddled-lists"]
    )
markdowner.convert(markdown_input)

Expected behavior
That this would not raise an assertion error and would parse out to someting like:

<ul>
   <li>
       <ul>
          <li>Test</li>
      </ul>
   </li>
</ul>

Debug info
Latest: 2.4.13

Any extras being used:
"tables", "break-on-newline", "fenced-code-blocks", "strike", "cuddled-lists"

Additional context

@edufresne
Copy link
Author

Potential duplicate of: #297

@edufresne
Copy link
Author

Also, looking at the test suite, the not_quite_a_list test case should catch this but looks to be passing as the most recent build: https://github.com/trentm/python-markdown2/actions/runs/8789672182/job/24119927692. Taking the input .txt file from that test case and running against it locally also reproduces the assertion error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants