IpynbConverter uses a comment inside a Markdown code fence as the notebook title

未关闭 适合新手
#2,964 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@Primaverah 已经在做这个了。

开始于 2026年12月4日。

  • #2965 来自 @Primaverah —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
77/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
jupyter, markdown, python
领域
backend, data

调研方向

找到提取笔记本标题的 IpynbConverter 代码,然后阅读它如何处理行列表形式的 Markdown 源和 metadata.title。使用提供的笔记本复现问题,并检查现有转换器测试中关于标题提取的部分。完成标准是:即使前面有围栏代码块注释,第一个实际标题仍作为标题,同时 Markdown 正文和显式的 metadata.title 覆盖行为保持不变。

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

描述

What happened

A valid Jupyter Markdown cell with a fenced code example before its first real heading can get the wrong DocumentConverterResult.title. The Markdown body is preserved.

Minimal reproduction

Tested with MarkItDown 0.1.10 at 06dd724d5ea980f03a25de87a02f5d25c68addd3, Python 3.12.16 on Linux. The notebook is not executed.

import io, json
from markitdown import MarkItDown, StreamInfo
nb = {"nbformat": 4, "nbformat_minor": 5, "metadata": {}, "cells": [{
    "cell_type": "markdown", "id": "example", "metadata": {},
    "source": ["```python\n", "# setup comment\n", "```\n", "# Notebook title\n"],
}]}
result = MarkItDown().convert_stream(io.BytesIO(json.dumps(nb).encode("utf-8")),
                                    stream_info=StreamInfo(extension=".ipynb"))
print(repr(result.title))
  • Actual: 'setup comment'
  • Expected: 'Notebook title'
  • Control: Remove the fenced example and the current line-list path finds the correct title.

Title extraction should skip fenced code without changing the Markdown body or the explicit metadata.title override. #2762 covers string-valued source; this example uses the line-list form. #2920 concerns fences generated for code/raw cells, not fences already present in Markdown cells.

主要语言
Python
星标
198k
派生
15k
平均合并
2 小时 16 分钟
30 天内合并 PR
9

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 没有贡献指南

从这里开始

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

microsoft/markitdown 的其他 Issue

查看 microsoft/markitdown 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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