JSON-writer diagnostics are dropped ("failed to serialize AST to Pandoc JSON (1 diagnostics)"); a stray `{key=value}` in prose triggers it

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

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

调研方向

Start in crates/quarto-core/src/stage/stages/pandoc_write.rs near line 1125, where json_result.map_err keeps only diags.len(), then trace how the writer's diagnostics in writers/json.rs could be passed through to the output. Reproduce with q2 render s4.qmd --to docx using the {colspan=2} paragraph, and check that the --json-errors output includes a location. Done means the writer's diagnostics are printed with their source location, and a parse-time diagnostic is emitted for the standalone attribute so that HTML and docx agree.

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

描述

Tested with q2 0.47.0 and pandoc 3.14 (via QUARTO_PANDOC) on Windows 11.

When the pandoc JSON writer reports a problem, the render stops with only a count. In crates/quarto-core/src/stage/stages/pandoc_write.rs (around line 1125), json_result.map_err(|diags| …) keeps diags.len() and drops the diagnostics. So the author never sees the message the writer built, with its location. This affects every format that goes through pandoc: docx, json, native, plain and so on.

A simple way to trigger it is a {key=value} block in the middle of a paragraph, for example after pasting text, or when trying an attribute where q2 doesn't support one. The parser accepts it as a standalone attribute. writers/json.rs treats that as a case that "should not reach" it, and builds the error "Standalone attribute not supported in JSON format".

Repro

Text {colspan=2} here.

q2 render s4.qmd --to docx

Actual:

Error: failed to serialize AST to Pandoc JSON (1 diagnostics)

The one diagnostic isn't printed. --json-errors gives "details":[] and no location. With --to html, the render succeeds and the paragraph is <p>Text here.</p>: the text is dropped without a warning.

Expected:

  1. The writer's diagnostics are shown, with their source location.
  2. A standalone attribute that has nothing to attach to gets a diagnostic at parse time, as Q-2-41 does for invalid brace runs like { a, b }. Then HTML and docx behave the same, and the text doesn't silently disappear in HTML.
主要语言
Rust
星标
316
派生
23
平均合并
11 小时 49 分钟
30 天内合并 PR
245

环境准备

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

从这里开始

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

quarto-dev/q2 的其他 Issue

查看 quarto-dev/q2 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

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