# @jamen/mdc

> Compile directory of markdown into HTML and JSON fragments.

Latest version **0.0.1** (published 2018-06-14) · 0 weekly downloads

## Install

```sh
npm install @jamen/mdc
pnpm add @jamen/mdc
yarn add @jamen/mdc
bun add @jamen/mdc
```

Provides the command `mdc`.

## Health

**Score 10/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2018-06-14 |
| First published | 2018-06-14 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 16 |
| Unpacked size | 13.6 KB |
| Known vulnerabilities | 0 (+13 in 6 direct dependencies) |
| Install scripts | no |
| Author | Jamen Marz |
| Maintainers | jamen |

## Links

- npm: https://www.npmjs.com/package/@jamen/mdc
- npm.io page: https://npm.io/package/@jamen/mdc

## Dependencies (16)

- [ajv](https://npm.io/package/ajv.md) 6.5.1
- [glob](https://npm.io/package/glob.md) 7.1.2
- [chalk](https://npm.io/package/chalk.md) 2.4.1
- [mkdirp](https://npm.io/package/mkdirp.md) 0.5.1
- [minimist](https://npm.io/package/minimist.md) 1.2.0
- [markdown-it](https://npm.io/package/markdown-it.md) 8.4.1
- [xss-filters](https://npm.io/package/xss-filters.md) 1.2.7
- [front-matter](https://npm.io/package/front-matter.md) 2.3.0
- [get-md-title](https://npm.io/package/get-md-title.md) 1.0.4
- [glob-promise](https://npm.io/package/glob-promise.md) 3.4.0
- [highlight.js](https://npm.io/package/highlight.js.md) 9.12.0
- [markdown-it-katex](https://npm.io/package/markdown-it-katex.md) 2.0.3
- [markdown-it-imsize](https://npm.io/package/markdown-it-imsize.md) 2.0.1
- [markdown-it-deflist](https://npm.io/package/markdown-it-deflist.md) 2.0.3
- [markdown-it-decorate](https://npm.io/package/markdown-it-decorate.md) 1.2.2
- [markdown-it-footnote](https://npm.io/package/markdown-it-footnote.md) 3.0.1

## Recent versions

- 0.0.1 (latest) — 2018-06-14
- 0.0.0 — 2018-06-14

## README

# mdc

Compile directory of markdown into HTML and JSON fragments.

## Install

```shell
npm i -g mdc
```

## Usage

### `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:

```shell
$ 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.md
```

With `--no-index`, instead of an `index.json` file, separate JSON files of the front matters are created alongside the HTML files (as `*-info.json`):

```shell
$ 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.md
```

With `--no-json`, JSON and front matter is omitted entirely:

```shell
$ 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.md
```

With one input, you can omit `-o` or `--output` to use stdout instead:

```shell
# Compile to stdout
$ mdc input.md
$ mdc input.md --no-json
```

Every 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][1] and [front-matter][2].
- Adds [LaTeX][3], [footnotes][4], and [deflists][5], similar to Pandoc Markdown.
- Adds the [decorate][6] and [imsize][7] plugins for setting classes, attributes, sizes, etc.
- Front matter validated against [a schema][8].

```js
let result = await mdc('./input.md', './dist')
// result.htmlFile

let result = await mdc('./input.md')
// result.htmlBody
```

See [lib/schema.js][8] for more info on the return value.

### License Types

Inspired from [markdown-to-medium][9], 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

[1]: https://npmjs.com/markdown-it
[2]: https://npmjs.com/front-matter
[3]: https://npmjs.com/markdown-it-katex
[4]: https://npmjs.com/markdown-it-footnotes
[5]: https://npmjs.com/markdown-it-deflist
[6]: https://npmjs.com/markdown-it-decorate
[7]: https://npmjs.com/markdown-it-imsize
[8]: lib/schema.js
[9]: https://www.npmjs.com/package/markdown-to-medium

---
_Source: https://npm.io/package/@jamen/mdc · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
