New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

doku-md

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

doku-md

Commandline tool that generates a pdf file from markdown files.

latest
npmnpm
Version
1.0.6
Version published
Maintainers
1
Created
Source

doku

npm version

Doku is designed to make the process of building downloadable PDFs from markdown files simple and easy.

Features

  • Automatically generated table of contents
  • Customizable via css
  • Customizable via Javascript
  • Extensible Markdown renderer
  • Full power of Puppeteer for pdf rendering
  • Simple and easy commandline tool
       __      __
  ____/ /___  / /____  __
 / __  / __ \/ //_/ / / /
/ /_/ / /_/ / ,< / /_/ /
\__,_/\____/_/|_|\__,_/

Installation

npm install doku-md

Usage

The easiest way to get started with it is to run doku at the root of your documentation project.

> doku --glob '*.md'
Success! PDF file created
Open now: file.pdf

Options

--fileName [file]     -- name of the output file
--config [doku.json]  -- configuration file
--glob [*.md]         -- glob
--dev  [false]        -- launch a browser
--css                 -- path or url to a custom stylesheet
--js                  -- path or url to a custom Javascript include
--puppeteerOptions    -- override default options of puppetter
--outputDir           -- output directory
--tocLevels           -- table of content levels. default: 'h1, h2, h3, h4'

Advanced usage

Table of contents

In your markdown files, add a <toc> tag where you want to insert an automatically generated table of contents. This tag will scan the rest of the document for h1, h2, h3, and h4 headers and build an indented table of contents at that location.

<toc>

## My Header

lorem ipsum

Configuration file

You can use a doku.json file to pass your options. This file also takes an entries property where you can specify the files you'd like to use for your pdf. This is a great option if you want more precise control over your input files than a glob would provide.

Example:

{
  "fileName": "Documentation.pdf",
  "entries": ["Chapter1.md", "Chapter2.md"]
}
> doku
Success! PDF file created
Open now: Documentation.pdf

Custom stylesheet

Under the hood, doku uses Bootstrap library to reboot the browser defaults. You can use any Bootstrap utility class to customize the appearance of your markdown files.

You can also pass your own stylesheet through the commandline.

doku --css mystyles.css

Custom Javascript

If you'd like to modify the DOM using Javascript, you can pass your own Javascript file.

doku --js myscript.js

In your file, you can use jQuery. To ensure that the page is completely rendered, listen for the doku-rendered custom event.

window.addEventListener(`doku-rendered`, () => { ... })

Extending Markdown renderer

To extend the marked renderer, you can provide your extensions in the Javascript file. The renderer will be available at window.marked property.

Check out the "how-to" page of marked to get a better sense of how to extend the renderer.

Customizing Puppeteer

If you want more control over your PDF, including customization for header and footer templates, you can pass puppeteerOptions to doku to override any of the defaults.

Keywords

pdf

FAQs

Package last updated on 01 Nov 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts