{"_id":"@brahim.ariani/md2pdf-cli","_rev":"5-826ef1a2beed74a33518ff6d6dbdc21b","name":"@brahim.ariani/md2pdf-cli","dist-tags":{"latest":"1.2.2"},"versions":{"1.0.0":{"name":"@brahim.ariani/md2pdf-cli","version":"1.0.0","keywords":["markdown","pdf","md-to-pdf","puppeteer","marked","katex","math","latex","equations","cli","converter"],"author":{"name":"Brahim Ariani","email":"brahim.ariani.inc@gmail.com"},"license":"MIT","_id":"@brahim.ariani/md2pdf-cli@1.0.0","maintainers":[{"name":"brahim.ariani","email":"brahim.ariani.inc@gmail.com"}],"homepage":"https://github.com/brahimariani/md2pdf-cli#readme","bugs":{"url":"https://github.com/brahimariani/md2pdf-cli/issues"},"bin":{"md2pdf":"bin/md2pdf.js"},"dist":{"shasum":"250ed256041b9199d4583e639d78c88746320d25","tarball":"https://registry.npmjs.org/@brahim.ariani/md2pdf-cli/-/md2pdf-cli-1.0.0.tgz","fileCount":6,"integrity":"sha512-vP9sIgBi/4RTdYNuBJpuy5FfiExYrZHaknaiX9wYtr5g1ZFljs5653yj3938gNrRoHuL14uWH9xRa3boOUubzA==","signatures":[{"sig":"MEUCIQCBGZ8toTB6LBB9fBpGc1hkJOSSVKg9dI6CDEwgzC1e8QIgBJ7gida8xwakeF6HYJva+gWAkTfhcxuA1yeloc7Fdlk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":17706},"main":"lib/index.js","engines":{"node":">=18"},"gitHead":"0f9e1e29b61d679d99de05f9c21786853f779e3a","scripts":{"test":"node test/smoke.js"},"_npmUser":{"name":"brahim.ariani","email":"brahim.ariani.inc@gmail.com"},"repository":{"url":"git+https://github.com/brahimariani/md2pdf-cli.git","type":"git"},"_npmVersion":"11.6.2","description":"Convert Markdown files to beautifully styled PDFs using marked and puppeteer.","directories":{},"_nodeVersion":"24.12.0","dependencies":{"katex":"^0.16.9","marked":"^12.0.0","puppeteer":"^24.15.0","marked-katex-extension":"^5.0.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/md2pdf-cli_1.0.0_1779587857219_0.8278548235566101","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@brahim.ariani/md2pdf-cli","version":"1.1.0","keywords":["markdown","pdf","md-to-pdf","puppeteer","marked","katex","math","latex","equations","cli","converter"],"author":{"name":"Brahim Ariani","email":"brahim.ariani.inc@gmail.com"},"license":"MIT","_id":"@brahim.ariani/md2pdf-cli@1.1.0","maintainers":[{"name":"brahim.ariani","email":"brahim.ariani.inc@gmail.com"}],"homepage":"https://github.com/brahimariani/md2pdf-cli#readme","bugs":{"url":"https://github.com/brahimariani/md2pdf-cli/issues"},"bin":{"md2pdf":"bin/md2pdf.js"},"dist":{"shasum":"bde6205a02fc4a84ad2d3bd5ace775c977b1e152","tarball":"https://registry.npmjs.org/@brahim.ariani/md2pdf-cli/-/md2pdf-cli-1.1.0.tgz","fileCount":10,"integrity":"sha512-WodYLbEZWsVcHHTYUd9GBqXQ/AzXerC7YzNExx7f6ztTn68etW2D/15AhmAc/5zFJDSt1NOLW/mhUY/2et+N3Q==","signatures":[{"sig":"MEUCIF/RI+2r8URSy2kaDaTTtOmN3zFfbxflwj1JI5aSvoe1AiEAoyQ2LjNOeeRQRVsu9//MB0VbXrwJIteJW8mG7Pyu/3M=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":33913},"main":"lib/index.js","engines":{"node":">=18"},"gitHead":"8f86ab0e9c46247a0c45dc8b5af95650a423b0d5","scripts":{"test":"node test/sanitize.js && node test/toc.js && node test/highlight.js && node test/frontmatter.js && node test/smoke.js","test:toc":"node test/toc.js","test:sanitize":"node test/sanitize.js","test:highlight":"node test/highlight.js","test:frontmatter":"node test/frontmatter.js"},"_npmUser":{"name":"brahim.ariani","email":"brahim.ariani.inc@gmail.com"},"repository":{"url":"git+https://github.com/brahimariani/md2pdf-cli.git","type":"git"},"_npmVersion":"11.6.2","description":"Convert Markdown files to beautifully styled PDFs using marked and puppeteer.","directories":{},"_nodeVersion":"24.12.0","dependencies":{"jsdom":"^29.1.1","katex":"^0.16.9","shiki":"^4.1.0","marked":"^12.0.0","dompurify":"^3.4.7","puppeteer":"^24.15.0","gray-matter":"^4.0.3","marked-katex-extension":"^5.0.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/md2pdf-cli_1.1.0_1780189588982_0.08392741620928357","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"@brahim.ariani/md2pdf-cli","version":"1.2.0","keywords":["markdown","pdf","md-to-pdf","puppeteer","marked","katex","math","latex","equations","cli","converter"],"author":{"name":"Brahim Ariani","email":"brahim.ariani.inc@gmail.com"},"license":"MIT","_id":"@brahim.ariani/md2pdf-cli@1.2.0","maintainers":[{"name":"brahim.ariani","email":"brahim.ariani.inc@gmail.com"}],"homepage":"https://github.com/brahimariani/md2pdf-cli#readme","bugs":{"url":"https://github.com/brahimariani/md2pdf-cli/issues"},"bin":{"md2pdf":"bin/md2pdf.js"},"dist":{"shasum":"8f5f83237a623d8f3d484520bbcec656a0322d68","tarball":"https://registry.npmjs.org/@brahim.ariani/md2pdf-cli/-/md2pdf-cli-1.2.0.tgz","fileCount":11,"integrity":"sha512-LH9r0Nu0llj7xpsmiMDv8vVtn6VZYe5AeADfDboGPn2gjYp/FAGMJwrVc41J2ykS8DRIdE/5ee/BD1EMHttVpg==","signatures":[{"sig":"MEQCIDs5zTj8sfK9HOqfya0dZsVHelfg+UAR9FuT2GjhmbcuAiB/SZTcTb8wrBtIhzm4Sxlc3js48D2UruNcgxEdb6t7CA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":43431},"main":"lib/index.js","engines":{"node":">=18"},"gitHead":"f7130c029ec0149d3a4d09afe7344df132d52328","scripts":{"test":"node test/sanitize.js && node test/toc.js && node test/highlight.js && node test/frontmatter.js && node test/themes.js && node test/mermaid.js && node test/smoke.js","test:toc":"node test/toc.js","test:themes":"node test/themes.js","test:mermaid":"node test/mermaid.js","test:sanitize":"node test/sanitize.js","test:highlight":"node test/highlight.js","test:frontmatter":"node test/frontmatter.js"},"_npmUser":{"name":"brahim.ariani","email":"brahim.ariani.inc@gmail.com"},"repository":{"url":"git+https://github.com/brahimariani/md2pdf-cli.git","type":"git"},"_npmVersion":"11.6.2","description":"Convert Markdown files to beautifully styled PDFs using marked and puppeteer.","directories":{},"_nodeVersion":"24.12.0","dependencies":{"jsdom":"^29.1.1","katex":"^0.16.9","shiki":"^4.1.0","marked":"^12.0.0","mermaid":"^11.15.0","dompurify":"^3.4.7","puppeteer":"^24.15.0","gray-matter":"^4.0.3","marked-katex-extension":"^5.0.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/md2pdf-cli_1.2.0_1780191617865_0.050233942240791585","host":"s3://npm-registry-packages-npm-production"}},"1.2.1":{"name":"@brahim.ariani/md2pdf-cli","version":"1.2.1","keywords":["markdown","pdf","md-to-pdf","puppeteer","marked","katex","math","latex","equations","cli","converter"],"author":{"name":"Brahim Ariani","email":"brahim.ariani.inc@gmail.com"},"license":"MIT","_id":"@brahim.ariani/md2pdf-cli@1.2.1","maintainers":[{"name":"brahim.ariani","email":"brahim.ariani.inc@gmail.com"}],"homepage":"https://github.com/brahimariani/md2pdf-cli#readme","bugs":{"url":"https://github.com/brahimariani/md2pdf-cli/issues"},"bin":{"md2pdf":"bin/md2pdf.js"},"dist":{"shasum":"acf13932df01a9dc4d676faa0fea667ea170199b","tarball":"https://registry.npmjs.org/@brahim.ariani/md2pdf-cli/-/md2pdf-cli-1.2.1.tgz","fileCount":11,"integrity":"sha512-p3H1SnqyBczKvF/MCS1IonYhL5S9WTyNMvO1j/v69R9vwLhueVJxKnPkq/ZLYcc8M3sq34CgzqduEzDKwAXKDg==","signatures":[{"sig":"MEYCIQDOmqr4pyK324lIqY1VDz+laQ7YZ8Nzh8j9DLRR90lvSAIhAPc8PSbpIl0X1DZCLvH9Pg/JVDx8+5cx4bcsPJza80zE","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":45704},"main":"lib/index.js","engines":{"node":">=18"},"gitHead":"f7130c029ec0149d3a4d09afe7344df132d52328","scripts":{"test":"node test/sanitize.js && node test/toc.js && node test/highlight.js && node test/frontmatter.js && node test/themes.js && node test/mermaid.js && node test/smoke.js","test:toc":"node test/toc.js","test:themes":"node test/themes.js","test:mermaid":"node test/mermaid.js","test:sanitize":"node test/sanitize.js","test:highlight":"node test/highlight.js","test:frontmatter":"node test/frontmatter.js"},"_npmUser":{"name":"brahim.ariani","email":"brahim.ariani.inc@gmail.com"},"repository":{"url":"git+https://github.com/brahimariani/md2pdf-cli.git","type":"git"},"_npmVersion":"11.6.2","description":"Convert Markdown files to beautifully styled PDFs using marked and puppeteer.","directories":{},"_nodeVersion":"24.12.0","dependencies":{"jsdom":"^29.1.1","katex":"^0.16.9","shiki":"^4.1.0","marked":"^12.0.0","mermaid":"^11.15.0","dompurify":"^3.4.7","puppeteer":"^24.15.0","gray-matter":"^4.0.3","marked-katex-extension":"^5.0.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/md2pdf-cli_1.2.1_1780194787462_0.4150443193448894","host":"s3://npm-registry-packages-npm-production"}},"1.2.2":{"name":"@brahim.ariani/md2pdf-cli","version":"1.2.2","description":"Convert Markdown files to beautifully styled PDFs using marked and puppeteer.","keywords":["markdown","pdf","md-to-pdf","puppeteer","marked","katex","math","latex","equations","cli","converter"],"license":"MIT","author":{"name":"Brahim Ariani","email":"brahim.ariani.inc@gmail.com"},"main":"lib/index.js","bin":{"md2pdf":"bin/md2pdf.js"},"engines":{"node":">=18"},"scripts":{"test":"node test/sanitize.js && node test/toc.js && node test/highlight.js && node test/frontmatter.js && node test/themes.js && node test/mermaid.js && node test/smoke.js","test:sanitize":"node test/sanitize.js","test:toc":"node test/toc.js","test:highlight":"node test/highlight.js","test:frontmatter":"node test/frontmatter.js","test:themes":"node test/themes.js","test:mermaid":"node test/mermaid.js"},"dependencies":{"dompurify":"^3.4.7","gray-matter":"^4.0.3","jsdom":"^29.1.1","katex":"^0.16.9","marked":"^12.0.0","marked-katex-extension":"^5.0.0","mermaid":"^11.15.0","pdf-lib":"^1.17.1","puppeteer":"^24.15.0","shiki":"^4.1.0"},"repository":{"type":"git","url":"git+https://github.com/brahimariani/md2pdf-cli.git"},"bugs":{"url":"https://github.com/brahimariani/md2pdf-cli/issues"},"homepage":"https://github.com/brahimariani/md2pdf-cli#readme","_id":"@brahim.ariani/md2pdf-cli@1.2.2","gitHead":"65572e1e64d5f5b9ae4e8fadf70b5f3651142be2","_nodeVersion":"20.20.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-B9PQm5xkGRq8BAKPXcbMPfjYBG1qqZ8qdl3j64Oa1UCpKmA9/dDa9lHGGk6lUfsAEI88kQghwHkKPylhBhesIA==","shasum":"7d6b71bfa692b64c738f0a3cb7a190375fb54590","tarball":"https://registry.npmjs.org/@brahim.ariani/md2pdf-cli/-/md2pdf-cli-1.2.2.tgz","fileCount":11,"unpackedSize":60513,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCqmqMIKBs93bNFRfZ0XicxbFeL1uM0h3BNCk7JOxDG4gIhAP+ovMrj+Uzavyf0chn8dkPxYFnMmVDeZ/t6Yrngr6E5"}]},"_npmUser":{"name":"brahim.ariani","email":"brahim.ariani.inc@gmail.com"},"directories":{},"maintainers":[{"name":"brahim.ariani","email":"brahim.ariani.inc@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/md2pdf-cli_1.2.2_1780653525662_0.052513288076843745"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-24T01:57:37.070Z","modified":"2026-06-05T09:58:45.884Z","1.0.0":"2026-05-24T01:57:37.409Z","1.1.0":"2026-05-31T01:06:29.125Z","1.2.0":"2026-05-31T01:40:17.985Z","1.2.1":"2026-05-31T02:33:07.592Z","1.2.2":"2026-06-05T09:58:45.794Z"},"bugs":{"url":"https://github.com/brahimariani/md2pdf-cli/issues"},"author":{"name":"Brahim Ariani","email":"brahim.ariani.inc@gmail.com"},"license":"MIT","homepage":"https://github.com/brahimariani/md2pdf-cli#readme","keywords":["markdown","pdf","md-to-pdf","puppeteer","marked","katex","math","latex","equations","cli","converter"],"repository":{"type":"git","url":"git+https://github.com/brahimariani/md2pdf-cli.git"},"description":"Convert Markdown files to beautifully styled PDFs using marked and puppeteer.","maintainers":[{"name":"brahim.ariani","email":"brahim.ariani.inc@gmail.com"}],"readme":"# md2pdf-cli\n\nConvert Markdown files into beautifully styled PDFs using [marked](https://github.com/markedjs/marked), [KaTeX](https://katex.org/) and [puppeteer](https://github.com/puppeteer/puppeteer).\n\nGitHub-flavored Markdown, tables, code blocks, blockquotes, images **and LaTeX math equations** (`$inline$` and `$$display$$`) are all rendered with sane, print-friendly defaults — page numbers in the footer, A4 by default, justified body text, and zebra-striped tables.\n\n## Install\n\n```bash\nnpm install -g @brahim.ariani/md2pdf-cli\n```\n\nOr use it directly in a project:\n\n```bash\nnpm install brahim.ariani/md2pdf-cli\n```\n\n## CLI\n\n```bash\nmd2pdf <input.md> [output.pdf] [options]\n```\n\nIf `output.pdf` is omitted, the output filename is derived from the input (e.g. `research.md` → `research.pdf`).\n\n### Options\n\n| Flag                   | Description                                                |\n|------------------------|------------------------------------------------------------|\n| `--title <text>`       | Document title (defaults to the input filename)            |\n| `--css <file>`         | Path to a custom CSS file (replaces the default styles)    |\n| `--theme <name>`       | Built-in theme: `default`, `academic`, `latex`             |\n| `--format <size>`      | Page format: `A4`, `Letter`, `Legal`, ... Default: `A4`    |\n| `--toc`                | Prepend an auto-generated table of contents                |\n| `--toc-depth <n>`      | Deepest heading level included in the TOC. Default: `3`    |\n| `--toc-title <text>`   | TOC heading text. Default: `Contents`                      |\n| `--highlight`          | Syntax-highlight fenced code blocks with Shiki             |\n| `--code-theme <name>`  | Shiki theme for code blocks. Default: `github-light`       |\n| `--mermaid`            | Render ` ```mermaid ` code blocks as diagrams              |\n| `--mermaid-theme <t>`  | Mermaid theme: `base`, `default`, `neutral`, `dark`, `forest`. Default: `base` |\n| `--cover`              | Render a title page from YAML front matter                 |\n| `--no-cover`           | Never render a title page (overrides front matter)         |\n| `--header-logos`       | Repeat the cover logos in every page header (skips the cover) |\n| `--no-page-numbers`    | Disable the page-number footer                             |\n| `--no-math`            | Disable KaTeX equation rendering                           |\n| `--no-sanitize`        | Disable HTML sanitization (**unsafe**, see below)          |\n| `--keep-html`          | Keep the intermediate `.tmp.html` file for debugging       |\n| `-h`, `--help`         | Show usage                                                 |\n\n### Examples\n\n```bash\nmd2pdf research.md\nmd2pdf research.md out/research.pdf\nmd2pdf report.md report.pdf --title \"Quarterly Report\" --css theme.css\nmd2pdf notes.md notes.pdf --format Letter --no-page-numbers\nmd2pdf book.md book.pdf --toc --toc-depth 2 --toc-title \"Table of Contents\"\nmd2pdf code.md code.pdf --highlight --code-theme github-dark\nmd2pdf paper.md paper.pdf --cover --toc\nmd2pdf thesis.md thesis.pdf --theme academic --toc\nmd2pdf paper.md paper.pdf            # equations rendered by default\nmd2pdf draft.md draft.pdf --no-math  # treat $...$ as literal text\n```\n\n### Math / LaTeX equations\n\nInline math uses single dollars, display math uses double dollars:\n\n```markdown\nThe famous identity is $e^{i\\pi} + 1 = 0$.\n\n$$\n\\int_{-\\infty}^{\\infty} e^{-x^2}\\,dx = \\sqrt{\\pi}\n$$\n```\n\nEquations are rendered server-side with KaTeX, so the PDF is self-contained and prints identically on any machine.\n\n## Table of contents\n\nPass `--toc` to prepend an auto-generated, clickable table of contents built\nfrom the document headings. Each heading also receives a stable `id` slug, so\nthe TOC links resolve as in-document bookmarks.\n\n```bash\nmd2pdf report.md report.pdf --toc                       # depth 3 (default)\nmd2pdf report.md report.pdf --toc --toc-depth 2         # only h1 + h2\nmd2pdf report.md report.pdf --toc --toc-title \"Sommaire\"\n```\n\nThe TOC is placed on its own page (it ends with a page break). You can fully\nrestyle it via `--css` by targeting `nav.toc`, `nav.toc .toc-title`, etc.\n\n## Themes\n\nPick a built-in look with `--theme`:\n\n| Theme      | Description                                                          |\n|------------|----------------------------------------------------------------------|\n| `default`  | Clean sans-serif, navy headings, zebra tables (the original look)    |\n| `academic` | Georgia serif, justified & indented paragraphs, centered title       |\n| `latex`    | Classic LaTeX `article` look: Computer Modern serif, booktabs tables |\n\n```bash\nmd2pdf report.md report.pdf --theme academic\nmd2pdf thesis.md thesis.pdf --theme latex --toc\nmd2pdf design.md design.pdf --mermaid --highlight --cover\n```\n\nEvery theme keeps the same structural rules (math, TOC, cover page, tables,\npage-break safety) and only swaps typography and colors. An unknown theme name\nfalls back to `default` with a warning. For full control, `--css` still\nreplaces all styles entirely.\n\n## Front matter & cover page\n\nMarkdown files may start with a YAML front-matter block. It is parsed, stripped\nfrom the body, and used to enrich the document:\n\n```markdown\n---\ntitle: Quarterly Report\nsubtitle: Q2 2026 Financial Overview\nauthor:\n  - Brahim Ariani\n  - Finance Team\ndate: 2026-05-31\nversion: 2.1.0\ncover: true\n---\n\n# Introduction\n...\n```\n\n- `title` becomes the HTML document title (a `--title` flag still wins).\n- With `--cover` (or `cover: true` in the front matter), a dedicated **title\n  page** is rendered from `title`, `subtitle`, `version`, `author`/`authors` and\n  `date`, followed by a page break. `--no-cover` disables it even if the front\n  matter requests one.\n\n```bash\nmd2pdf paper.md paper.pdf --cover\nmd2pdf paper.md paper.pdf --cover --toc   # title page, then a TOC page\n```\n\n### Cover layout & images\n\nFor full control over the cover layout, design and image placement, use the\n**object form** of `cover` instead of `cover: true`:\n\n```markdown\n---\ntitle: Quarterly Report\nsubtitle: Q2 2026 Financial Overview\nversion: 2.1.0\nauthor: Brahim Ariani\ndate: 2026-05-31\ncover:\n  logos:                     # up to 3 logos, spread across the top\n    - assets/logo-left.svg\n    - assets/logo-right.svg\n  image: assets/hero.png     # illustration shown above the title\n  align: center              # vertical placement: top | center | bottom | between\n  # background: true         # use `image` as a full-bleed background instead\n---\n```\n\nCover-specific keys (all optional):\n\n| Key          | Type                | Effect                                                                  |\n| ------------ | ------------------- | ----------------------------------------------------------------------- |\n| `enabled`    | `boolean`           | Set `false` to keep the config but skip the cover                       |\n| `logo`       | `string`            | A single logo (centered above everything else)                          |\n| `logos`      | `string[]`          | Up to **3** logos laid out as a top row with even spacing               |\n| `image`      | `string`            | Path or URL to a cover illustration shown between the logos and title   |\n| `background` | `boolean`           | Render `image` as a full-bleed background layer behind the text         |\n| `align`      | `string`            | Vertical placement: `top`, `center` (default), `bottom` or `between`    |\n| `version`    | `string`            | Version line (also accepted as a top-level `version:` key)              |\n\nImage paths are resolved relative to the Markdown file; remote (`https://`) and\n`data:` URLs are used as-is. A single `logo` (or one entry in `logos`) is\ncentered; two or three logos are spread across the top with `space-between`.\n\n### Logos in the page header\n\nPass `--header-logos` to repeat the cover logos at the top of **every page**.\nThe logos are inlined as data URIs (so they reliably render inside the header)\nand aligned with the body margins.\n\n```bash\nmd2pdf paper.md paper.pdf --cover --header-logos\n```\n\nWhen a cover page is present alongside a header/footer, the cover is rendered on\nits own and merged ahead of the body, so its **header and footer are fully\nsuppressed**: the cover carries **no page number** and no header logos. Page\nnumbering and the header logos start on the first content page at `1`.\n\nRestyle the cover via `--css` by targeting `section.cover` (and its\n`.cover-align-*` / `.cover-bg` modifiers), `.cover-content`, `.cover-logos`,\n`.cover-logo`, `.cover-image`, `.cover-bg-image`, `.cover-title`,\n`.cover-subtitle`, `.cover-version`, `.cover-author`, `.cover-date`.\n\n## Syntax highlighting\n\nPass `--highlight` to colorize fenced code blocks with\n[Shiki](https://shiki.style/) (the same engine that powers VS Code). Colors are\ninlined into the HTML, so the PDF stays self-contained and prints identically\neverywhere — no client-side JavaScript or web fonts required.\n\n```bash\nmd2pdf code.md code.pdf --highlight\nmd2pdf code.md code.pdf --highlight --code-theme github-dark\n```\n\nOnly the languages actually used in the document are loaded, keeping conversion\nfast. Use any Shiki theme name (e.g. `github-light`, `github-dark`, `nord`,\n`dracula`, `min-light`). Unknown languages fall back to a plain, escaped code\nblock, and an unknown theme falls back to `github-light`.\n\n## Mermaid diagrams\n\nWith `--mermaid`, fenced code blocks tagged `mermaid` are rendered into vector\ndiagrams with [Mermaid](https://mermaid.js.org/) (flowcharts, sequence diagrams,\nGantt charts, etc.):\n\n````markdown\n```mermaid\nflowchart LR\n  A[Start] --> B{OK?}\n  B -- Yes --> C[Ship]\n  B -- No  --> A\n```\n````\n\n```bash\nmd2pdf design.md design.pdf --mermaid\nmd2pdf design.md design.pdf --mermaid --mermaid-theme neutral\n```\n\nDiagrams are rendered inside the same headless Chromium used for printing, so\nthe resulting SVG is embedded directly in the PDF — no network access or extra\ntooling required. Mermaid runs with `securityLevel: 'strict'`, and a diagram\nwith invalid syntax is skipped rather than aborting the whole conversion.\nWithout `--mermaid`, ` ```mermaid ` blocks are left as plain code.\n\n## Security / HTML sanitization\n\nMarkdown allows raw HTML, which means an untrusted `.md` file can embed\n`<script>`, `<iframe>`, or event-handler attributes (`onerror`, `onclick`, ...).\nBecause the document is rendered through a real browser (Chromium) before being\nprinted, such payloads would otherwise execute.\n\nTo prevent this, the HTML produced from your Markdown is **sanitized by default**\nwith [DOMPurify](https://github.com/cure53/DOMPurify) before it ever reaches the\nbrowser. Scripts, event handlers, and dangerous URIs (`javascript:`, ...) are\nstripped, while legitimate content — headings, tables, code blocks, images,\nlinks and KaTeX/MathML/SVG math — is preserved.\n\nIf you fully trust the input and need to keep raw HTML (custom `<script>`,\nembeds, etc.), you can opt out:\n\n```bash\nmd2pdf trusted.md trusted.pdf --no-sanitize\n```\n\n```js\nawait convert({ input: 'trusted.md', output: 'trusted.pdf', sanitize: false });\n```\n\n> Only disable sanitization for content you control. Never run `--no-sanitize`\n> on files from untrusted sources.\n\n## Programmatic API\n\n```js\nconst { convert } = require('md2pdf-cli');\n\nawait convert({\n  input: 'research.md',\n  output: 'research.pdf',\n  title: 'My Research Report',\n  // cssFile: 'theme.css',\n  // css: '/* inline CSS string */',\n  format: 'A4',\n  pageNumbers: true,\n  sanitize: true,\n  toc: true,\n  tocDepth: 3,\n  highlight: true,\n  codeTheme: 'github-light',\n});\n```\n\n### `convert(options)`\n\n| Option              | Type                          | Default                | Description                                            |\n|---------------------|-------------------------------|------------------------|--------------------------------------------------------|\n| `input`             | `string`                      | —                      | Path to a Markdown file (required)                     |\n| `output`            | `string`                      | —                      | Path to the output PDF (required)                      |\n| `title`             | `string`                      | input basename         | `<title>` of the generated HTML                        |\n| `theme`             | `string`                      | `'default'`            | Built-in theme: `default`/`academic`/`latex`           |\n| `css`               | `string`                      | bundled default        | Inline CSS string (overrides `theme`)                  |\n| `cssFile`           | `string`                      | —                      | Path to a CSS file (overrides `css` and `theme`)       |\n| `format`            | `string`                      | `'A4'`                 | Puppeteer page format                                  |\n| `margin`            | `object`                      | 22mm / 18mm            | `{ top, bottom, left, right }`                         |\n| `pageNumbers`       | `boolean`                     | `true`                 | Render `n / total` in the footer                       |\n| `math`              | `boolean`                     | `true`                 | Render `$...$` and `$$...$$` as KaTeX                  |\n| `sanitize`          | `boolean`                     | `true`                 | Sanitize generated HTML (strip scripts/handlers)       |\n| `toc`               | `boolean`                     | `false`                | Prepend an auto-generated table of contents            |\n| `tocDepth`          | `number`                      | `3`                    | Deepest heading level included in the TOC              |\n| `tocTitle`          | `string`                      | `'Contents'`           | TOC heading text                                       |\n| `highlight`         | `boolean`                     | `false`                | Syntax-highlight code blocks with Shiki                |\n| `codeTheme`         | `string`                      | `'github-light'`       | Shiki theme name for code blocks                       |\n| `mermaid`           | `boolean`                     | `false`                | Render `mermaid` code blocks as diagrams               |\n| `mermaidTheme`      | `string`                      | `'base'`               | Mermaid theme name (light by default)                  |\n| `cover`             | `boolean`                     | front matter           | Render a title page (`true`/`false` overrides YAML)    |\n| `headerLogos`       | `boolean`                     | `false`                | Repeat the cover logos in every page header            |\n| `headerTemplate`    | `string`                      | empty                  | Puppeteer header HTML                                  |\n| `footerTemplate`    | `string`                      | page numbers           | Puppeteer footer HTML                                  |\n| `puppeteerOptions`  | `object`                      | `{}`                   | Extra options passed to `puppeteer.launch`             |\n| `keepHtml`          | `boolean`                     | `false`                | Keep the intermediate `.tmp.html` file                 |\n\nReturns `{ output, brokenImages }` where `brokenImages` lists any `<img>` URLs that failed to load.\n\n## Requirements\n\n- Node.js >= 18\n- Puppeteer will download a compatible Chromium on install (≈ 170 MB). To skip this and reuse an existing Chrome, set `PUPPETEER_SKIP_DOWNLOAD=true` before installing and pass `puppeteerOptions: { executablePath: '...' }` to `convert()`.\n\n## License\n\nMIT\n","readmeFilename":"README.md"}