{"id":50311739,"url":"https://github.com/maxyotka/book-converter","last_synced_at":"2026-05-28T21:30:46.638Z","repository":{"id":352070399,"uuid":"1209811460","full_name":"maxyotka/book-converter","owner":"maxyotka","description":"FB2 → PDF with book-grade Russian/English typography, built on Typst · Конвертер FB2 в PDF с книжной типографикой","archived":false,"fork":false,"pushed_at":"2026-04-17T17:48:37.000Z","size":1473,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-17T19:33:39.654Z","etag":null,"topics":["cli","ebook-converter","fb2","pdf","python","russian-typography","typography","typst"],"latest_commit_sha":null,"homepage":"https://github.com/maxyotka/book-converter","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maxyotka.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-13T20:02:16.000Z","updated_at":"2026-04-17T17:48:41.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/maxyotka/book-converter","commit_stats":null,"previous_names":["maxyotka/book-converter"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/maxyotka/book-converter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxyotka%2Fbook-converter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxyotka%2Fbook-converter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxyotka%2Fbook-converter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxyotka%2Fbook-converter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxyotka","download_url":"https://codeload.github.com/maxyotka/book-converter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxyotka%2Fbook-converter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33627934,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-28T02:00:06.440Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","ebook-converter","fb2","pdf","python","russian-typography","typography","typst"],"created_at":"2026-05-28T21:30:45.893Z","updated_at":"2026-05-28T21:30:46.618Z","avatar_url":"https://github.com/maxyotka.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# book-converter\n\n**English** · [Русский](README.ru.md)\n\n[![CI](https://github.com/maxyotka/book-converter/actions/workflows/ci.yml/badge.svg)](https://github.com/maxyotka/book-converter/actions/workflows/ci.yml)\n[![Python](https://img.shields.io/badge/python-3.11%2B-blue.svg)](https://www.python.org)\n[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)\n[![Version](https://img.shields.io/badge/version-1.0.0-brightgreen.svg)](CHANGELOG.md)\n\nUniversal **FB2 → beautiful PDF** converter with book-grade Russian / English\ntypography, built on [Typst](https://typst.app/).\n\nParses [FB2](http://www.fictionbook.org/) (including `.fb2.zip`), builds a\ntyped Document IR, applies pluggable typography (Russian, English,\npassthrough), renders a Typst source via the `classic.typ` template, and\ncompiles the PDF.\n\n## Preview\n\nSample output from a short Pushkin collection — title page, prose with\nepigraph and footnote reference, a poem with stanzas:\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/screenshots/01-title.png\" width=\"280\" alt=\"Title page\" /\u003e\n  \u003cimg src=\"docs/screenshots/02-prose-epigraph.png\" width=\"280\" alt=\"Prose with epigraph\" /\u003e\n  \u003cimg src=\"docs/screenshots/03-poem.png\" width=\"280\" alt=\"Poem layout\" /\u003e\n\u003c/p\u003e\n\n---\n\n## Highlights\n\n- **Full FB2 coverage** — sections nested 5+ levels, `\u003cpart\u003e`, `\u003csubtitle\u003e`,\n  `\u003cepigraph\u003e`, `\u003ccite\u003e`, `\u003cpoem\u003e`, `\u003ctable\u003e` (flattened with inline\n  formatting preserved), `\u003cimage\u003e` / `\u003cbinary\u003e`, footnotes\n  (`\u003ca type=\"note\"\u003e` + `\u003cbody name=\"notes\"\u003e`), and every inline tag.\n- **Pluggable typography** — Russian (Russian quotes, non-breaking spaces\n  after short prepositions, em-dashes), English (smart quotes, `--` →\n  em-dash), passthrough for the rest. Adding a language = one module + one\n  registry line.\n- **Layered config** — FB2 metadata → `\u003cbook_stem\u003e.toml` → CLI flags.\n- **Two CLI modes** — single-shot (`book-converter \u003cinput\u003e`) and batch\n  (`book-converter build [dir]`) with per-book error isolation.\n- **Hardened parser** — `defusedxml` against XXE, path-traversal guards,\n  defensive handling of empty sections and malformed footnotes.\n- **Localized template** — Contents / Source / Series / typeset notice\n  strings are pulled from an `l10n` dict keyed by the book's language.\n\n## Requirements\n\n- Python ≥ 3.11 and [uv](https://docs.astral.sh/uv/)\n- [Typst CLI](https://typst.app/) ≥ 0.12 on `PATH`\n- Fonts in `templates/fonts/` — PT Serif ships under the SIL OFL 1.1\n\n## Install\n\n```bash\ngit clone https://github.com/maxyotka/book-converter.git\ncd book-converter\nuv sync\n```\n\n## Quick start\n\n```bash\n# single shot\nuv run book-converter books/one.fb2.zip                    # → build/one.pdf\n\n# batch — every .fb2 / .fb2.zip under books/\nuv run book-converter build books --out-dir build\n\n# convenience wrapper\n./build.sh\n```\n\n## Per-book overrides\n\nDrop `\u003cstem\u003e.toml` next to `\u003cstem\u003e.fb2.zip`:\n\n```toml\ntitle = \"Correct Title\"\nauthor = \"Correct Author\"\nlang = \"en\"\npublisher = \"ACME\"\nyear = \"2026\"\nisbn = \"978-...\"\nfonts = [\"EB Garamond\", \"Liberation Serif\"]\n```\n\nFlags (`--title`, `--author`, `--lang`, `--font`, `--publisher`, `--year`,\n`--isbn`, `--config`) override TOML, which overrides FB2 metadata. Empty\npublisher / year / ISBN are skipped on the copyright page.\n\n## Architecture\n\n```\nsrc/book_converter/\n  cli.py              single-shot + batch dispatch\n  config.py           BookConfig: FB2 ↔ TOML ↔ CLI merge\n  batch.py            books/ scan with per-book error isolation\n  ir.py               Pydantic v2 Document IR\n  fb2/\n    loader.py         .fb2 / .fb2.zip → defusedxml tree\n    parser.py         ET.Element → Document IR\n  typography/\n    base.py           Protocol + Passthrough + flatten/rebuild helpers\n    russian.py        RussianTypography\n    english.py        EnglishTypography\n    registry.py       lang-code → plugin, fallback Passthrough\n  render/\n    typst.py          Document IR → Typst source + binary assets\n    escape.py         _typst_escape / _typst_string\ntemplates/\n  classic.typ         book template (part/chapter/subsection/epigraph/poem)\n  fonts/              PT Serif (OFL)\nbooks/                input FB2 (gitignored)\nbuild/                output PDF (gitignored)\ntests/                pytest suite + fixtures\n```\n\n## Tests\n\n```bash\nuv run pytest          # 90 fast tests (parser, IR, render, typography)\nuv run pytest -m slow  # + integration compile via typst CLI\n```\n\nIntegration smoke (`tests/test_integration_smoke.py`) expects two FB2 files\nin `books/`; both are gitignored, so drop them in yourself — slow tests skip\nwhen they are absent.\n\n## Adding a language\n\n1. Create `src/book_converter/typography/\u003clang\u003e.py` with a class implementing\n   `TypographyPlugin.transform_paragraph(inlines) -\u003e inlines`.\n2. Register it in `typography/registry.py` by its ISO 639-1 code.\n3. Mirror `tests/test_typography_russian.py` for coverage.\n4. Add localized strings to the `l10n` dict in `templates/classic.typ` if\n   needed (Contents, Source, Series, …).\n\n## Troubleshooting\n\n- **`unknown font family: pt serif`** — pass `--font-path templates/fonts`\n  to Typst, or use the `book-converter` CLI which wires it up automatically.\n- **`program not found: book-converter`** — re-run `uv sync` after pulling;\n  the entry point is installed by the Hatchling build backend.\n- **Slow tests skip** — expected unless you drop the two referenced FB2\n  files into `books/`.\n\n## Contributing\n\nPRs welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for dev setup, commit\nstyle, and guidance on adding new languages or template variants.\n\n## License\n\nSource code: [MIT](LICENSE).\n\nBundled PT Serif fonts under `templates/fonts/`: SIL Open Font License 1.1 —\nsee [`templates/fonts/OFL.txt`](templates/fonts/OFL.txt) and\n[`templates/fonts/README.md`](templates/fonts/README.md) for full\nattribution.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxyotka%2Fbook-converter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxyotka%2Fbook-converter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxyotka%2Fbook-converter/lists"}