npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

doku-md

v1.0.6

Published

Commandline tool that generates a pdf file from markdown files.

Downloads

18

Readme

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.