fix: Inline-SVG in HTML-Tabellen als <img> ausgeben (QA2-05)
Eingebettete SVGs in komplexen Tabellen wurden als Markdown-Bild  in den HTML-Block geschrieben und daher nicht angezeigt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
6be92645f4
commit
e9120c84ef
2 changed files with 14 additions and 0 deletions
|
|
@ -1103,6 +1103,8 @@ class Renderer:
|
|||
self.formulas.append({"source": self._source(el), "chapter": self.file, "origin": "svg",
|
||||
"representation": "svg", "display": "false"})
|
||||
self.diag.warn("formula-svg", "Formel liegt nur als SVG vor; als Bild referenziert.", self._source(el), self.file)
|
||||
if self.in_table_html: # Markdown is not rendered inside an HTML block
|
||||
return [("r", f'<img src="{html.escape(url_path(rel_link(self.file, mf.output)))}" alt="{html.escape(alt)}"/>')]
|
||||
return [("r", f")})")]
|
||||
|
||||
def math(self, el: Any, display: bool) -> list[Piece]:
|
||||
|
|
|
|||
|
|
@ -86,3 +86,15 @@ def test_end_of_book_reference_inside_html_table_is_html(convert):
|
|||
table = _html_table(run.chapter("001"))
|
||||
assert "](" not in table, table
|
||||
assert '<a href="999-anmerkungen.md#fn-001">1</a>' in table
|
||||
|
||||
|
||||
def test_inline_svg_inside_html_table_is_html_img(convert):
|
||||
"""QA2-05: inline SVG in a complex table was written as Markdown image inside the HTML block."""
|
||||
body = ('<h1>T</h1><table><tr><th colspan="2">Kopf</th></tr><tr><td>A</td><td>'
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" width="5" height="5" aria-label="Kreis"><circle r="2"/></svg>'
|
||||
"</td></tr></table>")
|
||||
run = convert(Book(docs=[Doc("c.xhtml", body)]))
|
||||
table = _html_table(run.chapter("001"))
|
||||
assert "![" not in table, table
|
||||
assert re.search(r'<img src="\.\./media/images/\d{4}-c-svg\.svg" alt="Kreis"/>', table), table
|
||||
assert run.report["output_link_check"]["broken_count"] == 0
|
||||
|
|
|
|||
Loading…
Reference in a new issue