feat: Abschnitt Weiterverarbeitung in der Buch-README (QA R7)
Die erzeugte README.md nennt den Merge-Befehl mit dem tatsächlichen Ausgabeordner und passende Pandoc-Befehle. Bei Büchern mit Formeln enthalten sie --mathml, ergänzt um einen Hinweis zur Formeldarstellung. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5f58589c2e
commit
bdc611eefc
3 changed files with 26 additions and 2 deletions
|
|
@ -249,7 +249,7 @@ def _convert(reader: EpubReader, input_path: Path, output_dir: Path, opts: Optio
|
|||
stats = _book_stats(all_chapters, media, renderer, diag)
|
||||
if opts.toc:
|
||||
files["README.md"] = writer.readme(md, chapters, endnotes, package.toc, resolver, stats, cover_out,
|
||||
package.version, input_path.name, opts.command)
|
||||
package.version, input_path.name, opts.command, str(output_dir))
|
||||
existing = {mf.output for mf in media.files.values()} if opts.extract_media else set()
|
||||
if opts.copy_original:
|
||||
existing.add(f"source/{input_path.name}")
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ def _nav_lines(entries: list[NavEntry], resolver: LinkResolver, depth: int = 0)
|
|||
|
||||
def readme(md: BookMetadata, chapters: list[Chapter], endnotes: Chapter | None, nav: list[NavEntry],
|
||||
resolver: LinkResolver, stats: dict[str, int], cover: str, epub_version: str, source_name: str,
|
||||
command: list[str]) -> str:
|
||||
command: list[str], output_dir: str = "OUTPUT_VERZEICHNIS") -> str:
|
||||
out = [f"# {md_escape(md.title or source_name)}"]
|
||||
if md.subtitle:
|
||||
out.append(f"*{md_escape(md.subtitle)}*")
|
||||
|
|
@ -128,6 +128,20 @@ def readme(md: BookMetadata, chapters: list[Chapter], endnotes: Chapter | None,
|
|||
out.append("\n".join(["| Kennzahl | Anzahl |", "| --- | ---: |"] + [f"| {lbl} | {stats.get(k, 0)} |" for k, lbl in labels]))
|
||||
out.append("Details: [conversion-report.json](conversion-report.json), "
|
||||
"[manifest.json](manifest.json), [Warnungen](diagnostics/warnings.md)")
|
||||
stem = source_name[:-5] if source_name.lower().endswith(".epub") else source_name
|
||||
math = " --mathml" if stats.get("formulas") else ""
|
||||
commands = [
|
||||
"# Gesamtdatei erzeugen (im selben Arbeitsverzeichnis wie die Konvertierung)",
|
||||
f"python3 epub2md_merge.py {shlex.quote(output_dir)}",
|
||||
"# danach in diesem Ordner:",
|
||||
f"pandoc {shlex.quote(stem + '.md')} --toc -s{math} -o {shlex.quote(stem + '.html')}",
|
||||
f"pandoc {shlex.quote(stem + '.md')} --toc -o {shlex.quote(stem + '.epub')}",
|
||||
]
|
||||
out.append("## Weiterverarbeitung")
|
||||
out.append("```bash\n" + "\n".join(commands) + "\n```")
|
||||
if math:
|
||||
out.append("Das Buch enthält Formeln: Für HTML `--mathml` (oder `--mathjax`) verwenden, sonst belässt "
|
||||
"Pandoc Matrizen und ähnliche Konstrukte als TeX-Text.")
|
||||
out.append("## Reproduktion")
|
||||
out.append("```bash\n" + " ".join(shlex.quote(c) for c in command) + "\n```")
|
||||
return "\n\n".join(out) + "\n"
|
||||
|
|
|
|||
|
|
@ -104,3 +104,13 @@ def test_svg_file_formula_is_reported_as_svg(convert):
|
|||
report = convert(math_book()).report
|
||||
origins = {f["origin"] for f in report["formulas"]["items"]}
|
||||
assert "svg" in origins
|
||||
|
||||
|
||||
def test_book_readme_suggests_mathml_for_pandoc_only_with_formulas(convert):
|
||||
run = convert(math_book())
|
||||
readme = (run.out / "README.md").read_text(encoding="utf-8")
|
||||
assert "## Weiterverarbeitung" in readme and "epub2md_merge.py" in readme
|
||||
assert "--mathml" in readme
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue