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

Đang mở
#1,322 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
50/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
backend, cli

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
Rust
Star
316
Fork
23
Merge trung bình
11 giờ 49 phút
Pull request đã merge (30 ngày)
245

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của quarto-dev/q2

Tất cả issue của quarto-dev/q2

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.