IpynbConverter: title is never extracted when a markdown cell's source is a single string (valid nbformat form)
メンテナーはふだん 1 日以内に返信
@guptaishaan がすでに取り組んでいます。
2026年10月24日 から。
評価
- 難易度
- 1/5
- 見積もり時間
- 1時間未満
- 初心者へのやさしさ
- 25/100
調査の方向性
Inspect packages/markitdown/src/markitdown/converters/_ipynb_converter.py lines 79-81 where the title loop iterates source_lines. Apply the normalization snippet from the issue so single-string source splits into lines, then verify with the provided Python repro that both notebook forms return the title. A linked PR #2763 already exists for this change.
索引モデルが issue の本文から書いたものです。
説明
Problem
IpynbConverter never extracts a title from a notebook whose markdown cells store source as a single string, even though that's a fully valid representation under the nbformat schema (the Jupyter format spec allows source to be "a single string" or a list of strings — nbformat.validator accepts both). Notebooks written by scripts and many third-party tools use the single-string form.
Repro
from markitdown import MarkItDown
import json
md = MarkItDown()
# source as a list (what Jupyter itself usually writes)
nb_list = {
"nbformat": 4, "nbformat_minor": 5,
"cells": [{"cell_type": "markdown", "source": ["# My Title\n", "hello"]}],
}
# source as a single string (equally valid)
nb_str = {
"nbformat": 4, "nbformat_minor": 5,
"cells": [{"cell_type": "markdown", "source": "# My Title\nhello"}],
}
import tempfile, pathlib
for name, nb in (("list", nb_list), ("string", nb_str)):
p = pathlib.Path(tempfile.mkdtemp()) / "t.ipynb"
p.write_text(json.dumps(nb))
result = md.convert(str(p))
print(name, "->", repr(result.title))
Output:
list -> 'My Title'
string -> None
The body content converts identically in both cases; only the extracted title differs.
Root cause
In packages/markitdown/src/markitdown/converters/_ipynb_converter.py, the title-extraction loop (lines 79-81 of the current main) iterates source_lines assuming it is a list of whole lines:
for line in source_lines:
if line.startswith("# "):
title = line.removeprefix("# ").strip()
break
When source is a single string, for line in source_lines iterates characters, so line.startswith("# ") can never be true and the title is silently lost. The body conversion only keeps working by luck: "".join(source_lines) happens to reconstruct a string source correctly (and it would also misbehave if the string contained multi-line content in the code/raw branches' fence formatting, since no trailing-newline handling exists).
Suggested fix: normalize once, e.g.
source = cell.get("source", [])
source_lines = source if isinstance(source, list) else source.splitlines(keepends=True)
before the loop, so both valid nbformat forms take the same path.
I verified this by running the current main version of IpynbConverter._convert directly against both notebooks above (Python 3.13.5, commit 7482c092d9c0074a89803c9fdb63a969e7fe17fc).
- 主要言語
- Python
- スター
- 198k
- フォーク
- 15k
- 平均マージ
- 2時間 16分
- マージ済み PR(30日)
- 9
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/markitdown のほかの issue
-
IpynbConverter uses a comment inside a Markdown code fence as the notebook title対応中かも @Primaverah が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
microsoft/markitdown#2964 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
PPTX image alt text ending in a backslash breaks the Markdown image対応中かも @dongyikuan919 が 3 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
microsoft/markitdown#2943 ·
メンテナーはふだん 1 日以内に返信
-
PPTX chart labels with pipes or line breaks produce malformed Markdown tables対応中かも @dongyikuan919 が 5 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 92/100
microsoft/markitdown#2937 ·
メンテナーはふだん 1 日以内に返信
-
DOCX: math pre-processing re-parses every document.xml even without equations (32 s -> 17.5 s on a 12.5 MB document)対応中かも @houyunsun が 26 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 89/100
microsoft/markitdown#2834 ·
メンテナーはふだん 1 日以内に返信
-
URL fetch sends default python-requests User-Agent, Wikipedia returns 403対応中かも @sushan5140 が 31 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
microsoft/markitdown#2820 ·
メンテナーはふだん 1 日以内に返信
microsoft/markitdown の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
hugohe3/ppt-master#366 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 89/100
メンテナーはふだん 2 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
521xueweihan/HelloGitHub#4716 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 84/100
pcqpcq/open-source-android-apps#619 ·
メンテナーはふだん 1 日以内に返信
-
contribution Windows 主机
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Lee-xeo/Claude-Cage#1519 ·
メンテナーはふだん 1 日以内に返信