fix(adoc): resolve empty-text cross-references corrupting walker context#1110
Open
SudhanshuMatrix wants to merge 1 commit into
Open
fix(adoc): resolve empty-text cross-references corrupting walker context#1110SudhanshuMatrix wants to merge 1 commit into
SudhanshuMatrix wants to merge 1 commit into
Conversation
Fixes a bug where rules with 'scope: heading' stopped matching most section titles in an AsciiDoc file if that file combined explicit block anchors with 'xref:' inline macros having empty link text. During HTML compilation, Asciidoctor resolves empty-text cross-references (e.g., 'xref:target[]' or '<<target>>') using the target heading's title. Since this resolved title text is not present in the raw source paragraph containing the reference, Vale's walker fails to locate the exact phrase and falls back to masking individual words across the rest of the document. This erroneously masks those words at subsequent headings, corrupting their text in the walker context and causing them to be silently skipped. We resolve this by pre-processing the AsciiDoc content inside 'lintADoc' to rewrite empty-text cross-references so that their target text matches the literal target identifier present in the raw source: - 'xref:target[]' -> 'xref:target[target]' - '<<target>>' -> '<<target,target>>'
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.
Description
This PR fixes a silent false-negative bug where rules carrying
scope: headingstop matching section titles in an AsciiDoc file if that file combines explicit block anchors withxref:inline macros (having empty link text).Fixes #1109
Root Cause
xref:id[]or<<id>>) using the target heading's title."first","heading","lowercase") anywhere it can find them in the remaining document context."second heading lowercase"becomes"second @@@@@@@ @@@@@@@@@").Proposed Changes
We intercept the AsciiDoc content inside
lintADocininternal/lint/adoc.gobefore it is passed to Asciidoctor, and rewrite empty-text references:xref:target[]->xref:target[target]<<target>>-><<target,target>>This ensures that the text rendered in the HTML tag is the literal target identifier (e.g.
#introorintro), which is present in the raw source code of the paragraph. Vale's walker successfully matches and masks it within the paragraph block, leaving subsequent headings untouched.How to Test and Verify
repro.adoc):