feat: Seitenzahlen der Druckausgabe per --page-markers (P5)

- Erkennung: epub:type/role pagebreak (aria-label, title, Text) sowie
  Seitenanker-IDs page_47, page37, seite-12 und p17 (nur leere a/span)
- Ausgabe: visible = \[S. 123\], comment = <!-- S. 123 -->, none (Standard)
- keine Marker in Code; Marker in Überschriften als Absatz davor;
  Layout-Tabellen-Überschriften behalten ihre Seitenmarke
- Bericht: layout.page_markers; interne data-e2m-*-Attribute nie im HTML

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Dieter Schlüter 2026-10-06 05:10:38 +02:00
commit 16e2d186a4

View file

@ -162,3 +162,25 @@ def test_p3_p7_html_styles(convert):
assert '<div style="text-align: center">\n\nWidmung\n\n</div>' in text
assert "Zweiter Absatz." in text and "Aldus" not in text # base paragraph style is not repeated
assert run.report["css"]["applied"]["style"] >= 5
PAGES = ('<h1>K</h1><p>Ende Seite 89.</p><div aria-label="90" epub:type="pagebreak" id="page90" role="doc-pagebreak"/>'
'<p>Text<a id="page_12"/> weiter, <span id="page_13">Wort</span> und<a id="p14"/> fort.</p>'
'<p id="p15">Absatz mit Absatz-ID.</p><h2><a id="page_16"/>Kapitelanfang</h2><p>x</p><pre><a id="page_17"/>code</pre>'
'<table class="Head2"><tr><td class="sec_num"><a id="page_18"/>1.2</td><td>Tabellentitel</td></tr></table>')
def test_p5_page_markers(convert):
none = convert(Book(docs=[Doc("c.xhtml", PAGES)])).chapter("001")
assert "S. 90" not in none and "S. 12" not in none
vis = convert(Book(docs=[Doc("c.xhtml", PAGES)]), "--page-markers", "visible")
text = vis.chapter("001")
assert "Ende Seite 89.\n\n\\[S. 90\\]" in text
assert "Text\\[S. 12\\] weiter, \\[S. 13\\]Wort und\\[S. 14\\] fort." in text
assert "S. 15" not in text # paragraph id, not a page
assert "\\[S. 16\\]\n\n## Kapitelanfang" in text # marker before the heading, not inside it
assert "```\ncode\n```" in text # nothing inside code
assert "\\[S. 18\\]\n\n## 1.2 Tabellentitel" in text # layout-table heading keeps the page
assert vis.report["layout"]["page_markers"] == 6
com = convert(Book(docs=[Doc("c.xhtml", PAGES)]), "--page-markers", "comment").chapter("001")
assert "<!-- S. 90 -->" in com and "Text<!-- S. 12 --> weiter" in com