Files
ai-agent-book/book-hu/make_full_epub.py
T
liqiang b119135836
Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
ai-agent-book 精选快照(<2MB 代码与文档,来自 github.com/bojieli/ai-agent-book)
2026-08-20 13:12:50 +00:00

80 lines
2.1 KiB
Python
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""Build and validate the complete Hungarian EPUB 3 edition."""
from pathlib import Path
import shutil
import subprocess
import sys
BOOK_DIR = Path(__file__).resolve().parent
ROOT = BOOK_DIR.parent
OUTPUT = BOOK_DIR / "AI-Agent-Book_HU.epub"
CHAPTERS = [
"introduction.md",
*(f"chapter{number}.md" for number in range(1, 11)),
"afterword.md",
"reference-answers.md",
]
def require(command: str) -> str:
path = shutil.which(command)
if path is None:
raise SystemExit(f"Hiba: a(z) {command} program szükséges az EPUB elkészítéséhez.")
return path
def main() -> None:
pandoc = require("pandoc")
missing = [name for name in CHAPTERS if not (BOOK_DIR / name).is_file()]
if missing:
raise SystemExit(f"Hiba: hiányzó forrásfájlok: {', '.join(missing)}")
command = [
pandoc,
*CHAPTERS,
"-o",
str(OUTPUT),
"--from=markdown+lists_without_preceding_blankline-raw_html",
"--to=epub3",
"--standalone",
"--toc",
"--toc-depth=3",
"--number-sections",
"--mathml",
"--split-level=1",
"--highlight-style=kate",
f"--lua-filter={ROOT / 'epub_external_links.lua'}",
f"--css={ROOT / 'epub.css'}",
"--metadata=title:AI Agent Tervezési elvek és gyakorlat",
"--metadata=author:Bojie Li",
"--metadata=lang:hu",
"--metadata=dir:ltr",
"--metadata=identifier:https://github.com/bojieli/ai-agent-book#hu",
]
subprocess.run(command, cwd=BOOK_DIR, check=True)
subprocess.run(
[
sys.executable,
str(ROOT / "flatten_epub_toc.py"),
str(OUTPUT),
"Címlap",
"Tartalomjegyzék",
],
check=True,
)
epubcheck = shutil.which("epubcheck")
if epubcheck:
subprocess.run([epubcheck, str(OUTPUT)], check=True)
else:
print("Figyelem: az epubcheck nem található; az EPUB-validáció kimaradt.")
print(f"Elkészült: {OUTPUT} ({OUTPUT.stat().st_size / 1024 / 1024:.1f} MiB)")
if __name__ == "__main__":
main()