Make cross-chapter links work in both outputs - #158
Merged
Merged
Conversation
A spec single-sourced for the PDF and the site has to write a link to an
anchor in another chapter as <<chapter.adoc#some-id>>: a bare
<<some-id>> is a broken link on the site, where each chapter is its own
page. Neither build resolved that form out of the box.
- src/cross-page-xrefs.rb, in the Makefile's REQUIRES, lets the PDF
build resolve those links to the included pages, so they render as
before ("Chapter 1", "Table 5").
- antora-playbook.yml registers xref_text_extension from the
docs-resources submodule (riscv/docs-resources#261), which supplies
the link text on the site; Antora otherwise renders the raw target.
This covers the local preview, the pull-request preview and the
GitHub Pages site, whose playbook derives from this one. The central
playbook registers its own copy.
- docs-resources moves to the commit that carries the extension.
Registering it without the bump fails with "Cannot find module", so
UPGRADING 2.7 now says to take the submodule before merging the
playbook.
- The sample spec links across pages, so this repo's own gate exercises
both paths, and MIGRATION says how to write these links.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Signed-off-by: Bill Traynor <wmat@riscv.org>
UPGRADING 2.4 copies scripts/ wholesale but not src/, so a repo taking the Makefile's REQUIRES change would not have received the helper and its PDF build would fail with 'cannot load such file'. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Bill Traynor <wmat@riscv.org>
This was referenced Sep 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes a cross-chapter link work in both outputs a spec repo produces from one source.
Problem
The template's dual-source layout gives each chapter its own Antora page, so a link to an anchor in another chapter has to name that chapter:
Neither build handled that form until now:
../modules/ROOT/pages/intro.intro.adoc#introas the link text, since Antora does not generate text for an anchor on another page.A bare
<<some-id>>is not an option either: it works in the PDF and is a broken link on the site.Changes
src/cross-page-xrefs.rb, added to the Makefile'sREQUIRES: registers each included page under its file name, so the PDF resolves these links and generates the text as before ("Chapter 1", "Table 5", "IRR4").antora-playbook.ymlregistersxref_text_extensionfrom thedocs-resourcessubmodule (Add the Antora xref text extension for spec repos docs-resources#261), which supplies the link text on the site. This covers the builds a spec repo runs itself: the local preview, the pull-request preview, and the GitHub Pages site, whose playbookgen-pages-playbook.jsderives from this file. docs.riscv.org registers its own copy.docs-resourcesbumped to the commit carrying the extension (b5df347→3184f3f, which adds only that file and its README section). Registering without the bump fails withCannot find module, so UPGRADING 2.7 now says to take the submodule before mergingantora-playbook.yml.Verification
Built here with
VERSION=v0.8 DATE=2026-09-22:Also exercised on a real migrated spec (
riscv/riscv-high-assurance-cryptography, 175 cross-chapter links): the PDF text is byte-identical with the helper in place, and the site build fills every link.For existing repos
Nothing breaks: this only matters for a repo that writes page-qualified links. When adopting it, bump
docs-resourcesin the same PR as the playbook change.🤖 Generated with Claude Code