|
|
vor 5 Tagen | |
|---|---|---|
| .. | ||
| index.js | vor 5 Tagen | |
| license | vor 5 Tagen | |
| package.json | vor 5 Tagen | |
| readme.md | vor 5 Tagen | |
unist utility to create a new trees with hyperscript-like syntax.
npm:
npm install unist-builder
var u = require('unist-builder')
var tree = u('root', [
u('subtree', {id: 1}),
u('subtree', {id: 2}, [
u('node', [u('leaf', 'leaf 1'), u('leaf', 'leaf 2')]),
u('leaf', {id: 3}, 'leaf 3'),
u('void', {id: 4})
])
])
console.dir(tree, {depth: null})
results in the following tree:
{
type: 'root',
children: [
{type: 'subtree', id: 1},
{
type: 'subtree',
id: 2,
children: [
{
type: 'node',
children: [
{type: 'leaf', value: 'leaf 1'},
{type: 'leaf', value: 'leaf 2'}
]
},
{type: 'leaf', id: 3, value: 'leaf 3'},
{type: 'void', id: 4}
]
}
]
}
u(type[, props][, children|value])Creates a node from props, children, and optionally value.
u(type[, props], children) — create a parentu(type[, props], value) — create a literalu(type[, props]) — create a void nodetype (string) — node typeprops (Object) — other values assigned to nodechildren (Array.<Node>) — children of nodevalue (*) — value of node (cast to string)Node.
unist-builder-blueprint
— Convert unist trees to unist-builder notationhastscript
— Create hast elementsSee contributing.md in syntax-tree/.github for ways to get
started.
See support.md for ways to get help.
This project has a Code of Conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.
MIT © Eugene Sharygin