{"id":13477972,"url":"https://github.com/RosiePuddles/mdbook-compress","last_synced_at":"2025-03-27T07:30:35.087Z","repository":{"id":65189683,"uuid":"585091318","full_name":"RosiePuddles/mdbook-compress","owner":"RosiePuddles","description":"An mdBook single PDF generator using pure Rust and some Node.js","archived":false,"fork":false,"pushed_at":"2024-03-24T17:47:34.000Z","size":650,"stargazers_count":57,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-24T20:43:34.069Z","etag":null,"topics":["mdbook","pdf","pdf-generation","rust"],"latest_commit_sha":null,"homepage":"","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/RosiePuddles.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2023-01-04T09:47:32.000Z","updated_at":"2024-07-31T17:17:32.434Z","dependencies_parsed_at":"2024-07-31T17:17:26.103Z","dependency_job_id":null,"html_url":"https://github.com/RosiePuddles/mdbook-compress","commit_stats":{"total_commits":32,"total_committers":3,"mean_commits":"10.666666666666666","dds":0.21875,"last_synced_commit":"ae307ceb479208a7d1570bfef42ab4f91000b256"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RosiePuddles%2Fmdbook-compress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RosiePuddles%2Fmdbook-compress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RosiePuddles%2Fmdbook-compress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RosiePuddles%2Fmdbook-compress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RosiePuddles","download_url":"https://codeload.github.com/RosiePuddles/mdbook-compress/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245802138,"owners_count":20674593,"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":["mdbook","pdf","pdf-generation","rust"],"created_at":"2024-07-31T16:01:50.722Z","updated_at":"2025-03-27T07:30:34.694Z","avatar_url":"https://github.com/RosiePuddles.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# mdbook-compress\n\n\u003ca href=\"https://crates.io/crates/mdbook-compress\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/crates/v/mdbook-compress.svg\" alt=\"crate.io version badge\"\u003e\u003c/a\u003e\n\nAn [mdBook](https://github.com/rust-lang/mdBook) backend renderer to generate a single PDF file for a full book.\n\nThere are other similar projects, but most rely on chrome in some way to generate a PDF. This project only optionally\nrequires Node.js to be installed for code block syntax highlighting. If you don't want highlighting you can specify that with `highlight = \"none\"` in the config (or set `highlight = \"no-node\"` to use the built-in highlighter).\n\n## Usage\n\nTo use this backend, you'll need to add the following to your `book.toml` file:\n\n```toml\n[output.compress]\n```\n\nand install this project\n\n```bash\ncargo install mdbook-compress\n```\n\n\u003e If you want to keep the default HTML output, you'll also need to add in `[output.html]` if it's not already there\n\nThe resulting PDF will end up in `/book/compress/\u003cbook-title\u003e.pdf`. If you want to have a look at an example PDF, you can have a look at [this one](https://github.com/heyitsdoodler/hbml/blob/main/docs/book/compress/HBML%20Tutorial.pdf) which is the whole reason this project exists in the first place.\n\n### Config options\n\nThere are a few config options. They're all below and have a few comments to explain things. All the values are the default values.\n\n```toml\n[output.compress]\n# You can optionally specify a subtitle. If you don't the PDF\n# won't include a subtitle\nsubtitle = \"\"\n# If you want to use custom fonts, specify them here.\n# The value is a path relative to 'theme/fonts' under your book root\nfont.regular = \"\"\nfont.bold = \"\"\nfont.italic = \"\"\nfont.bold-italic = \"\"\nfont.monospace = \"\"\n# Font sizes. Any heading after H6 will use the H6 font size\n# All font sizes will become a u8\nfont_size.title = 12\nfont_size.h1 = 11\nfont_size.h2 = 10\n# H3 is also used for the subtitle\nfont_size.h3 = 8\nfont_size.h4 = 7\nfont_size.h5 = 6\nfont_size.h6 = 6\nfont_size.text = 5\n# Page configs\n# Page size. One of: A4, US letter, US legal (see below for custom sizes)\npage.size = \"A4\"\npage.landscape = false\n# Insert a page break between chapters (markdown files)\npage.new_pages = false\n# Line and margin spacing. Both measured in millimeters (f64 internally)\npage.spacing.line = 1.5\npage.spacing.heading = 2.0\npage.spacing.margin = [20.0, 20.0]\n# See the highlighting section below\nhighlight = \"all\"\n```\n\n### Custom page sizes\n\nIf you need a custom page size, you can give the width and height (`x` and `y`) dimensions in millimeters like this\n```toml\npage.size = { x = \"width\", y = \"height\" }\n```\n\n### Highlighting\n\nCode highlighting with highlight.js (what mdbook uses for the HTML) is pretty slow because it requires calling a node command. To fix this, this project uses syntect to do any highlighting. However, if you specify a custom highlight.js script in the _themes_ directory of your book, the code will use that.\n\nYou can change this though. The `highlight` value of the config can be one of:\n- `\"all\"` (default)\\\n  Use highlight.js file when given otherwise use syntect \n- `\"no-node\"`\\\n  Always use syntect even if a highlight.js file is given. In this case you can give `.sublime-syntax` files in your theme folder that will be used for highlighting. This way you can have a faster alternative to Node whilst keeping custom highlighting\n- `\"none\"`\\\n  Don't do any highlighting\n\nIt's worth noting that the highlighting colours for syntect and highlight.js are different because they're different programs\n\nIf you use syntect, you can provide a custom `theme.tmtheme` file in your theme directory. If this is a valid theme, that'll get used for highlighting. If not, the theme `base16-ocean.light` is used instead.\n\n## Why does it take so long?\n\nIf you're using a custom highlight.js file, this might make the renderer a bit slow. This is due to having to call Node.js for each code block. You should only use this if you require highlighting a language not supported by syntect.\n\n## Things still to add\n\n- Images (This is not possible with `genpdf`... at the moment)\n- Custom highlight.js theme application (Can have a custom syntect theme)\n\n## Dependencies\n\nIf you want to know what different dependencies are used for, here you go. The descriptions are all a bit general, because anything more specific would make the table too big.\n\n| Dependency                                                        | Version | Use                                                |\n|-------------------------------------------------------------------|---------|----------------------------------------------------|\n| [`serde`](https://crates.io/crates/serde/1.0.152)                 | 1.0.152 | Config struct deserialisation                      |\n| [`mdbook`](https://crates.io/crates/mdbook/0.4.25)                | 0.4.25  | Getting mdbook config and some error printing      |\n| [`genpdf`](https://crates.io/crates/genpdf/0.2.0)                 | 0.2.0   | PDF building (really nice library btw)             |\n| [`anyhow`](https://crates.io/crates/anyhow/1.0.68)                | 1.0.68  | Error handling                                     |\n| [`scraper`](https://crates.io/crates/scraper/0.14.0)              | 0.14.0  | Parsing HTML outputs                               |\n| [`ego-tree`](https://crates.io/crates/ego-tree/0.6.2)             | 0.6.2   | Required for function call types when highlighting |\n| [`pulldown-cmark`](https://crates.io/crates/pulldown-cmark/0.9.2) | 0.9.2   | Markdown parsing                                   |\n| [`syntect`](https://crates.io/crates/syntect/0.5.0)               | 0.5.0   | Built-in code highlighting                         |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRosiePuddles%2Fmdbook-compress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRosiePuddles%2Fmdbook-compress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRosiePuddles%2Fmdbook-compress/lists"}