mirror of
https://github.com/affaan-m/ECC.git
synced 2026-12-06 15:12:02 +09:00
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:
5 files changed
+102
-73
No files matched your search
@@ -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(
|
||||
|
||||
Reference in new issue
Block a user