commonmark reader registers its input twice and stamps nodes with the content-less FileId(0)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
crates/pampa/src/readers/commonmark.rsを読み、そのコンテキスト設定をcrates/pampa/src/readers/qmd.rsと比較してください。crates/pampa/tests/integration/test_diagnostic_path_normalization.rs、特にcommonmark_reader_source_context_uses_forward_slashesを更新し、正規化されたパスと入力内容がFileId(0)に属し、登録されるファイルが1つだけであることを確認してください。commonmarkノードがその内容を持つファイルを使用し、対象のテストが成功すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
pampa::readers::commonmark::read registers its input in the SourceContext twice and then points every node's SourceInfo at the wrong entry: the one without content. Line/column mapping for commonmark-read nodes only works today because the sole caller (the pampa CLI's --from commonmark) passes a real path that the first registration reads back from disk. For an in-memory input (anything named like <pandoc.read>), no position in the resulting AST can be turned into a line and column.
Where
crates/pampa/src/readers/commonmark.rs, read:
let mut context = ASTContext::with_filename(filename.to_string()); // (1) add_file(filename, None) -> FileId(0)
let normalized_filename = context.filenames[0].clone();
context
.source_context
.add_file(normalized_filename, Some(input.to_string())); // (2) same path, with content -> FileId(1)
let file_id = FileId(0); // (3) ...but nodes are stamped with FileId(0)
let source_ctx = SourceLocationContext::new(input, file_id);
let pandoc = convert_document_with_source(root, Some(&source_ctx));
SourceContext::add_file (quarto-source-map 0.3.0, context.rs) always pushes a new SourceFile; it does not dedupe by path. So after (2) the context holds two files with the same path: FileId(0) with content: None and a file_info only if std::fs::read_to_string(path) succeeded, and FileId(1) with the actual content. Every SourceInfo::Original the conversion produces names FileId(0).
The qmd reader (readers/qmd.rs, same spot) avoids this by replacing the context before adding the file:
let mut context = ASTContext::with_filename(filename.to_string());
context.source_context = quarto_source_map::SourceContext::new();
context.source_context.add_file(normalized_filename, Some(input_str));
so its FileId(0) is the entry that has the content.
Evidence that it is pinned rather than caught
crates/pampa/tests/integration/test_diagnostic_path_normalization.rs, commonmark_reader_source_context_uses_forward_slashes, asserts on FileId(1) and explains why:
FileId(0) is the entry
ASTContext::with_filenamecreates internally … The fix this test protects is commonmark::read's own secondadd_filecall, which lands at FileId(1)
That test will need to move to FileId(0) with the fix (and could additionally assert the context holds exactly one file).
Consequences
- With a real on-disk path: works by accident.
FileId(0)got aFileInformationfrom re-reading the file, somap_offsetsucceeds;FileId(1)is dead weight. - With an in-memory input and a synthetic name:
FileId(0)has neither content norfile_info. A diagnostic or anymap_offsetagainst a commonmark node has an offset into a file the context cannot map. This is the path a Luapandoc.read(text, "commonmark")would take (separate issue), and the reason to fix this first. - Snapshot or provenance tooling that looks at
root_file_id()of commonmark nodes gets the content-less entry.
Fix
Mirror the qmd reader: build the context, replace source_context with a fresh one (or skip the with_filename registration), add_file(normalized, Some(input)) once, and use the FileId that call returns instead of a hard-coded FileId(0). Update the test above to assert a single file at FileId(0) with the normalized path and the content.
Environment
Repo at ad283a2cb (2026-10-16); quarto-source-map 0.3.0.
- 主要言語
- Rust
- スター
- 278
- フォーク
- 19
- 平均マージ
- 21時間 56分
- マージ済み PR(30日)
- 156
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
quarto-dev/q2 のほかの issue
-
難易度 5/5 1週間以上 初心者へのやさしさ 48/100
quarto-dev/q2#900 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
quarto-dev/q2#896 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
quarto-dev/q2#893 · リアクション 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
quarto-dev/q2#892 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
quarto-dev/q2#891 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 1 日以内に返信
-
area:sim good first issue kind:feature
難易度 2/5 1〜3時間 初心者へのやさしさ 87/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
bitcoindevkit/bdk#2432 ·
メンテナーはふだん 3 日以内に返信
-
The demo's interval button and chart legend keep the previous interval after an interval changeオープンbug ui
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
userFRM/egui-charts#670 ·
メンテナーはふだん 1 日以内に返信
-
docs good first issue
難易度 1/5 1〜3時間 初心者へのやさしさ 84/100
Usenova-Labs/usenova-backend#35 ·
メンテナーはふだん 1 日以内に返信