{"id":13961515,"url":"https://github.com/crowdagger/epub-builder","last_synced_at":"2025-12-12T15:32:01.526Z","repository":{"id":15245066,"uuid":"77778919","full_name":"crowdagger/epub-builder","owner":"crowdagger","description":"A Rust library for generating EPUB files","archived":false,"fork":false,"pushed_at":"2025-02-17T01:27:00.000Z","size":387,"stargazers_count":143,"open_issues_count":8,"forks_count":44,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-03-28T08:08:40.079Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/crowdagger.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"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},"funding":{"github":"lise_henry"}},"created_at":"2017-01-01T12:58:36.000Z","updated_at":"2025-03-26T21:31:48.000Z","dependencies_parsed_at":"2023-02-10T17:00:27.586Z","dependency_job_id":"8a756eef-a425-4027-85c3-f7732fedbbe8","html_url":"https://github.com/crowdagger/epub-builder","commit_stats":{"total_commits":142,"total_committers":17,"mean_commits":8.352941176470589,"dds":"0.21126760563380287","last_synced_commit":"5c1f9068f88c3ae6d36149de10bdf7e6ce6333df"},"previous_names":["crowdagger/epub-builder","lise-henry/epub-builder"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crowdagger%2Fepub-builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crowdagger%2Fepub-builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crowdagger%2Fepub-builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crowdagger%2Fepub-builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crowdagger","download_url":"https://codeload.github.com/crowdagger/epub-builder/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247149502,"owners_count":20891954,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-08-08T17:01:12.802Z","updated_at":"2025-12-12T15:32:01.495Z","avatar_url":"https://github.com/crowdagger.png","language":"Rust","funding_links":["https://github.com/sponsors/lise_henry"],"categories":["Rust"],"sub_categories":[],"readme":"[See the full library documentation on Docs.rs.](https://docs.rs/epub-builder)\n\nA library to generate EPUB files.\n\nThe purpose for this library is to make it easier to generate EPUB files:\nit should take care of most of the boilerplate for you, leaving you only\nwith the task of filling the actual content.\n\n## Usage\n\nAdd this in your `Cargo.toml` file:\n\n```toml\n[dependencies]\nepub-builder = \"0.8\"\n```\n\n## Example\n```rust\nuse epub_builder::EpubBuilder;\nuse epub_builder::EpubContent;\nuse epub_builder::ReferenceType;\nuse epub_builder::Result;\nuse epub_builder::TocElement;\nuse epub_builder::ZipLibrary;\n\nuse std::io;\nuse std::io::Write;\n\n// Try to print Zip file to stdout\nfn run() -\u003e Result\u003c()\u003e {\n    env_logger::init();\n    // Some dummy content to fill our book\n    let dummy_content = r#\"\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n//! \u003chtml xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:epub=\"http://www.idpf.org/2007/ops\"\u003e\n\u003cbody\u003e\n\u003cp\u003eText of the page\u003c/p\u003e\n\u003c/body\u003e\n\u003c/html\u003e\"#;\n    let dummy_image = \"Not really a PNG image\";\n    let dummy_css = \"body { background-color: pink }\";\n\n    // Create a new EpubBuilder using the zip library\n    let mut builder = EpubBuilder::new(ZipLibrary::new()?)?;\n    // Set some metadata\n    builder\n        .metadata(\"author\", \"Joan Doe\")?\n        .metadata(\"title\", \"Dummy Book \u003cT\u003e\")?\n        // Set the stylesheet (create a \"stylesheet.css\" file in EPUB that is used by some generated files)\n        .stylesheet(dummy_css.as_bytes())?\n        // Add a image cover file\n        .add_cover_image(\"cover.png\", dummy_image.as_bytes(), \"image/png\")?\n        // Add a resource that is not part of the linear document structure\n        .add_resource(\"some_image.png\", dummy_image.as_bytes(), \"image/png\")?\n        // Add a cover page\n        .add_content(\n            EpubContent::new(\"cover.xhtml\", dummy_content.as_bytes())\n                .title(\"Cover\")\n                .reftype(ReferenceType::Cover),\n        )?\n        // Add a title page\n        .add_content(\n            EpubContent::new(\"title.xhtml\", dummy_content.as_bytes())\n                .title(\"Title \u003cT\u003e\")\n                .reftype(ReferenceType::TitlePage),\n        )?\n        // Add a chapter, mark it as beginning of the \"real content\"\n        .add_content(\n            EpubContent::new(\"chapter_1.xhtml\", dummy_content.as_bytes())\n                .title(\"Chapter 1 \u003cT\u003e\")\n                .reftype(ReferenceType::Text),\n        )?\n        // Add a second chapter; this one has more toc information about its internal structure\n        .add_content(\n            EpubContent::new(\"chapter_2.xhtml\", dummy_content.as_bytes())\n                .title(\"Chapter 2 \u003cT\u003e\")\n                .child(TocElement::new(\"chapter_2.xhtml#1\", \"Chapter 2, section 1\")),\n        )?\n        // Add a section. Since its level is set to 2, it will be attached to the previous chapter.\n        .add_content(\n            EpubContent::new(\"section.xhtml\", dummy_content.as_bytes())\n                .title(\"Chapter 2 \u003cT\u003e, section 2\")\n                .level(2),\n        )?\n        // Add a chapter without a title, which will thus not appear in the TOC.\n        .add_content(EpubContent::new(\"notes.xhtml\", dummy_content.as_bytes()))?\n        // Generate a toc inside of the document, that will be part of the linear structure.\n        .inline_toc();\n    // Finally, write the EPUB file to stdout\n    builder.generate(\u0026mut io::stdout())?; // generate into stout\n\n    log::debug!(\"dummy book generation is done\");\n    Ok(())\n}\n\nfn main() {\n    match run() {\n        Ok(_) =\u003e writeln!(\n            \u0026mut io::stderr(),\n            \"Successfully wrote epub document to stdout!\"\n        )\n        .unwrap(),\n        Err(err) =\u003e writeln!(\u0026mut io::stderr(), \"Error: {}\", err).unwrap(),\n    };\n}\n```\n\n## Features\n\n`epub-builder`'s aim is to make EPUB generation simpler. It takes care of zipping\nthe files and generate the following ones:\n\n* `mimetype`\n* `toc.ncx`\n* `nav.xhtml`\n* `manifest.xml`\n* `content.opf`\n* `com.apple.ibooks.display-options.xml`.\n\nIt also tries to make it easier to have a correct table of contents, and optionally\ngenerate an inline one in the document.\n\nSupported EPUB versions:\n\n* 2.0.1 (default)\n* 3.0.1\n\n### Missing features\n\nThere are various EPUB features that `epub-builder` doesn't handle. Particularly,\nthere are some metadata that could be better\nhandled (e.g. support multiple authors, multiple languages in the document and so on).\n\nThere are also various things that aren't in the scope of this library: it doesn't\nprovide a default CSS, templates for your XHTML content and so on. This is left to\nlibraries or applications using it.\n\n## Conditional compilation\n\nEPUB files are Zip files, so we need to zip. By default, this library provides\nwrappers around both the [Rust zip library](https://crates.io/crates/zip) and calls\nto the `zip` command that may (or may not) be installed on your system.\n\nIt is possible to disable the compilation (and the dependencies) of either of these\nwrappers, using `no-default-features`. (If you don't enable at least one of them this\nlibrary will be pretty useless).\n\n## License\n\nThis is free software, published under the [Mozilla Public License,\nversion 2.0](https://www.mozilla.org/en-US/MPL/2.0/).\n\n## ChangeLog\n\nSee the [ChangeLog file](ChangeLog.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrowdagger%2Fepub-builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrowdagger%2Fepub-builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrowdagger%2Fepub-builder/lists"}