JSPM

  • Created
  • Published
  • Downloads 389174
  • Score
    100M100P100Q202881F
  • License MIT

Transform HAST to MDAST

Package Exports

  • hast-util-to-mdast

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (hast-util-to-mdast) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

hast-util-to-mdast Build Status Coverage Status

Transform HAST (HTML) to MDAST (markdown).

This is stable in versioning now, but may change a bit in the future.

See GH-3 for progress.

Installation

npm:

npm install hast-util-to-mdast

Usage

var rehype = require('rehype');
var remark = require('remark');
var toMDAST = require('hast-util-to-mdast');

var hast = rehype().parse('<h2>Hello <strong>world!</strong></h2>');
var doc = remark().stringify(toMDAST(hast));
console.log(doc);

Yields:

## Hello **world!**

API

toMDAST(node[, options])

Transform the given HAST tree to an MDAST tree.

options.handlers

Object mapping tag-names to functions handling those elements. Take a look at handlers/ for examples.

options.document

Whether the given tree is a complete document. If document: true, implicit paragraphs are added in the root node around inline MDAST nodes. Otherwise, inline MDAST nodes are wrapped when needed.

License

MIT © Titus Wormer