JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2752216
  • Score
    100M100P100Q217508F
  • License MIT

Transform HAST to HTML

Package Exports

  • hast-util-to-html

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-html) 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-html Build Status Coverage Status

Transform HAST to HTML.

Installation

npm:

npm install hast-util-to-html

Usage

Dependencies:

var h = require('hastscript');
var toHTML = require('hast-util-to-html');

Transform:

var tree = h('.alpha', [
    'bravo ',
    h('b', 'charlie'),
    ' delta ',
    h('a.echo', {
        download: true
    }, 'foxtrot')
]);

Yields:

<div class="alpha">bravo <b>charlie</b> delta <a class="echo" download>foxtrot</a></div>

API

toHTML(node[, options])

Stringify the given HAST tree.

Parameters
  • node (HASTNode).

  • options (object, optional):

    • allowDangerousHTML (boolean, default: false) — Whether to allow raw nodes and insert them as raw HTML. When falsey, encodes raw nodes.
    • entities (Object, default: {escapeOnly: true}) — configuration for stringify-entities.
    • voids (Array.<string>, default: html-void-elements) — Tag-names of elements to stringify without closing tag.
    • closeSelfClosing (boolean, default: false) Whether to close self-closing nodes with an extra, superfluous slash (/): <img /> instead of <img>.
Returns

string.

License

MIT © Titus Wormer