Readable bookmark names for cross-reference targets in docx output

Abierto
#15,331 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
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
25/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Activo
Stack tecnológico
javascript

Línea de trabajo

The issue asks for reports of workflows that depend on readable DOCX bookmark names, to judge whether Quarto should request a Pandoc fallback before hashing. Start by reviewing the examples in the issue: external links, hand-added Word cross-references, and post-processing with officer, VBA, or python-docx. Done means documenting a concrete use case in the issue; any implementation would need a separately scoped decision.

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

Descripción

crossref docx enhancement

Since Pandoc 3.12, the docx writer starts every bookmark name with _ and replaces any id containing a character other than a letter, digit or _ with a SHA-1 hash (jgm/pandoc@d171c5b, from jgm/pandoc#11845). Quarto 1.12 updates the bundled Pandoc to 3.13 (#15320).

All Quarto cross-reference ids contain - (fig-plot, tbl-cars, sec-intro), so every cross-reference target in a .docx is now a hidden bookmark with a name like _fba68d637b950dddd2fa839b49fee024d186089.

source

toBookmarkName :: Text -> Text
toBookmarkName s
  | T.length s < 40
  , T.all (\c -> isAlphaNum c || c == '_') s
    = "_" <> s
  | otherwise = "_" <> T.pack (drop 1 (show (hashWith SHA1 (fromText s))))

Cross-reference links inside the document still work, as link anchors are hashed the same way. What is lost is any reference to a target by its Quarto id from outside the document:

  • a link like report.docx#fig-plot
  • a Word cross-reference added by hand to a Quarto figure or table, which now requires showing hidden bookmarks and finding the right hash
  • post-processing (officer, VBA, python-docx) that looks a bookmark up by name

We decided to accept the Pandoc change for 1.12 and document it in the changelog. This issue is to collect use cases where the readable name matters. If you rely on one of the above, please describe your workflow here.

If there is demand, we could ask upstream for a readable fallback before hashing, for example fig-plot becoming _fig_plot, still hidden but recognisable. Hashing would remain for collisions or long ids.

Related: jgm/pandoc#6078 (Word cross-reference fields instead of hyperlinks in the docx writer)

Lenguaje dominante
JavaScript
Estrellas
6.2k
Forks
482
Merge medio
17 h 46 min
PR fusionados (30 d)
135

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/quarto-cli

Todos los issues de quarto-dev/quarto-cli

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.