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 [](ziel) und startete Links an escapten \[-Klammern. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
557bbd3b36
commit
0dad1f7b2d
2 changed files with 34 additions and 3 deletions
|
|
@ -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": "[](fehlt.md) [](#x) <a id=\"x\"></a>\n"}
|
||||
broken = check_links(files, {"bild.png"})
|
||||
assert [b["link"] for b in broken] == ["fehlt.md"]
|
||||
|
|
|
|||
|
|
@ -63,3 +63,10 @@ def test_unknown_elements_are_reported_and_keep_html(convert):
|
|||
kept = convert(Book(docs=[Doc("c.xhtml", body)]), "--keep-html")
|
||||
assert '<foo-widget data-x="1">Inhalt bleibt</foo-widget>' in kept.chapter("001")
|
||||
assert "evil" not in kept.chapter("001")
|
||||
|
||||
|
||||
def test_complex_table_anchor_is_emitted_once(convert):
|
||||
body = ('<h1>T</h1><p><a href="#t1">Tabelle 1</a></p><table id="t1"><tr><td colspan="2">a</td></tr>'
|
||||
"<tr><td>b</td><td>c</td></tr></table>")
|
||||
text = convert(Book(docs=[Doc("c.xhtml", body)])).chapter("001")
|
||||
assert text.count('id="t1"') == 1
|
||||
|
|
|
|||
Loading…
Reference in a new issue