markup-it

13.0.0 • Public • Published

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

/markup-it/

    Package Sidebar

    Install

    npm i markup-it

    Weekly Downloads

    322

    Version

    13.0.0

    License

    Apache-2.0

    Unpacked Size

    230 kB

    Total Files

    15

    Last publish

    Collaborators

    • taranvohra
    • gitbook-bot
    • samypesse
    • jpreynat
    • emmerich