Readable bookmark names for cross-reference targets in docx output

Offen
#15,331 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
25/100
Issue-Typ
Feature
Klarheit
Muss geklärt werden
Aktivitätsstatus
Aktiv
Tech-Stack
javascript
Bereich
documentation

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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)

Vorherrschende Sprache
JavaScript
Sterne
6.2k
Forks
482
Ø Merge
17 Std. 46 Min.
Gemergte PRs (30 T.)
135

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus quarto-dev/quarto-cli

Alle Issues in quarto-dev/quarto-cli

Ähnliche Issues

Weitere Issues zu JavaScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.