Skip to content

JavaScript library to parse and work with markup content (Markdown)

Notifications You must be signed in to change notification settings

antifragileer/markup-it

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Usage

Initialize a syntax:

var MarkupIt = require('markup-it');
var markdownSyntax = require('markup-it/syntaxes/markdown');
var htmlSyntax = require('markup-it/syntaxes/html');

var markdown = new MarkupIt(markdownSyntax);
var html = new MarkupIt(htmlSyntax);

Parse markdown

const { State } = require('markup-it');
const markdown = require('markup-it/lib/markdown');

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

Render document to HTML

const { State } = require('markup-it');
const html = require('markup-it/lib/html');

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

Render document to Markdown

const { State } = require('markup-it');
const markdown = require('markup-it/lib/markdown');

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

About

JavaScript library to parse and work with markup content (Markdown)

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 96.2%
  • HTML 3.7%
  • GCC Machine Description 0.1%