CommonMark spec in JSON.
- What is this?
- When should I use this?
- Install
- Use
- API
- Types
- Compatibility
- Security
- Contribute
- License
This package exposes the CommonMark examples (tests) as plain objects.
You can use this package when you are building a markdown parser.
This package is ESM only. In Node.js (version 14.14+, 16.0+), install with npm:
npm install commonmark.json
In Deno with esm.sh
:
import {commonmark} from 'https://esm.sh/commonmark.json@0.30'
In browsers with esm.sh
:
<script type="module">
import {commonmark} from 'https://esm.sh/commonmark.json@0.30?bundle'
</script>
import {commonmark} from 'commonmark.json'
console.log(commonmark)
Yields:
[ { markdown: '\tfoo\tbaz\t\tbim\n',
html: '<pre><code>foo\tbaz\t\tbim\n</code></pre>\n',
section: 'Tabs' },
{ markdown: ' \tfoo\tbaz\t\tbim\n',
html: '<pre><code>foo\tbaz\t\tbim\n</code></pre>\n',
section: 'Tabs' },
{ markdown: ' a\ta\n ὐ\ta\n',
html: '<pre><code>a\ta\nὐ\ta\n</code></pre>\n',
section: 'Tabs' },
{ markdown: ' - foo\n\n\tbar\n',
html: '<ul>\n<li>\n<p>foo</p>\n<p>bar</p>\n</li>\n</ul>\n',
section: 'Tabs' },
{ markdown: '- foo\n\n\t\tbar\n',
html: '<ul>\n<li>\n<p>foo</p>\n<pre><code> bar\n</code></pre>\n</li>\n</ul>\n',
section: 'Tabs' },
... 622 more items ]
This package exports the identifiers commonmark
.
There is no default export.
CommonMark test spec in JSON (Array<Example>
).
A test case (Object
).
Has the following fields:
markdown
(string
) — actual input markdownhtml
(string
) — expected output HTMLsection
(string
) — label of test group.
This package is fully typed with TypeScript.
It exports the additional type Example
.
This package is at least compatible with all maintained versions of Node.js. As of now, that is Node.js 14.14+ and 16.0+. It also works in Deno and modern browsers.
This package is safe.
Yes please! See How to Contribute to Open Source.
To generate new examples, run npm run generate
to transform the spec at
CommonMark’s HEAD to JSON.
Run it with a $VERSION
to get JSON for a specific version, such as:
VERSION="0.27" node build