markup-it

Pipeline for working with markup input (for example Markdown)

Apache-2.0 94 个版本
安装
npm install markup-it
yarn add markup-it
pnpm add markup-it
bun add markup-it
README

markup-it

Build Status NPM version

markup-it is a JavaScript library to serialize/deserialize markdown content using an intermediate format backed by an immutable model.

Installation

$ npm i markup-it --save

or

$ yarn add markup-it

Usage

Parse markdown

const { State, MarkdownParser } = require('markup-it');

const state = State.create(MarkdownParser);
const document = state.deserializeToDocument('Hello **World**');

Render document to HTML

const { State, HTMLParser } = require('markup-it');

const state = State.create(HTMLParser);
const str = state.serializeDocument(document);

Render document to Markdown

const { State, MarkdownParser } = require('markup-it');

const state = State.create(markdown);
const str = state.serializeDocument(document);

ES6

markup-it is ESM compliant through the package.json module field, so you can safely use it with ES6 syntax for tree-shaking.

import { State, HTMLParser } from 'markup-it';

const state = State.create(HTMLParser);
const str = state.serializeDocument(document);

Testing

There are many scripts available in the /bin folder to output an HTML or Markdown file to multiple formats (HTML, Hyperscript, JSON, Markdown, YAML).

These scripts can be called with babel-node, for example:

babel-node bin/toJSON.js ./page.md
版本列表
13.0.0 2021-03-19
12.1.1 2020-05-27
12.1.0 2020-01-31
12.0.5 2020-01-24
12.0.4 2020-01-24
12.0.3 2020-01-17
12.0.2 2020-01-17
12.0.1 2019-12-09
12.0.0 2019-11-26
11.1.8 2019-07-15
11.1.7 2019-07-15
11.1.6 2019-06-19
11.1.5 2019-06-04
11.1.4 2019-02-27
11.1.3 2019-01-06
11.1.2 2019-01-06
11.1.1 2018-10-15
11.1.0 2018-10-15
11.0.0 2018-09-19
10.0.0 2018-09-06
9.0.0 2018-07-31
8.1.3-alpha.0 2018-07-05
8.1.3 2018-07-06
8.1.2 2018-06-09
8.1.1 2018-06-06
8.1.0 2018-06-06
8.0.3 2018-05-29
8.0.2 2018-05-14
8.0.1 2018-05-03
8.0.0 2018-04-19
7.0.4 2018-04-16
7.0.3 2018-04-06
7.0.2 2018-04-05
7.0.1 2018-03-28
7.0.0 2018-03-23
6.0.6 2018-04-06
6.0.5 2018-04-04
6.0.4 2018-03-29
6.0.3 2018-03-28
6.0.2 2018-03-28
6.0.1 2018-03-28
6.0.0 2018-02-26
6.0.0-pre.1 2018-02-25
6.0.0-pre.0 2018-02-25
5.1.2 2018-01-22
5.1.1 2018-01-09
5.1.0 2017-12-07
5.0.2 2017-12-01
5.0.1 2017-11-24
5.0.0 2017-11-23
4.0.2 2017-11-10
4.0.1 2017-11-03
4.0.0 2017-09-27
4.0.0-pre.1 2017-03-02
4.0.0-pre.0 2017-02-28
3.6.0 2017-09-22
3.5.2 2017-06-14
3.5.1 2017-06-13
3.5.0 2017-04-21
3.4.2 2017-03-15
3.4.1 2017-03-10
3.4.0 2017-03-09
3.3.7 2017-03-08
3.3.6 2017-03-06
3.3.5 2017-03-01
3.3.4 2017-03-01
3.3.3 2017-02-27
3.3.2 2017-01-24
3.3.1 2017-01-18
3.3.0 2016-12-28
3.2.0 2016-12-19
3.1.2 2016-12-16
3.1.1 2016-12-16
3.1.0 2016-12-14
3.0.2 2016-12-10
3.0.1 2016-12-07
3.0.0 2016-12-06
3.0.0-pre.6 2016-12-01
3.0.0-pre.5 2016-11-30
3.0.0-pre.4 2016-11-30
3.0.0-pre.3 2016-11-29
3.0.0-pre.2 2016-11-29
3.0.0-pre.1 2016-11-28
2.5.0 2016-09-24
2.4.0 2016-08-08
2.3.0 2016-07-28
2.2.0 2016-07-05
2.1.2 2016-07-01
2.1.1 2016-06-30
2.1.0 2016-06-30
2.0.1 2016-06-28
2.0.0 2016-06-28
1.0.0 2016-06-15
1.0.0-pre.0 2016-04-07