Repository navigation
feat(xref): add --force-local-file-xrefs - #467
Conversation
76f7429 to
307236a
Compare
fda7e86 to
5210712
Compare
Allow combined or partially included documents to resolve file-qualified cross-references by their local anchors. Expose --force-local-file-xrefs and OptionsBuilder::with_force_local_file_xrefs(). Preserve URLs and custom link text. Keep the option disabled for every backend, including PDF, and require a nonempty fragment. Document that the option can redirect external file references. It does not scope duplicate anchors or resolve Antora resource IDs. Complete includes already resolve locally without this option. Co-authored-by: mocenigo <roberto.avanzi@gmail.com>
5210712 to
6f3d188
Compare
Use a private mode for normal and forced local file references. Keep the builder API and reference behaviour unchanged, and remove the excessive-bools allowances from Options and OptionsBuilder. Preserve the selected mode when options are made static or rebuilt.
|
I've added But I think there’s also a way to resolve these links through the normal include rules, in both Asciidoctor PDF and acdc. After looking through https://github.com/riscv/riscv-high-assurance-cryptography/ I believe the mismatch is between the include path in your PDF master: include::../modules/ROOT/pages/Zkl-ISA-unpriv.adoc[leveloffset=+1] and the reference in a chapter: <<Zkl-ISA-unpriv.adoc#KLE-State-field>> Both converters compare these paths relative to the master document. Your Ruby extension handles the difference by registering included files under their basenames. If you’re happy to adjust the PDF build, I’d try using modules/ROOT/pages as the master’s base directory and changing its chapter includes to basenames: include::Zkl-ISA-unpriv.adoc[leveloffset=+1] The existing reference then matches the include directly. Asciidoctor supports an explicit base directory; both converters can also read the master through stdin while running from that directory. Shared includes, images, fonts and theme paths would need adjusting. Another option is to use ifdef::env-site[] to select a reference prefix: empty for Antora, and ../modules/ROOT/pages/ for the combined document. That requires changing the references and updating the tools that inspect them, so I’d start with the build-directory approach perhaps. In any case, this flag remains useful if you prefer to keep the current layout - its mostly harmless. Matching the include paths has one useful advantage: references to documents outside the assembled book keep their normal external-link behaviour. |
[...]
Yes there may be other methods but this one is useful as a quick solution/quick check. |
I removed the short form. For flags like this one I think it's preferable to force using the long form. If there's a constraint you have on the length of the name, happy to consider. |
A document combined outside acdc, or built from selected includes, can keep references to the original files.
--force-local-file-xrefslets the author resolve those references by their local anchors. Complete includes already resolve locally without this flag.acdc convert --backend pdf --force-local-file-xrefs book.adocThe parser API is
Options::builder().with_force_local_file_xrefs().For example, when the combined document contains the
KLEE-State-fieldanchor:Both references resolve within the combined document. The explicit text remains
the state field.Scope and limits
#. Page-only references and empty fragments keep normal behavior.//. Protected URL text is restored before this check. A single letter before:is treated as a Windows drive.introanchor cannot be distinguished after their filenames are removed.--fail-on-warningscan make the conversion return a failure status. Cross-references never load their target files.guide:chapter.adoc#introkeeps normal behavior because its prefix looks like a URI scheme.Relationship to Antora
Antora's official PDF Extension uses Assembler to select and combine pages before conversion. Assembler scopes anchors, turns references to pages in the same assembly into internal references, and keeps references to other pages or attachments external. Its prepared source does not need this override. See Assembler concepts and PDF link settings.
Antora also recommends
xref:page.adoc#anchor[]for cross-page references. Extensions may not support<<page.adoc#anchor>>in that role. See Antora's xref guidance.Refs #464.