Readable bookmark names for cross-reference targets in docx output

オープン
#15,331 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
活発
技術スタック
javascript
領域
documentation

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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)

主要言語
JavaScript
スター
6.2k
フォーク
482
平均マージ
17時間 46分
マージ済み PR(30日)
135

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

quarto-dev/quarto-cli のほかの issue

quarto-dev/quarto-cli の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。