{"_id":"@ambikuk/markdown-pdf","name":"@ambikuk/markdown-pdf","dist-tags":{"latest":"11.0.0"},"versions":{"11.0.0":{"name":"@ambikuk/markdown-pdf","version":"11.0.0","description":"Markdown to PDF converter","main":"index.js","scripts":{"test":"standard && istanbul cover node_modules/.bin/tape test/*.js","coveralls":"cat ./coverage/lcov.info | coveralls"},"repository":{"type":"git","url":"git+ssh://git@github.com/ambikuk/markdown-pdf.git"},"keywords":["markdown","pdf","convert","template"],"author":{"name":"Alan Shaw"},"homepage":"https://github.com/ambikuk/markdown-pdf","license":"MIT","dependencies":{"commander":"^3.0.0","duplexer":"^0.1.1","extend":"^3.0.2","highlight.js":"^10.0.0","phantomjs-prebuilt":"^2.1.3","remarkable":"^2.0.0","stream-from-to":"^1.4.2","through2":"^3.0.1","tmp":"^0.1.0"},"devDependencies":{"coveralls":"^3.0.6","istanbul":"^0.4.0","pdf-text":"^0.4.0","standard":"^13.1.0","tape":"^4.11.0"},"engines":{"node":">=0.10.0"},"bin":{"markdown-pdf":"bin/markdown-pdf"},"standard":{"ignore":["html5bp/**"]},"bugs":{"url":"https://github.com/ambikuk/markdown-pdf/issues"},"directories":{"test":"test"},"gitHead":"1aad86ab801326a669539ab6c21c54f84bcee523","_id":"@ambikuk/markdown-pdf@11.0.0","_nodeVersion":"16.14.2","_npmVersion":"8.5.0","dist":{"integrity":"sha512-x8g4P8OqSAgeVfGHue1wbav+RAuh9xhsHiN/RdqANnVh1vCJrQ6OgTcbWsW7wZP0IwlAc+GuVlT/PahEEun+kA==","shasum":"a766d34eebef7b7c4341b5208e06fd7db9ca398a","tarball":"https://registry.npmjs.org/@ambikuk/markdown-pdf/-/markdown-pdf-11.0.0.tgz","fileCount":45,"unpackedSize":253189,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDtIHund3Mv3j5jrkVUagQRXrHeT5dCsAA48vhcU6/SvAIgDvwgyoJUQHph0zD8aEM8gfOWWaPUbVbP2y5NIo9Dv78="}]},"_npmUser":{"name":"ambikuk","email":"ambikuk@gmail.com"},"maintainers":[{"name":"ambikuk","email":"ambikuk@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/markdown-pdf_11.0.0_1697631643029_0.5388708668460889"},"_hasShrinkwrap":false}},"time":{"created":"2023-10-18T12:20:42.950Z","11.0.0":"2023-10-18T12:20:43.331Z","modified":"2023-10-18T12:20:43.621Z"},"maintainers":[{"name":"ambikuk","email":"ambikuk@gmail.com"}],"description":"Markdown to PDF converter","homepage":"https://github.com/ambikuk/markdown-pdf","keywords":["markdown","pdf","convert","template"],"repository":{"type":"git","url":"git+ssh://git@github.com/ambikuk/markdown-pdf.git"},"author":{"name":"Alan Shaw"},"bugs":{"url":"https://github.com/ambikuk/markdown-pdf/issues"},"license":"MIT","readme":"markdown-pdf [![Build Status](https://travis-ci.org/alanshaw/markdown-pdf.svg)](https://travis-ci.org/alanshaw/markdown-pdf) [![Dependency Status](https://david-dm.org/alanshaw/markdown-pdf.svg)](https://david-dm.org/alanshaw/markdown-pdf) [![Coverage Status](https://img.shields.io/coveralls/alanshaw/markdown-pdf.svg?style=flat)](https://coveralls.io/r/alanshaw/markdown-pdf?branch=master)\n===\n\nNode module that converts Markdown files to PDFs.\n\nThe PDF looks great because it is styled by HTML5 Boilerplate. What? - Yes! Your Markdown is first converted to HTML, then pushed into the HTML5 Boilerplate `index.html`. Phantomjs renders the page and saves it to a PDF. You can even customise the style of the PDF by passing an optional path to your CSS _and_ you can pre-process your markdown file before it is converted to a PDF by passing in a pre-processing function, for templating.\n\n## Install\n\n```sh\nnpm install -g markdown-pdf --ignore-scripts\n```\n\nNote: elevated (sudo) permissions may be needed for `npm install -g`\n\n## Usage\n\n```\nUsage: markdown-pdf [options] <markdown-file-path>\n\nOptions:\n\n  -h, --help                             output usage information\n  -V, --version                          output the version number\n  <markdown-file-path>                   Path of the markdown file to convert\n  -c, --cwd [path]                       Current working directory\n  -p, --phantom-path [path]              Path to phantom binary\n  -h, --runnings-path [path]             Path to runnings (header, footer)\n  -s, --css-path [path]                  Path to custom CSS file\n  -z, --highlight-css-path [path]        Path to custom highlight-CSS file\n  -m, --remarkable-options [json]        Options to pass to Remarkable\n  -f, --paper-format [format]            'A3', 'A4', 'A5', 'Legal', 'Letter' or 'Tabloid'\n  -r, --paper-orientation [orientation]  'portrait' or 'landscape'\n  -b, --paper-border [measurement]       Supported dimension units are: 'mm', 'cm', 'in', 'px'\n  -d, --render-delay [millis]            Delay before rendering the PDF\n  -t, --load-timeout [millis]            Timeout before the page is rendered in case `page.onLoadFinished` isn't fired\n  -o, --out [path]                       Path of where to save the PDF\n```\n\n`markdown-pdf` can also be used programmatically:\n\n```javascript\nvar markdownpdf = require(\"markdown-pdf\")\n  , fs = require(\"fs\")\n\nfs.createReadStream(\"/path/to/document.md\")\n  .pipe(markdownpdf())\n  .pipe(fs.createWriteStream(\"/path/to/document.pdf\"))\n\n// --- OR ---\n\nmarkdownpdf().from(\"/path/to/document.md\").to(\"/path/to/document.pdf\", function () {\n  console.log(\"Done\")\n})\n```\n\n### Options\n\nPass an options object (`markdownpdf({/* options */})`) to configure the output.\n\n#### options.cwd\nType: `String`\nDefault value: `process.cwd()`\n\nCurrent working directory.\n\n#### options.phantomPath\nType: `String`\nDefault value: Path provided by phantomjs module\n\nPath to the phantomjs binary.\n\n#### options.cssPath\nType: `String`\nDefault value: `[module path]/markdown-pdf/css/pdf.css`\n\nPath to custom CSS file, relative to the current directory.\n\n#### options.highlightCssPath\nType: `String`\nDefault value: `[module path]/markdown-pdf/css/highlight.css`\n\nPath to custom highlight CSS file (for code highlighting with [highlight.js](https://highlightjs.org)), relative to the current directory.\n\n#### options.paperFormat\nType: `String`\nDefault value: `A4`\n\n'A3', 'A4', 'A5', 'Legal', 'Letter' or 'Tabloid'.\n\n#### options.paperOrientation\nType: `String`\nDefault value: `portrait`\n\n'portrait' or 'landscape'.\n\n#### options.paperBorder\nType: `String`\nDefault value: `2cm`\n\nSupported dimension units are: 'mm', 'cm', 'in', 'px'\n\n#### options.runningsPath\nType: `String`\nDefault value: `runnings.js`\n\nPath to CommonJS module which sets the page header and footer (see [runnings.js](runnings.js)).\n\n#### options.renderDelay\nType: `Number`\nDefault value: Time until [`page.onLoadFinished`](http://phantomjs.org/api/webpage/handler/on-load-finished.html) event fired\n\nDelay (in ms) before the PDF is rendered.\n\n#### options.loadTimeout\nType: `Number`\nDefault value: `10000`\n\nIf `renderDelay` option isn't set, this is the timeout (in ms) before the page is rendered in case the `page.onLoadFinished` event doesn't fire.\n\n#### options.preProcessMd\nType: `Function`\nDefault value: `function () { return through() }`\n\nA function that returns a [through2 stream](https://npmjs.org/package/through2) that transforms the markdown before it is converted to HTML.\n\n#### options.preProcessHtml\nType: `Function`\nDefault value: `function () { return through() }`\n\nA function that returns a [through2 stream](https://npmjs.org/package/through2) that transforms the HTML before it is converted to PDF.\n\n#### options.remarkable\nType: `object`\nDefault value: `{ breaks: true }`\n\nA config object that is passed to [remarkable](https://www.npmjs.com/package/remarkable#options), the underlying markdown parser.\n\n##### options.remarkable.preset\nType: `String`\nDefault value: `default`\n\nUse remarkable [presets](https://www.npmjs.com/package/remarkable#presets) as a convenience to quickly enable/disable active syntax rules and options for common use cases.\n\nSupported values are `default`, `commonmark` and `full`\n\n##### options.remarkable.plugins\nType: `Array` of remarkable-plugin `Function`s\nDefault value: `[]`\n\nAn array of Remarkable plugin functions, that extend the markdown parser functionality.\n\n##### options.remarkable.syntax\nType: `Array` of optional remarkable syntax `Strings`s\nDefault value: `[]`\n\nAn array of [optional Remarkable syntax extensions](https://github.com/jonschlinkert/remarkable#syntax-extensions), disabled by default, that extend the markdown parser functionality.\n\n## API\n\n### from.path(path, opts) / from(path, opts)\n\nCreate a readable stream from `path` and pipe to markdown-pdf. `path` can be a single path or array of paths.\n\n### from.string(string)\n\nCreate a readable stream from `string` and pipe to markdown-pdf. `string` can be a single string or array of strings.\n\n### concat.from.paths(paths, opts)\n\nCreate and concatenate readable streams from `paths` and pipe to markdown-pdf.\n\n### concat.from.strings(strings, opts)\n\nCreate and concatenate readable streams from `strings` and pipe to markdown-pdf.\n\n### to.path(path, cb) / to(path, cb)\n\nCreate a writeable stream to `path` and pipe output from markdown-pdf to it. `path` can be a single path, or array of output paths if you specified an array of inputs. The callback function `cb` will be invoked when data has finished being written.\n\n### to.buffer(opts, cb)\n\nCreate a [concat-stream](https://npmjs.org/package/concat-stream) and pipe output from markdown-pdf to it. The callback function `cb` will be invoked when the buffer has been created.\n\n### to.string(opts, cb)\n\nCreate a [concat-stream](https://npmjs.org/package/concat-stream) and pipe output from markdown-pdf to it. The callback function `cb` will be invoked when the string has been created.\n\n## More examples\n\n### From string to path\n\n```javascript\nvar markdownpdf = require(\"markdown-pdf\")\n\nvar md = \"foo===\\n* bar\\n* baz\\n\\nLorem ipsum dolor sit\"\n  , outputPath = \"/path/to/doc.pdf\"\n\nmarkdownpdf().from.string(md).to(outputPath, function () {\n  console.log(\"Created\", outputPath)\n})\n```\n\n### From multiple paths to multiple paths\n\n```javascript\nvar markdownpdf = require(\"markdown-pdf\")\n\nvar mdDocs = [\"home.md\", \"about.md\", \"contact.md\"]\n  , pdfDocs = mdDocs.map(function (d) { return \"out/\" + d.replace(\".md\", \".pdf\") })\n\nmarkdownpdf().from(mdDocs).to(pdfDocs, function () {\n  pdfDocs.forEach(function (d) { console.log(\"Created\", d) })\n})\n```\n\n### Concat from multiple paths to single path\n\n```javascript\nvar markdownpdf = require(\"markdown-pdf\")\n\nvar mdDocs = [\"chapter1.md\", \"chapter2.md\", \"chapter3.md\"]\n  , bookPath = \"/path/to/book.pdf\"\n\nmarkdownpdf().concat.from(mdDocs).to(bookPath, function () {\n  console.log(\"Created\", bookPath)\n})\n```\n\n### Transform markdown before conversion\n\n```javascript\nvar markdownpdf = require(\"markdown-pdf\")\n  , split = require(\"split\")\n  , through = require(\"through\")\n  , duplexer = require(\"duplexer\")\n\nfunction preProcessMd () {\n  // Split the input stream by lines\n  var splitter = split()\n\n  // Replace occurences of \"foo\" with \"bar\"\n  var replacer = through(function (data) {\n    this.queue(data.replace(/foo/g, \"bar\") + \"\\n\")\n  })\n\n  splitter.pipe(replacer)\n  return duplexer(splitter, replacer)\n}\n\nmarkdownpdf({preProcessMd: preProcessMd})\n  .from(\"/path/to/document.md\")\n  .to(\"/path/to/document.pdf\", function () { console.log(\"Done\") })\n```\n\n### Remarkable options and plugins\n\nExample using [remarkable-classy](https://www.npmjs.com/package/remarkable-classy) plugin:\n\n```javascript\nvar markdownpdf = require(\"markdown-pdf\")\n\nvar options = {\n    remarkable: {\n        html: true,\n        breaks: true,\n        plugins: [ require('remarkable-classy') ],\n\t\tsyntax: [ 'footnote', 'sup', 'sub' ]\n    }\n}\n\nmarkdownpdf(options)\n  .from(\"/path/to/document.md\")\n  .to(\"/path/to/document.pdf\", function () { console.log(\"Done\") })\n```\n\n## Contribute\n\nFeel free to dive in! [Open an issue](https://github.com/alanshaw/markdown-pdf/issues/new) or submit PRs.\n\n## License\n\n[MIT](LICENCE) © Alan Shaw\n","readmeFilename":"README.md"}