Package Exports
- hast-util-raw
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-raw) 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-raw
hast utility to parse the tree again, now supporting
embedded raw
nodes.
One of the reasons to do this is for “malformed” syntax trees: for example, say
there’s an h1
element in a p
element, this utility will make them siblings.
Another reason to do this is if raw HTML/XML is embedded in a syntax tree, which
can occur when coming from Markdown using mdast-util-to-hast
.
If you’re working with remark and/or
remark-rehype
, use rehype-raw
instead.
Install
npm:
npm install hast-util-raw
Usage
var h = require('hastscript')
var raw = require('hast-util-raw')
var tree = h('div', [h('h1', ['Foo ', h('h2', 'Bar'), ' Baz'])])
var clean = raw(tree)
console.log(clean)
Yields:
{ type: 'element',
tagName: 'div',
properties: {},
children:
[ { type: 'element',
tagName: 'h1',
properties: {},
children: [Object] },
{ type: 'element',
tagName: 'h2',
properties: {},
children: [Object] },
{ type: 'text', value: ' Baz' } ] }
API
raw(tree[, file])
Given a hast tree and an optional vfile (for positional info), return a new parsed-again hast tree.
Contribute
See 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.