drawdown-bake

Drawdown bake is a tool for baking markdown documents with drawdown diagram scripts into markdown documents with diagram images

Usage no npm install needed!

<script type="module">
  import drawdownBake from 'https://cdn.skypack.dev/drawdown-bake';
</script>

README

Drawdown Bake

Drawdown bake is a tool for baking markdown documents with drawdown diagram scripts into markdown documents with diagram images

Installation

npm install drawdown-bake --save-dev

Usage

Once installed the tool can be manually run by

node node_modules/.bin/drawdown-bake ./docs ./baked

This will make the baker walk trough ./docs recursively and search for markdown files to bake.
For every file found it will:

  1. Extract all drawdown scripts.
  2. Create an image representation of the diagram. The image will be stored into ./baked/assets.
  3. Scripts will be replaced with image references.
  4. Create new makrdown file into its relative directory within ./baked.
  5. All non makrdown-ish files will be copied as is.

Use in projects

In a project drawdawn-bake can be used as a npm script in the package.json:

{
  "scripts": {
    "bake": "drawdown-bake ./src ./baked",
  },
}

Now, every time a new fresh documentation badge is needed it can be baked by:

npm run bake

Command syntax

drawdown-bake <source-dir> <destination-dir> [options]

Options

Option Defaults Description
ext md,markdown CVS file extensions for markdown files to be baked
layout .drawdown‑preview‑layout Path to a JSON file with drawdown layout information.
no‑layout --- Will make the baker use automatic diagram layouts. Using --layout and --no-layout together will cause an error
web‑dir <module>/web A path to the directory which holds the browser version of the baker. Internally this tool uses puppeteer and chromium to render the SVG scripts produced by the drawdown-svg-render
web‑port 8989 Port number for the minimalistic web server to listen to. This server is used to serve the browser version of the baker which is later used by the chromium spawned by the puppeteer

Examples

Bake only .txt and .md files

drawdown-bake ./docs ./baked --ext=txt,md

Bake with custom layout file

drawdown-bake ./docs ./baked --layout=my_layout.json

Bake with automatic layout

drawdown-bake ./docs ./baked --no-layout

Using different port for the built-in http-server (in case the default :8989 is already used)

drawdown-bake ./docs ./baked --web-port=8787