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

Aperta Adatta ai principianti
#1,435 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
77/100
Tipo di issue
Documentazione
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
markdown, rust

Direzione di ricerca

La issue propone un avviso nella guida alla migrazione e un avviso facoltativo per le sequenze di parentesi quadre con escape nell’output di qmd-syntax-helper; non indica file né test. Inizia individuando la guida alla migrazione e la gestione dell’output dell’helper, poi verifica come le sue regole segnalano i risultati della conversione. Il lavoro è completato quando la guida spiega che i riferimenti e le note a piè di pagina all’interno dei blocchi interessati vanno convertiti prima della conversione e l’output può segnalare le parentesi quadre con escape da esaminare.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Rust
Stelle
321
Fork
23
Merge medio
11h 39m
PR unite (30g)
251

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di quarto-dev/q2

Tutte le issue di quarto-dev/q2

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.