Skip to content

Fix cross-reference id lookups - #92

Merged
bbatsov merged 4 commits into
masterfrom
fix-id-lookups
Oct 7, 2026
Merged

bbatsov merged 4 commits into
masterfrom
fix-id-lookups

Conversation

@bbatsov

@bbatsov bbatsov commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Ids were looked up case-insensitively, xref:#id[] and [[id,reftext]] couldn't be resolved, and M-? on a section title prompted instead of using the section's id.

A section with an explicit id now uses that id and stops offering its auto-id, since Asciidoctor doesn't generate one for it. The rest of the section auto-id differences (duplicate titles, {attr} in titles, :sectids!:) are left for another time.

Asciidoctor ids are case-sensitive, but adoc--goto-id and
adoc--xref-collect searched with the default case-fold-search, and the
Antora project-wide search handed grep `-i' for the same reason. So
`<<foo>>' could jump to `[[FOO]]', and definitions and references
mixed ids that only differ in case.
The `#' in `xref:#id[]' isn't part of the id, but adoc-xref-id-at-point
returned `#id', so following it failed ("Can't find an anchor
defining '#id'") and M-? found no references. Strip it there, and let
adoc--re-xref-to match the `#' form like the Antora search already did.
adoc-re-anchor's inline-special regexp, given an id, only allowed
whitespace between the id and the closing `]]', so `[[inl,Inline Ref]]'
never matched `inl': completion offered the id (it splits at the
comma) but definitions and following came up empty. Allow the reftext,
brackets in it included.
xref-backend-identifier-at-point only knew about xrefs and anchors, so
M-? on a section title prompted instead of finding the references to
that section. It now returns the section's id.

That id is the explicit one when the section has one - a block anchor
or id right above the title, or an anchor at the end of it - since
Asciidoctor then doesn't generate an auto-id at all. For the same
reason such sections no longer contribute an auto-id to completion and
section lookups; their anchors already define them.
@bbatsov
bbatsov merged commit e8f6e71 into master Oct 7, 2026
6 of 8 checks passed
@bbatsov
bbatsov deleted the fix-id-lookups branch October 7, 2026 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant