Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gitbookio/markup-it
JavaScript library to parse and serialize markup content (Markdown and HTML)
https://github.com/gitbookio/markup-it
javascript markdown slate wysiwyg
Last synced: 2 days ago
JSON representation
JavaScript library to parse and serialize markup content (Markdown and HTML)
- Host: GitHub
- URL: https://github.com/gitbookio/markup-it
- Owner: GitbookIO
- Created: 2016-03-10T16:40:47.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-07-18T20:15:42.000Z (over 1 year ago)
- Last Synced: 2024-10-31T14:41:33.309Z (13 days ago)
- Topics: javascript, markdown, slate, wysiwyg
- Language: JavaScript
- Homepage:
- Size: 1.7 MB
- Stars: 270
- Watchers: 8
- Forks: 49
- Open Issues: 36
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# markup-it
[![Build Status](https://travis-ci.org/GitbookIO/markup-it.svg?branch=master)](https://travis-ci.org/GitbookIO/markup-it)
[![NPM version](https://badge.fury.io/js/markup-it.svg)](http://badge.fury.io/js/markup-it)`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
```js
const { State, MarkdownParser } = require('markup-it');const state = State.create(MarkdownParser);
const document = state.deserializeToDocument('Hello **World**');
```#### Render document to HTML
```js
const { State, HTMLParser } = require('markup-it');const state = State.create(HTMLParser);
const str = state.serializeDocument(document);
```#### Render document to Markdown
```js
const { State, MarkdownParser } = require('markup-it');const state = State.create(markdown);
const str = state.serializeDocument(document);
```### ES6
`markup-it` is [ESM](https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/) compliant through the package.json `module` field, so you can safely use it with ES6 syntax for tree-shaking.
```js
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
```