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

Abierto Apto para principiantes
#1,435 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
77/100
Tipo de issue
Documentación
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
markdown, rust

Línea de trabajo

La incidencia propone una advertencia en la guía de migración y una advertencia opcional para las secuencias de corchetes escapados en la salida de qmd-syntax-helper; no menciona archivos ni pruebas. Empieza por localizar la guía de migración y el procesamiento de la salida del helper; después, comprueba cómo sus reglas informan de los resultados de la conversión. El trabajo estará terminado cuando la guía explique que hay que convertir las referencias y las notas al pie dentro de los bloques afectados antes de la conversión, y la salida pueda señalar los corchetes escapados para su revisión.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Rust
Estrellas
321
Forks
23
Merge medio
11 h 39 min
PR fusionados (30 d)
251

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de quarto-dev/q2

Todos los issues de quarto-dev/q2

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.