fix: Leerzeilenfolgen innerhalb von Codeblöcken erhalten (QA2-06)
render_chapter reduzierte mehrfache Leerzeilen im gesamten Kapiteltext, auch innerhalb von Codeblöcken (z. B. zwei Leerzeilen zwischen Python-Funktionen nach PEP 8). Im Python-Beispielbuch waren 54 von 746 Listings nicht mehr zeichengetreu. Die Normalisierung gilt jetzt nur außerhalb von Fences. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e9120c84ef
commit
7de7efaaa2
1 changed files with 30 additions and 1 deletions
|
|
@ -98,3 +98,12 @@ def test_inline_svg_inside_html_table_is_html_img(convert):
|
|||
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
|
||||
|
||||
|
||||
def test_multiple_blank_lines_inside_code_are_kept(convert):
|
||||
"""QA2-06: runs of blank lines inside code blocks were collapsed to one (PEP 8: two between functions)."""
|
||||
code = "def f():\n pass\n\n\nclass K:\n pass\n\n\n\nx = 1"
|
||||
body = f"<h1>K</h1><p>Vorher</p><pre>{code}</pre><p>Nachher</p>"
|
||||
text = convert(Book(docs=[Doc("c.xhtml", body)])).chapter("001")
|
||||
assert f"```python\n{code}\n```" in text, text
|
||||
assert "\n\n\n" not in text.replace(code, "") # outside code blank lines are still normalized
|
||||
|
|
|
|||
Loading…
Reference in a new issue