GFM trennt Tabellenzellen an jedem unmaskierten senkrechten Strich, auch innerhalb von Code-Spans und Link-Zielen. Operator-Tabellen (|, ||, |=) verloren dadurch Zellinhalte. Solche Tabellen werden jetzt wie andere komplexe Tabellen als bereinigtes HTML mit Warnung ausgegeben. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
23 lines
1 KiB
Python
23 lines
1 KiB
Python
"""Regression tests for defects found in the independent QA run (.qa/QA_REPORT.md, IDs QA2-…)."""
|
|
|
|
import re
|
|
|
|
from conftest import Book, Doc
|
|
|
|
|
|
def _pipe_rows(text: str) -> list[str]:
|
|
return [ln for ln in text.splitlines() if ln.startswith("| ")]
|
|
|
|
|
|
def test_pipe_in_inline_code_does_not_split_gfm_table(convert):
|
|
"""QA2-01: GFM splits table cells at every unescaped '|', also inside code spans and link targets."""
|
|
body = ("<h1>Operatoren</h1><table><thead><tr><th>Operator</th><th>Bedeutung</th></tr></thead><tbody>"
|
|
"<tr><td><code>||</code></td><td>logisches ODER</td></tr>"
|
|
"<tr><td><code>a | b</code></td><td><a href=\"https://example.org/a|b\">Link</a></td></tr>"
|
|
"</tbody></table>")
|
|
run = convert(Book(docs=[Doc("c.xhtml", body)]))
|
|
text = run.chapter("001")
|
|
for row in _pipe_rows(text):
|
|
cells = re.split(r"(?<!\\)\|", row.strip()[1:-1])
|
|
assert len(cells) == 2, f"Zeile zerfällt in GFM in {len(cells)} Zellen: {row}"
|
|
assert "||" in text and "a | b" in text and "logisches ODER" in text
|