GitXplorerGitXplorer
G

markup-it

public
270 stars
49 forks
36 issues

Commits

List of commits on branch master.
Unverified
4c0538ebc0a5767276fe8352493c8d386f971fd3

Bump version to 13.0.0 🚀

jjpreynat committed 4 years ago
Unverified
502f8f8fcd6738b68fd5f7fae02e8d6cc8e308ba

Lint fix

jjpreynat committed 4 years ago
Unverified
e39a16589e59f61f4b9a44d47d3c9c9430598773

Upgrade dependencies

jjpreynat committed 4 years ago
Verified
e9cdd52c3e4327b4ab06202dff14f51a8e588ff5

Merge pull request #157 from GitbookIO/improve-custom-blocks-parsing

jjpreynat committed 4 years ago
Unverified
99ff3556bdec5e316c6a82a8fca659bfcc513f6c

Improve parsing of closed custom blocks

jjpreynat committed 4 years ago
Unverified
31892707db682564dded7f1e2f445bb5e12614f3

Remove useless Travis config

jjpreynat committed 4 years ago

README

The README file for this repository.

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