Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

RecursionError on deeply nested HTML (about 330 levels), separate from the cyclic-tree case in #256

未关闭
#276 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

@HardMax71 已经在做这个了。

开始于 2026年9月3日。

  • #277 来自 @HardMax71 —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
python
领域
tooling

调研方向

从 markdownify/init.py 中 process_element 和 process_tag 附近的第 228-232、234 以及 287-288 行开始,然后运行 issue 中 330 层嵌套的复现程序。将深度失败与 #256/#274 中对循环树的处理进行比较。完成标准是:深度嵌套的非循环 HTML 不再引发 RecursionError,同时现有的循环案例仍得到覆盖。

由索引模型根据 Issue 内容生成。

描述

process_element / process_tag recurse three Python frames per nesting level (markdownify/__init__.py 228-232, 234, 287-288 on develop), so a plain acyclic tree hits the default recursion limit at around 330 levels. Real mail clients produce this: Outlook wraps quoted replies in empty <div>s and a long thread easily passes that depth.

deep div nesting depth=300: OK len=5
deep div nesting depth=330: RecursionError (maximum recursion depth exceeded)
deep div nesting depth=500: RecursionError (maximum recursion depth exceeded)
cyclic soup (p contains its ancestor div): RecursionError (maximum recursion depth exceeded)

Repro on 1.2.3: https://gist.github.com/HardMax71/bbfc6f70bab3ec6417d4f80324f40387. The one-liner is markdownify("<div>" * 330 + "x" + "</div>" * 330).

I applied the hunk from #274 to 1.2.3 to check: the cyclic case passes, the depth case still fails. So #256/#274 cover cycles and this needs its own guard. Cheapest fix: thread a depth counter through process_tag and past a max_depth option fall back to node.get_text(); a full fix walks node.descendants without recursion.

主要语言
Python
星标
2.3k
派生
216
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

matthewwithanm/python-markdownify 的其他 Issue

查看 matthewwithanm/python-markdownify 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。