Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

`AssertionError` when parsing a page with raw HTML

オープン
#731 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
半日
初心者へのやさしさ
74/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
compilers

調査の方向性

Start from the traceback in markdown2.py: _hash_html_block_sub (the assert m is not None around line 927) called from _strict_tag_block_sub in _hash_html_blocks. Reproduce by feeding the pasted snippet to markdown() and confirm it fails on 2.5.5 but not 2.5.4; git log/bisect between those tags to find the regression commit. Done when the snippet parses with the HTML emitted unchanged and the existing test suite (e.g. tests/test_markdown2.py) still passes, ideally with a new regression test.

索引モデルが issue の本文から書いたものです。

説明

Describe the bug
AssertionError when parsing a page with raw HTML

  File "/Users/brass75/src/brassnet.biz/.venv/lib/python3.13/site-packages/render_engine_markdown/__init__.py", line 18, in parse
    return markdown(
        content,
        extras=extras.get("markdown_extras", []) if extras else [],
    )
  File "/Users/brass75/src/brassnet.biz/.venv/lib/python3.13/site-packages/markdown2.py", line 210, in markdown
    use_file_vars=use_file_vars, cli=cli).convert(text)
                                          ~~~~~~~^^^^^^
  File "/Users/brass75/src/brassnet.biz/.venv/lib/python3.13/site-packages/markdown2.py", line 504, in convert
    text = self._hash_html_blocks(text, raw=True)
  File "/Users/brass75/src/brassnet.biz/.venv/lib/python3.13/site-packages/markdown2.py", line 255, in inner
    text = func(md, text, *args, **kwargs)
  File "/Users/brass75/src/brassnet.biz/.venv/lib/python3.13/site-packages/markdown2.py", line 991, in _hash_html_blocks
    text = self._strict_tag_block_sub(text, self._block_tags_a, hash_html_block_sub)
  File "/Users/brass75/src/brassnet.biz/.venv/lib/python3.13/site-packages/markdown2.py", line 1120, in _strict_tag_block_sub
    block = callback(block.rstrip('\n'))  # remove trailing newline
  File "/Users/brass75/src/brassnet.biz/.venv/lib/python3.13/site-packages/markdown2.py", line 4417, in result
    return function(*args + rest, **combined)
  File "/Users/brass75/src/brassnet.biz/.venv/lib/python3.13/site-packages/markdown2.py", line 927, in _hash_html_block_sub
    assert m is not None
           ^^^^^^^^^^^^^
AssertionError

To Reproduce

Since you've read this far I can assume that you're planning on attending PyCon US
this year. If you are planning on attending and enjoy baseball you might be interested in
coming with some folks to see either a Dodgers game ahead of the conference or an Angels
game after the first sprint day.

<blockquote class="mastodon-embed" data-embed-url="https://twit.social/@brass75/115486728122010385/embed"
    style="background: #FCF8FF; border-radius: 8px; border: 1px solid #C9C4DA; margin: 0; max-width: 540px;
    min-width: 270px; overflow: hidden; padding: 0;"> <a href="https://twit.social/@brass75/115486728122010385"
        target="_blank" style="align-items: center; color: #1C1A25; display: flex; flex-direction: column;
        font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Oxygen, Ubuntu, Cantarell,
'Fira Sans', 'Droid Sans', 'Helvetica Neue', Roboto, sans-serif; font-size: 14px; justify-content: center;
letter-spacing: 0.25px; line-height: 20px; padding: 24px; text-decoration: none;">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32"
    viewBox="0 0 79 75"><path d="M63 45.3v-20c0-4.1-1-7.3-3.2-9.7-2.1-2.4-5-3.7-8.5-3.7-4.1 0-7.2 1.6-9.3
        4.7l-2 3.3-2-3.3c-2-3.1-5.1-4.7-9.2-4.7-3.5 0-6.4 1.3-8.6 3.7-2.1 2.4-3.1 5.6-3.1 9.7v20h8V25.9c0-4.1
        1.7-6.2 5.2-6.2 3.8 0 5.8 2.5 5.8 7.4V37.7H44V27.1c0-4.9 1.9-7.4 5.8-7.4 3.5 0 5.2 2.1 5.2
        6.2V45.3h8ZM74.7 16.6c.6 6 .1 15.7.1 17.3 0 .5-.1 4.8-.1 5.3-.7 11.5-8 16-15.6 17.5-.1 0-.2 0-.3 0-4.9
        1-10 1.2-14.9 1.4-1.2 0-2.4 0-3.6 0-4.8 0-9.7-.6-14.4-1.7-.1 0-.1 0-.1 0s-.1 0-.1 0 0 .1 0 .1 0 0 0
        0c.1 1.6.4 3.1 1 4.5.6 1.7 2.9 5.7 11.4 5.7 5 0 9.9-.6 14.8-1.7 0 0 0 0 0 0 .1 0 .1 0 .1 0 0 .1 0 .1
        0 .1.1 0 .1 0 .1.1v5.6s0 .1-.1.1c0 0 0 0 0 .1-1.6 1.1-3.7 1.7-5.6 2.3-.8.3-1.6.5-2.4.7-7.5 1.7-15.4
        1.3-22.7-1.2-6.8-2.4-13.8-8.2-15.5-15.2-.9-3.8-1.6-7.6-1.9-11.5-.6-5.8-.6-11.7-.8-17.5C3.9 24.5 4 20
        4.9 16 6.7 7.9 14.1 2.2 22.3 1c1.4-.2 4.1-1 16.5-1h.1C51.4 0 56.7.8 58.1 1c8.4 1.2 15.5 7.5 16.6 15.6Z"
        fill="currentColor"/></svg> <div style="color: #787588; margin-top: 16px;">
            Post by @[email protected]</div> <div style="font-weight: 500;">View on Mastodon</div> </a>
</blockquote> <script data-allowed-prefixes="https://twit.social/" async src="https://twit.social/embed.js"></script>

I hope to see you in Long Beach this May. And I hope you do take the plunge and submit
a talk.

Expected behavior
The included HTML is rendered unchanged.

Debug info
2.5.5 - this does not happen with 2.5.4

Any extras being used:
None.

Additional context

主要言語
Python
スター
2.8k
フォーク
463
平均マージ
2日 9時間
マージ済み PR(30日)
8

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

trentm/python-markdown2 のほかの issue

trentm/python-markdown2 の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。