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

未关闭 适合新手
#1,435 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
77/100
Issue 类型
文档
描述清晰度
描述清楚
活跃度
活跃
技术栈
markdown, rust

调研方向

Issue 提议在迁移指南中添加警告,并为 qmd-syntax-helper 输出中的转义方括号序列提供可选警告;没有指定文件或测试。首先找到迁移指南和 helper 的输出处理部分,然后检查其规则如何报告转换结果。完成标准是:指南说明应在转换前转换受影响块中的引用和脚注,并且输出能够标记需要检查的转义方括号。

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

描述

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.

主要语言
Rust
星标
321
派生
23
平均合并
11 小时 39 分钟
30 天内合并 PR
251

环境准备

  • 没有 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 摘要。