@jamen/mdc v0.0.1
mdc
Compile directory of markdown into HTML and JSON fragments.
Install
npm i -g mdcUsage
mdc *.md -o output/ --no-index? --no-json?
Compiles each markdown file into an HTML file, using an index.json to store the front matters and paths:
$ mdc *.md -o dist
# Results in:
# .
# ├── dist
# │ ├── 2018-06-13-test-article-1.html
# │ ├── 2018-06-13-test-article-2.html
# │ └── index.json
# ├── test-article-1.md
# └── test-article-2.mdWith --no-index, instead of an index.json file, separate JSON files of the front matters are created alongside the HTML files (as *-info.json):
$ mdc *.md -o dist --no-index
# Results in:
# .
# ├── dist
# │ ├── 2018-06-13-test-article-1.html
# │ ├── 2018-06-13-test-article-1-info.json
# │ ├── 2018-06-13-test-article-2.html
# │ └── 2018-06-13-test-article-2-info.json
# ├── test-article-1.md
# └── test-article-2.mdWith --no-json, JSON and front matter is omitted entirely:
$ mdc *.md -o dist --no-json
# Results in:
# .
# ├── dist
# │ ├── 2018-06-13-test-article-1.html
# │ └── 2018-06-13-test-article-2.html
# ├── test-article-1.md
# └── test-article-2.mdWith one input, you can omit -o or --output to use stdout instead:
# Compile to stdout
$ mdc input.md
$ mdc input.md --no-jsonEvery input must have 'title', 'author', 'created', and 'license' properties.
mdc(input, output?)
Function to compile a markdown file into an HTML file, and returns an info object as a promise. Without output the HTML is returned inside the object.
Features of the compiler:
- Made with markdown-it and front-matter.
- Adds LaTeX, footnotes, and deflists, similar to Pandoc Markdown.
- Adds the decorate and imsize plugins for setting classes, attributes, sizes, etc.
- Front matter validated against a schema.
let result = await mdc('./input.md', './dist')
// result.htmlFile
let result = await mdc('./input.md')
// result.htmlBodySee lib/schema.js for more info on the return value.
License Types
Inspired from markdown-to-medium, the license types are:
- all-rights-reserved
- cc-40-by
- cc-40-by-nd
- cc-40-by-sa
- cc-40-by-nc
- cc-40-by-nc-nd
- cc-40-by-nc-sa
- cc-40-zero
- public-domain