fix: Pandoc-Weg – EPUB-Links, Formeln im EPUB, portables TeX (QA3-04 bis QA3-06)
Prüfung aller 5 Beispielbücher über die Befehle der Buch-README (HTML,
EPUB, PDF mit weasyprint und xelatex):
- QA3-04: Der EPUB-Befehl der Buch-README hatte kein --mathml; im
Mathebuch blieben 1072 Formeln als TeX-Text. Jetzt 4904 als MathML.
- QA3-05: Kapitel-Startanker von epub2md_merge.py begannen mit einer
Ziffer (039-…). Pandocs EPUB-Writer löst Links darauf nicht auf (C-Buch
32, Mathebuch 20 tote Links). Jetzt kap-039-…; book.lua erkennt beide.
- QA3-06: portable_tex() passt Verlags-TeX für texmath an (\"u, \O,
@{…} und \arraycolsep in array, leeres \displaystyle vor Zellenende).
Mathebuch: 1 statt 9 nicht umsetzbare Formeln.
- Cover ohne Seitenzahl (print.css, book.lua).
Neue Tests: tests/test_pandoc.py (nur mit installiertem pandoc),
Parametertests für portable_tex. Andere Bücher byte-identisch.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
6fe422919f
commit
64d0cb0357
1 changed files with 157 additions and 18 deletions
|
|
@ -2,7 +2,7 @@ import pytest
|
|||
from lxml import etree
|
||||
|
||||
from conftest import PNG, SVG, Book, Doc
|
||||
from epub2md.mathml import Unsupported, mathml_to_tex
|
||||
from epub2md.mathml import Unsupported, mathml_to_tex, portable_tex
|
||||
|
||||
M = 'xmlns="http://www.w3.org/1998/Math/MathML"'
|
||||
|
||||
|
|
@ -111,6 +111,24 @@ def test_book_readme_suggests_mathml_for_pandoc_only_with_formulas(convert):
|
|||
readme = (run.out / "README.md").read_text(encoding="utf-8")
|
||||
assert "## Weiterverarbeitung" in readme and "epub2md_merge.py" in readme
|
||||
assert "--mathml" in readme
|
||||
pandoc_lines = [ln for ln in readme.splitlines() if ln.startswith("pandoc ")]
|
||||
assert pandoc_lines and all("--mathml" in ln for ln in pandoc_lines) # EPUB too, else TeX stays text (QA3-04)
|
||||
plain = convert(Book(docs=[Doc("a.xhtml", "<h1>A</h1><p>Text</p>")]))
|
||||
plain_readme = (plain.out / "README.md").read_text(encoding="utf-8")
|
||||
assert "## Weiterverarbeitung" in plain_readme and "--mathml" not in plain_readme
|
||||
|
||||
|
||||
@pytest.mark.parametrize("tex,expected", [
|
||||
(r'\mbox{gr\"un}, \text{F\"{u}r}', r"\mbox{grün}, \text{Für}"),
|
||||
(r'\text{ f{\"u}r } j', r"\text{ f{ü}r } j"), # braces stay balanced
|
||||
(r"{\mathscr L}(A,b)={{\O }}", r"{\mathscr L}(A,b)={{\emptyset }}"),
|
||||
(r"M\cap N=\text{\O }", r"M\cap N=\emptyset"),
|
||||
(r"\Omega\neq\O", r"\Omega\neq\emptyset"),
|
||||
(r"\begin{array}{@{}l@{\qquad \quad }l@{}} a & b\end{array}", r"\begin{array}{ll} a & b\end{array}"),
|
||||
(r"\arraycolsep8pt\begin{array}{c@{\,}r} x\end{array}", r"\begin{array}{cr} x\end{array}"),
|
||||
(r"a & =&\displaystyle b, \\ & \vdots &\displaystyle \\ c", r"a & =&\displaystyle b, \\ & \vdots &\\ c"),
|
||||
(r"\frac{a}{b}+\{x\}", r"\frac{a}{b}+\{x\}"),
|
||||
])
|
||||
def test_publisher_tex_is_made_portable(tex, expected):
|
||||
"""Pandoc's texmath rejects \\", \\O, @{…} and \\arraycolsep (Springer alt texts, QA3-06)."""
|
||||
assert portable_tex(tex) == expected
|
||||
|
|
|
|||
Loading…
Reference in a new issue