Repository navigation
fix(links): match Asciidoctor's ids for anchored sections and listings - #1
Merged
Merged
Conversation
sectionIDs accepted ids that Asciidoctor never generates, so a link to a missing section could pass rfdtool check: - A section whose block attributes or title set an id, as with [[values]] above it, gets that id instead of one from its title. sectionIDs added both. Block attributes apply across blank lines, as in Asciidoctor. - [[exporters]] in a TOML listing is text, not an anchor. sectionIDs read anchors in literal blocks, which it already skipped for section titles. It also missed an id shorthand after a style, as in [source#id] or [discrete#id], which it now accepts. Where it cannot tell, sectionIDs keeps an id rather than rejecting a valid link: listings that set subs= may render anchors, an anchor inside monospace text still renders, and a quoted attribute value that looks like an anchor does not take the section's title id away. Against asciidoctor.js 4.1.1 with the site settings, across the 24 Renga RFDs and 30 edge cases, main accepted 20 ids that do not exist and missed 3; this accepts 1 that does not exist, deliberately, and misses none. Amp-Thread-ID: https://ampcode.com/threads/T-01a15d15-bb12-7429-9794-374e145cd95e Co-authored-by: Amp <amp@ampcode.com>
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.
rfdtool checkvalidates links to sections (<<goal>>,link:../0005/README.adoc#goal[...]) against the ids it expects Asciidoctor to generate. It accepted ids that don't exist, so a broken section link could pass.What changes
[[values]](or[#id],[id=...]) above it, or[[id]]in its title, gets only that id, as in Asciidoctor. Block attributes apply across blank lines.[[exporters]]in a TOML listing no longer counts as an anchor. Listings, literals and passthroughs that setsubs=are still scanned, since they can render anchors; comment blocks never are.[source#id],[discrete#id.role]) are now accepted; they were missed before.Where it can't tell, the checker keeps the id: a false accept only misses a broken link, but a false reject blocks a valid one. The only known false accept is an anchor-looking quoted value such as
[role="[[x]]"].Verification
Compared with asciidoctor.js 4.1.1 using the RFD site's settings (
idprefix="",idseparator="-"), on the 24 Renga RFDs plus 30 edge-case snippets:mainThe new
TestSectionIDscases fail onmain.go test ./..., golangci-lint andrfdtool checkon the Renga RFDs (includingRFD_BASE_REF=origin/main) pass.Found while evaluating Go AsciiDoc parsers:
kilabit.info/asciidoctor-goexposes no document tree, misreads titles after header attributes, and generates different ids for titles with punctuation, so it isn't adopted here.