npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@enyaxu/hast-util-to-html

v3.1.1

Published

Transform HAST to HTML

Downloads

4

Readme

hast-util-to-html Build Status Coverage Status

Transform HAST to HTML.

Installation

npm:

npm install hast-util-to-html

Usage

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

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

console.log(toHTML(tree));

Yields:

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

API

toHTML(node[, options])

Stringify the given HAST node.

options.entities

Configuration for stringify-entities (Object, default: {}). Do not use escapeOnly, attribute, or subset (toHTML already passes those). However, useNamedReferences, useShortestReferences, and omitOptionalSemicolons are all fine.

options.voids

Tag-names of elements to stringify without closing tag (Array.<string>, default: html-void-elements).

options.quote

Preferred quote to use ('"' or '\'', default: '"').

options.quoteSmart

Use the other quote if that results in less bytes (boolean, default: false).

options.preferUnquoted

Leave attributes unquoted if that results in less bytes (boolean, default: false).

options.omitOptionalTags

Omit optional opening and closing tags (boolean, default: false). For example, in <ol><li>one</li><li>two</li></ol>, both </li> closing tags can be omitted. The first because it’s followed by another li, the last because it’s followed by nothing.

options.collapseEmptyAttributes

Collapse empty attributes: class="" is stringified as class instead (boolean, default: false). Note: boolean attributes, such as hidden, are always collapsed.

options.closeSelfClosing

Close self-closing nodes with an extra slash (/): <img /> instead of <img> (boolean, default: false).

options.tightSelfClosing

Do not use an extra space when closing self-closing elements: <img/> instead of <img /> (boolean, default: false). Note: Only used if closeSelfClosing: true.

options.tightCommaSeparatedLists

Join known comma-separated attribute values with just a comma (,), instead of padding them on the right as well (,) (boolean, default: false).

options.tightAttributes

Join attributes together, without white-space, if possible: class="a b" title="c d" is stringified as class="a b"title="c d" instead to save bytes (boolean, default: false). Note: creates invalid (but working) markup.

options.allowParseErrors

Do not encode characters which trigger parse errors (even though they work), to save bytes (boolean, default: false). Note: creates invalid (but working) markup.

options.allowDangerousCharacters

Do not encode some characters which cause XSS vulnerabilities in older browsers (boolean, default: false). Note: Only set this if you completely trust the content.

options.allowDangerousHTML

Allow raw nodes and insert them as raw HTML. When falsey, encodes raw nodes (boolean, default: false). Note: Only set this if you completely trust the content.

options.allowCamelCased

Allow node can use CamelCased attribute name. When falsey, encodes attributeName viewBox to view-box (boolean, default false).
Note: svg node alway set true.

Related

Contribute

See contribute.md in syntax-tree/hast for ways to get started.

This organisation has a Code of Conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.

License

MIT © Titus Wormer