Treat section titles as cross-reference targets#80
Merged
Conversation
Real AsciiDoc - especially Antora docs - references sections by their auto-generated id far more than explicit [[id]] anchors. Generate each section's id the way Asciidoctor does and feed it into completion, the xref backend, and adoc-goto-ref-label, so a fragment like xref:page.adoc#clojure-cli-setup resolves to its == Clojure CLI Setup section. The id style is detected: a document's own :idprefix:/:idseparator: win, else files under an antora.yml use Antora's kebab-case style and the rest use Asciidoctor's underscore default; adoc-section-id-style forces one. The generation algorithm was validated against the asciidoctor CLI. This is phase 1 of the Antora/xref work; cross-file resolution follows.
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.
Phase 1 of the Antora/xref work. Real AsciiDoc - and especially the Antora docs I maintain (
rubocop/docs,cider/doc) - almost never uses explicit[[id]]anchors; references point at sections by their auto-generated id (e.g.xref:cljs/figwheel.adoc#clojure-cli-setup[]targets=== Clojure CLI Setup). Until nowadoc-modeonly knew about explicit anchors, so none of those resolved or completed.This generates each section's auto-id the way Asciidoctor does and feeds it into completion (
<</xref:), thexrefbackend (definitions + completion table), andadoc-goto-ref-label. The id style is detected automatically: a document's own:idprefix:/:idseparator:win; otherwise files inside an Antora component (anantora.ymlabove them) use Antora's kebab-case style (My Title->my-title) and everything else uses Asciidoctor's default (_my_title).adoc-section-id-styleforces a specific style.The id-generation algorithm is the fiddly bit, so I validated it against the real
asciidoctorCLI over a spread of titles (and a Buttercup spec does the same whenasciidoctoris installed). The level-0 doctitle is excluded, and==lines inside code blocks are skipped (reusing the heading validation the nav/imenu code already does).Next phases (separate PRs): Antora cross-file xref resolution (open
xref:page.adoc#frag, complete page targets, project-wide references, include/image resources), then paste-image-from-clipboard.eldev test)M-x checkdocwarnings