Package Exports
- hast-to-hyperscript
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-to-hyperscript) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
hast-to-hyperscript

Transform HAST to something else through a hyperscript DSL.
Installation
npm:
npm install hast-to-hyperscripthast-to-hyperscript is also available as an AMD, CommonJS, and globals module, uncompressed and compressed.
Usage
Dependencies:
var toH = require('hast-to-hyperscript');
var h = require('hyperscript');AST:
var tree = { type: 'element',
tagName: 'p',
properties: { id: 'alpha', className: [ 'bravo' ] },
children:
[ { type: 'text',
value: 'charlie ' },
{ type: 'element',
tagName: 'strong',
properties: { style: 'color: red;' },
children:
[ { type: 'text',
value: 'delta' } ] },
{ type: 'text',
value: ' echo.' } ] }Transform (hyperscript needs outerHTML to stringify):
var doc = toH(h, tree).outerHTML;Yields:
<p class="bravo" id="alpha">charlie <strong>delta</strong> echo.</p>API
toH(h, node[, prefix])
Transform HAST to something else through a hyperscript DSL.
Parameters
h(Function);node(Element);prefix(stringorboolean, optional) — Prefix to use as a prefix for keys passed inattrstoh(), this behaviour is turned off by passingfalse, turned on by passing astring. By default,h-is used as a prefix if the givenhis detected as beingvirtual-dom/horReact.createElement.
Returns
* — Anything returned by invoking h().
function h(name, attrs, children)
Transform HAST to something else through a hyperscript DSL.
Parameters
name(string) — Tag-name of element to create.attrs(Object.<string>) — Attributes to set.children(Array.<* | string>) — List of children and text, where children are the result of invokingh()previously.
Returns
* — Anything.
Caveats
Although there are lots of libs mentioning support for this interface,
there are significant differences between them. For example, hyperscript
doesn’t support classes in attrs, virtual-dom/h needs an attributes
object inside attrs most of the time. hast-to-hyperscript works
around these differences for: