qmd-syntax-helper: Pandoc-based rules lose reference links and footnotes that depend on the rest of the document

Đang mở Phù hợp với người mới
#1,435 0 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ó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
77/100
Loại issue
Tài liệu
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
markdown, rust
Lĩnh vực
documentation, tooling

Hướng nghiên cứu

Issue đề xuất thêm cảnh báo trong hướng dẫn di chuyển và một cảnh báo tùy chọn cho các chuỗi dấu ngoặc vuông được escape trong đầu ra của qmd-syntax-helper; issue không nêu tệp hay bài kiểm thử nào. Trước tiên, hãy tìm hướng dẫn di chuyển và phần xử lý đầu ra của helper, sau đó kiểm tra cách các quy tắc của nó báo cáo kết quả chuyển đổi. Công việc hoàn tất khi hướng dẫn giải thích rằng cần chuyển đổi các tham chiếu và chú thích cuối trang bên trong những khối bị ảnh hưởng trước khi chuyển đổi, đồng thời đầu ra có thể đánh dấu các dấu ngoặc vuông được escape để xem xét.

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

Mô tả

Some qmd-syntax-helper rules (definition-lists, and grid-tables when it produces list tables) pass the construct they convert through Pandoc and write it back from Pandoc's AST. Pandoc only sees the construct itself, not the rest of the document. Markup inside it that depends on something elsewhere in the document therefore cannot be resolved: reference-style links and their [label]: url definitions, and footnote references with their [^n]: ... definitions. That markup is written back as escaped literal text (\[the manual\]\[docs\], \[\^1\]), and the link or footnote is silently lost.

Running the rules in the other order does not help. Before conversion, q2 reads a Pandoc definition list as literal text, so the reference-links rule cannot see uses inside it. It then treats their definitions as unused and removes them. Either way, the URL for a reference link inside a definition list disappears from the document. It can only be recovered from version control. I don't think this can be prevented in general: the construct has to be converted before its contents are visible to q2, and converting it is what strips the context. But the migration guide should warn about it. The helper could also flag its own output when it contains escaped \]\[ or \[\^ sequences, so these cases get a manual look.

Example
Some prose with a [working link][docs].

Term
:   A definition that cites [the manual][docs]
    and has a footnote[^1].

[docs]: https://example.com/docs

[^1]: The footnote text.

Pandoc renders both links and the footnote. After qmd-syntax-helper convert -r definition-lists -i:

Some prose with a [working link][docs].

::: {.definition-list}

* Term

  * A definition that cites \[the manual\]\[docs\]
    and has a footnote\[\^1\].

:::
[docs]: https://example.com/docs

[^1]: The footnote text.

and then after -r reference-links:

Some prose with a [working link](https://example.com/docs).

::: {.definition-list}

* Term

  * A definition that cites \[the manual\]\[docs\]
    and has a footnote\[\^1\].

:::

[^1]: The footnote text.

The link inside the definition is now literal text, and its URL is gone. The footnote reference is literal and its definition is orphaned. Running reference-links first and definition-lists second ends in the same state: the use inside the definition list is not seen, so [docs]: is removed in the first step.

A suggested sentence for the migration guide: before converting definition lists or grid tables, convert any reference-style links and footnotes inside them to inline form by hand ([text](url), ^[note]). Afterwards, review the converted blocks for escaped brackets.

qmd-syntax-helper 0.1.0, pandoc 3.13.

Ngôn ngữ chính
Rust
Star
321
Fork
23
Merge trung bình
11 giờ 39 phút
Pull request đã merge (30 ngày)
251

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.