From 6f80c1a223bbdf7584c6a154780974eb83309cb6 Mon Sep 17 00:00:00 2001 From: Sudhanshu Date: Sun, 28 Jun 2026 15:09:58 +0530 Subject: [PATCH] fix(adoc): resolve empty-text cross-references corrupting walker context 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 '<>') 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]' - '<>' -> '<>' --- internal/lint/adoc.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/lint/adoc.go b/internal/lint/adoc.go index 06579e15..971be6cd 100644 --- a/internal/lint/adoc.go +++ b/internal/lint/adoc.go @@ -25,6 +25,8 @@ var adocSanitizer = strings.NewReplacer( // Convert listing blocks of the form `[source,.+]` to `[source]` var reSource = regexp.MustCompile(`\[source,.+\]`) var reComment = regexp.MustCompile(`// .+`) +var reXref = regexp.MustCompile(`xref:([^\[]+)\[\]`) +var reShortXref = regexp.MustCompile(`<<([^>,]+)>>`) var adocArgs = []string{ "-s", @@ -64,6 +66,9 @@ func (l *Linter) lintADoc(f *core.File) error { } s = adocSanitizer.Replace(s) + s = reXref.ReplaceAllString(s, "xref:$1[$1]") + s = reShortXref.ReplaceAllString(s, "<<$1,$1>>") + html, err = callAdoc(s, exe, l.Manager.Config.Asciidoctor) if err != nil { return core.NewE100(f.Path, err)