fix: doppelte Tabellen-Anker und Bild-Links im Linkcheck

- Komplexe Tabellen mit verlinkter id erzeugten den Anker zweimal
  (<a id> und <table id>), also ungültiges HTML.
- Der Linkcheck übersah das äußere Ziel von Bild-Links
  [![alt](img)](ziel) und startete Links an escapten \[-Klammern.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Dieter Schlüter 2026-10-05 20:24:47 +02:00
commit 0dad1f7b2d

View file

@ -66,3 +66,18 @@ def test_link_checker_detects_problems():
}
broken = check_links(files, {"media/images/a.png"})
assert {b["link"] for b in broken} == {"002-b.md#nein", "003.md"}
def test_link_checker_ignores_escaped_brackets():
"""An escaped \\[ must not start a link that swallows the following paragraphs."""
files = {
"a.md": '\\[»\\] Hinweis\n\n<a id="x"></a>Text [kaputt](fehlt.md) und \\[1\\]\n\n[ok](#x)\n',
}
broken = check_links(files, set())
assert [b["link"] for b in broken] == ["fehlt.md"]
def test_link_checker_handles_image_links():
files = {"a.md": "[![Abb.](bild.png)](fehlt.md) [![ok](bild.png)](#x) <a id=\"x\"></a>\n"}
broken = check_links(files, {"bild.png"})
assert [b["link"] for b in broken] == ["fehlt.md"]