`AssertionError` when parsing a page with raw HTML
还没有人认领这个 Issue。
评估
调研方向
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 小时
- 30 天内合并 PR
- 8
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
trentm/python-markdown2 的其他 Issue
-
Bug
难度 2/5 1-3 小时 新手友好度 72/100
trentm/python-markdown2#733 · 1 条评论 ·
-
Add py.typed marker可能已有人在做 @mac-agent 于 197 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
trentm/python-markdown2#696 ·
-
难度 4/5 3-5 天 新手友好度 48/100
trentm/python-markdown2#726 ·
-
markdown2 malformed HTML tokenizer CPU denial of service可能已有人在做 @wolfgang-aura 于 5 天前认领。 未关闭Bug
难度 4/5 3-5 天 新手友好度 55/100
trentm/python-markdown2#707 ·
-
Bug
难度 3/5 1-2 天 新手友好度 58/100
trentm/python-markdown2#688 · 4 条评论 ·
查看 trentm/python-markdown2 的全部 Issue
相似的 Issue
-
难度 1/5 1-3 小时 新手友好度 87/100
adri0/scadustats#128 ·
维护者通常 1 天内回复
-
`TIMESTAMP`, `TIMESTAMP_NTZ`, `TINYINT` and the other `TypeDecorator`s don't declare `python_type`未关闭
难度 2/5 1-3 小时 新手友好度 78/100
-
RPBC未关闭awaiting policy acceptance precheck-passed
难度 1/5 1 小时以内 新手友好度 78/100
Bioconductor/BiocContributions#240 · 1 条评论 ·
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
documentation good first issue launch
难度 2/5 1-3 小时 新手友好度 83/100
FlologixAI/etchwork#4 ·