fix(docs-governance): read HTML comments and code spans in one pass, as CommonMark does

Code spans were blanked before comments, so a code span could swallow a comment's closer and the comment then hid a real link after it. Comments and code spans are now read left to right, whichever opens first. An escaped \<!-- is text, and a comment becomes an opaque run of NUL characters rather than spaces, so a reference definition can no longer start across it.
This commit is contained in:
L4XB committed 2026-10-23 01:54:04 +02:00
1 parent 72229119a3
commit bf38bfcae2
5 files changed
+102 -73

No files matched your search

+17
View File
@@ -280,6 +280,23 @@ def test_artifact_scope_ignores_links_inside_html_comments(project: Path) -> Non
assert "Broken Markdown link: 'guide.md' -> 'missing-after.md'" in result.stdout
def test_artifact_scope_reads_html_comments_as_commonmark_does(project: Path) -> None:
(project / "guide.md").write_text(
# -- an escaped opener is text, so the link after it is real --
"Intro \\<!-- [escaped](missing-escaped.md) -->\n\n"
# -- a comment that opens before a code span ends at its own closer --
"<!-- ` --> `sample` [after-code](missing-after-code.md)\n\n"
# -- a comment where a destination must begin does not make a definition --
"[foo]: <!-- note --> missing-definition.md\n\n[foo]\n",
encoding="utf-8",
)
result = run_audit(project, "artifacts")
assert result.returncode == 1
assert "Broken Markdown link: 'guide.md' -> 'missing-escaped.md'" in result.stdout
assert "Broken Markdown link: 'guide.md' -> 'missing-after-code.md'" in result.stdout
assert "missing-definition.md" not in result.stdout
def test_artifact_scope_ignores_title_with_escaped_quotes(project: Path) -> None:
(project / "guide.md").write_text("# Guide\n", encoding="utf-8")
(project / "index.md").write_text(