WIP - add extractor, generate snippet_data

This commit is contained in:
Stefan Fejes
2019-08-20 15:52:05 +02:00
parent 88084d3d30
commit cc8f1d8a7a
37396 changed files with 4588842 additions and 133 deletions

22
node_modules/hast-to-hyperscript/LICENSE generated vendored Normal file
View File

@ -0,0 +1,22 @@
(The MIT License)
Copyright (c) 2016 Titus Wormer <tituswormer@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

232
node_modules/hast-to-hyperscript/index.js generated vendored Normal file
View File

@ -0,0 +1,232 @@
'use strict'
var html = require('property-information/html')
var svg = require('property-information/svg')
var find = require('property-information/find')
var spaces = require('space-separated-tokens')
var commas = require('comma-separated-tokens')
var style = require('style-to-object')
var ns = require('web-namespaces')
var is = require('unist-util-is')
var dashes = /-([a-z])/g
module.exports = wrapper
function wrapper(h, node, options) {
var settings = options || {}
var prefix
var r
var v
if (typeof h !== 'function') {
throw new Error('h is not a function')
}
if (typeof settings === 'string' || typeof settings === 'boolean') {
prefix = settings
settings = {}
} else {
prefix = settings.prefix
}
r = react(h)
v = vdom(h)
if (prefix === null || prefix === undefined) {
prefix = r === true || v === true ? 'h-' : false
}
if (is('root', node)) {
if (node.children.length === 1 && is('element', node.children[0])) {
node = node.children[0]
} else {
node = {
type: 'element',
tagName: 'div',
properties: {},
children: node.children
}
}
} else if (!is('element', node)) {
throw new Error(
'Expected root or element, not `' + ((node && node.type) || node) + '`'
)
}
return toH(h, node, {
schema: settings.space === 'svg' ? svg : html,
prefix: prefix,
key: 0,
react: r,
vdom: v,
hyperscript: hyperscript(h)
})
}
// Transform a HAST node through a hyperscript interface
// to *anything*!
function toH(h, node, ctx) {
var parentSchema = ctx.schema
var schema = parentSchema
var name = node.tagName
var properties
var attributes
var children
var property
var elements
var length
var index
var value
var result
if (parentSchema.space === 'html' && name.toLowerCase() === 'svg') {
schema = svg
ctx.schema = schema
}
if (ctx.vdom === true && schema.space === 'html') {
name = name.toUpperCase()
}
properties = node.properties
attributes = {}
for (property in properties) {
addAttribute(attributes, property, properties[property], ctx)
}
if (
typeof attributes.style === 'string' &&
(ctx.vdom === true || ctx.react === true)
) {
// VDOM and React accept `style` as object.
attributes.style = parseStyle(attributes.style, name)
}
if (ctx.prefix) {
ctx.key++
attributes.key = ctx.prefix + ctx.key
}
if (ctx.vdom && schema.space !== 'html') {
attributes.namespace = ns[schema.space]
}
elements = []
children = node.children
length = children ? children.length : 0
index = -1
while (++index < length) {
value = children[index]
if (is('element', value)) {
elements.push(toH(h, value, ctx))
} else if (is('text', value)) {
elements.push(value.value)
}
}
// Ensure no React warnings are triggered for
// void elements having children passed in.
result =
elements.length === 0 ? h(name, attributes) : h(name, attributes, elements)
// Restore parent schema.
ctx.schema = parentSchema
return result
}
function addAttribute(props, prop, value, ctx) {
var schema = ctx.schema
var info = find(schema, prop)
var subprop
// Ignore nully, `false`, `NaN`, and falsey known booleans.
if (
value === null ||
value === undefined ||
value === false ||
value !== value ||
(info.boolean && !value)
) {
return
}
if (value !== null && typeof value === 'object' && 'length' in value) {
// Accept `array`. Most props are space-separater.
value = (info.commaSeparated ? commas : spaces).stringify(value)
}
// Treat `true` and truthy known booleans.
if (info.boolean && ctx.hyperscript === true) {
value = ''
}
if (!info.mustUseProperty) {
if (ctx.vdom === true) {
subprop = 'attributes'
} else if (ctx.hyperscript === true) {
subprop = 'attrs'
}
}
if (subprop) {
if (props[subprop] === undefined) {
props[subprop] = {}
}
props[subprop][info.attribute] = value
} else {
props[ctx.react && info.space ? info.property : info.attribute] = value
}
}
// Check if `h` is `react.createElement`.
function react(h) {
var node = h && h('div')
return Boolean(
node && ('_owner' in node || '_store' in node) && node.key === null
)
}
// Check if `h` is `hyperscript`.
function hyperscript(h) {
return Boolean(h && h.context && h.cleanup)
}
// Check if `h` is `virtual-dom/h`.
function vdom(h) {
return h && h('div').type === 'VirtualNode'
}
function parseStyle(value, tagName) {
var result = {}
try {
style(value, iterator)
} catch (err) {
err.message = tagName + '[style]' + err.message.slice('undefined'.length)
throw err
}
return result
function iterator(name, value) {
result[styleCase(name)] = value
}
}
function styleCase(val) {
if (val.slice(0, 4) === '-ms-') {
val = 'ms-' + val.slice(4)
}
return val.replace(dashes, styleReplacer)
}
function styleReplacer($0, $1) {
return $1.toUpperCase()
}

View File

@ -0,0 +1,117 @@
'use strict'
module.exports = is
// Assert if `test` passes for `node`. When a `parent` node is known the
// `index` of node.
// eslint-disable-next-line max-params
function is(test, node, index, parent, context) {
var hasParent = parent !== null && parent !== undefined
var hasIndex = index !== null && index !== undefined
var check = convert(test)
if (
hasIndex &&
(typeof index !== 'number' || index < 0 || index === Infinity)
) {
throw new Error('Expected positive finite index or child node')
}
if (hasParent && (!is(null, parent) || !parent.children)) {
throw new Error('Expected parent node')
}
if (!node || !node.type || typeof node.type !== 'string') {
return false
}
if (hasParent !== hasIndex) {
throw new Error('Expected both parent and index')
}
return Boolean(check.call(context, node, index, parent))
}
function convert(test) {
if (typeof test === 'string') {
return typeFactory(test)
}
if (test === null || test === undefined) {
return ok
}
if (typeof test === 'object') {
return ('length' in test ? anyFactory : matchesFactory)(test)
}
if (typeof test === 'function') {
return test
}
throw new Error('Expected function, string, or object as test')
}
function convertAll(tests) {
var results = []
var length = tests.length
var index = -1
while (++index < length) {
results[index] = convert(tests[index])
}
return results
}
// Utility assert each property in `test` is represented in `node`, and each
// values are strictly equal.
function matchesFactory(test) {
return matches
function matches(node) {
var key
for (key in test) {
if (node[key] !== test[key]) {
return false
}
}
return true
}
}
function anyFactory(tests) {
var checks = convertAll(tests)
var length = checks.length
return matches
function matches() {
var index = -1
while (++index < length) {
if (checks[index].apply(this, arguments)) {
return true
}
}
return false
}
}
// Utility to convert a string into a function which checks a given nodes type
// for said string.
function typeFactory(test) {
return type
function type(node) {
return Boolean(node && node.type === test)
}
}
// Utility to return true.
function ok() {
return true
}

View File

@ -0,0 +1,22 @@
(The MIT license)
Copyright (c) 2015 Titus Wormer <tituswormer@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,113 @@
{
"_from": "unist-util-is@^2.0.0",
"_id": "unist-util-is@2.1.3",
"_inBundle": false,
"_integrity": "sha512-4WbQX2iwfr/+PfM4U3zd2VNXY+dWtZsN1fLnWEi2QQXA4qyDYAZcDMfXUX0Cu6XZUHHAO9q4nyxxLT4Awk1qUA==",
"_location": "/hast-to-hyperscript/unist-util-is",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "unist-util-is@^2.0.0",
"name": "unist-util-is",
"escapedName": "unist-util-is",
"rawSpec": "^2.0.0",
"saveSpec": null,
"fetchSpec": "^2.0.0"
},
"_requiredBy": [
"/hast-to-hyperscript"
],
"_resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-2.1.3.tgz",
"_shasum": "459182db31f4742fceaea88d429693cbf0043d20",
"_spec": "unist-util-is@^2.0.0",
"_where": "/Users/stefanfejes/Projects/30-seconds-of-python-code/node_modules/hast-to-hyperscript",
"author": {
"name": "Titus Wormer",
"email": "tituswormer@gmail.com",
"url": "https://wooorm.com"
},
"bugs": {
"url": "https://github.com/syntax-tree/hast-util-to-html/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Titus Wormer",
"email": "tituswormer@gmail.com",
"url": "https://wooorm.com"
}
],
"dependencies": {},
"deprecated": false,
"description": "Utility to check if a node passes a test",
"devDependencies": {
"browserify": "^16.0.0",
"nyc": "^14.0.0",
"prettier": "^1.0.0",
"remark-cli": "^6.0.0",
"remark-preset-wooorm": "^5.0.0",
"tape": "^4.0.0",
"tinyify": "^2.0.0",
"xo": "^0.24.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/syntax-tree/unist-util-is#readme",
"keywords": [
"unist",
"node",
"is",
"equal",
"test",
"type",
"util",
"utility"
],
"license": "MIT",
"name": "unist-util-is",
"nyc": {
"check-coverage": true,
"lines": 100,
"functions": 100,
"branches": 100
},
"prettier": {
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"bracketSpacing": false,
"semi": false,
"trailingComma": "none"
},
"remarkConfig": {
"plugins": [
"preset-wooorm"
]
},
"repository": {
"type": "git",
"url": "git+https://github.com/syntax-tree/unist-util-is.git"
},
"scripts": {
"build": "npm run build-bundle && npm run build-mangle",
"build-bundle": "browserify . -s unistUtilIs > unist-util-is.js",
"build-mangle": "browserify . -s unistUtilIs -p tinyify > unist-util-is.min.js",
"format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix",
"test": "npm run format && npm run build && npm run test-coverage",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test.js"
},
"version": "2.1.3",
"xo": {
"prettier": true,
"esnext": false,
"rules": {
"unicorn/prefer-type-error": "off"
},
"ignore": [
"unist-util-is.js"
]
}
}

View File

@ -0,0 +1,167 @@
# unist-util-is
[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]
[![Sponsors][sponsors-badge]][collective]
[![Backers][backers-badge]][collective]
[![Chat][chat-badge]][chat]
[**unist**][unist] utility to check if a node passes a test.
## Install
[npm][]:
```sh
npm install unist-util-is
```
## Usage
```js
var is = require('unist-util-is')
var node = {type: 'strong'}
var parent = {type: 'paragraph', children: [node]}
function test(node, n) {
return n === 5
}
is() // => false
is(null, {children: []}) // => false
is(null, node) // => true
is('strong', node) // => true
is('emphasis', node) // => false
is(node, node) // => true
is({type: 'paragraph'}, parent) // => true
is({type: 'strong'}, parent) // => false
is(test, node) // => false
is(test, node, 4, parent) // => false
is(test, node, 5, parent) // => true
```
## API
### `is(test, node[, index, parent[, context]])`
###### Parameters
* `test` ([`Function`][test], `string`, `Object`, or `Array.<Test>`, optional)
— When not given, checks if `node` is a [`Node`][node].
When `string`, works like passing `node => node.type === test`.
When `array`, checks if any one of the subtests pass.
When `object`, checks that all keys in `test` are in `node`,
and that they have strictly equal values
* `node` ([`Node`][node]) — Node to check. `false` is returned
* `index` (`number`, optional) — [Index][] of `node` in `parent`
* `parent` ([`Node`][node], optional) — [Parent][] of `node`
* `context` (`*`, optional) — Context object to invoke `test` with
###### Returns
`boolean` — Whether `test` passed *and* `node` is a [`Node`][node] (object
with `type` set to a non-empty `string`).
#### `function test(node[, index, parent])`
###### Parameters
* `node` (`Node`) — Node to test
* `index` (`number?`) — Position of `node` in `parent`
* `parent` (`Node?`) — Parent of `node`
###### Context
`*` — The to `is` given `context`.
###### Returns
`boolean?` — Whether `node` matches.
## Related
* [`unist-util-find-after`](https://github.com/syntax-tree/unist-util-find-after)
— Find a node after another node
* [`unist-util-find-before`](https://github.com/syntax-tree/unist-util-find-before)
— Find a node before another node
* [`unist-util-find-all-after`](https://github.com/syntax-tree/unist-util-find-all-after)
— Find all nodes after another node
* [`unist-util-find-all-before`](https://github.com/syntax-tree/unist-util-find-all-before)
— Find all nodes before another node
* [`unist-util-find-all-between`](https://github.com/mrzmmr/unist-util-find-all-between)
— Find all nodes between two nodes
* [`unist-util-find`](https://github.com/blahah/unist-util-find)
— Find nodes matching a predicate
* [`unist-util-filter`](https://github.com/eush77/unist-util-filter)
— Create a new tree with nodes that pass a check
* [`unist-util-remove`](https://github.com/eush77/unist-util-remove)
— Remove nodes from tree
## Contribute
See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
started.
See [`support.md`][support] for ways to get help.
This project has a [Code of Conduct][coc].
By interacting with this repository, organisation, or community you agree to
abide by its terms.
## License
[MIT][license] © [Titus Wormer][author]
<!-- Definitions -->
[build-badge]: https://img.shields.io/travis/syntax-tree/unist-util-is.svg
[build]: https://travis-ci.org/syntax-tree/unist-util-is
[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/unist-util-is.svg
[coverage]: https://codecov.io/github/syntax-tree/unist-util-is
[downloads-badge]: https://img.shields.io/npm/dm/unist-util-is.svg
[downloads]: https://www.npmjs.com/package/unist-util-is
[size-badge]: https://img.shields.io/bundlephobia/minzip/unist-util-is.svg
[size]: https://bundlephobia.com/result?p=unist-util-is
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
[collective]: https://opencollective.com/unified
[chat-badge]: https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg
[chat]: https://spectrum.chat/unified/syntax-tree
[npm]: https://docs.npmjs.com/cli/install
[license]: license
[author]: https://wooorm.com
[contributing]: https://github.com/syntax-tree/.github/blob/master/contributing.md
[support]: https://github.com/syntax-tree/.github/blob/master/support.md
[coc]: https://github.com/syntax-tree/.github/blob/master/code-of-conduct.md
[unist]: https://github.com/syntax-tree/unist
[node]: https://github.com/syntax-tree/unist#node
[parent]: https://github.com/syntax-tree/unist#parent-1
[index]: https://github.com/syntax-tree/unist#index
[test]: #function-testnode-index-parent

134
node_modules/hast-to-hyperscript/package.json generated vendored Normal file
View File

@ -0,0 +1,134 @@
{
"_from": "hast-to-hyperscript@^5.0.0",
"_id": "hast-to-hyperscript@5.0.0",
"_inBundle": false,
"_integrity": "sha512-DLl3eYTz8uwwzEubDUdCChsR5t5b2ne+yvHrA2h58Suq/JnN3+Gsb9Tc4iZoCCsykmFUc6UUpwxTmQXs0akSeg==",
"_location": "/hast-to-hyperscript",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "hast-to-hyperscript@^5.0.0",
"name": "hast-to-hyperscript",
"escapedName": "hast-to-hyperscript",
"rawSpec": "^5.0.0",
"saveSpec": null,
"fetchSpec": "^5.0.0"
},
"_requiredBy": [
"/hast-util-to-parse5"
],
"_resolved": "https://registry.npmjs.org/hast-to-hyperscript/-/hast-to-hyperscript-5.0.0.tgz",
"_shasum": "5106cbba78edb7c95e2e8a49079371eb196c1ced",
"_spec": "hast-to-hyperscript@^5.0.0",
"_where": "/Users/stefanfejes/Projects/30-seconds-of-python-code/node_modules/hast-util-to-parse5",
"author": {
"name": "Titus Wormer",
"email": "tituswormer@gmail.com",
"url": "http://wooorm.com"
},
"bugs": {
"url": "https://github.com/syntax-tree/hast-to-hyperscript/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Titus Wormer",
"email": "tituswormer@gmail.com",
"url": "http://wooorm.com"
},
{
"name": "Jannis Redmann",
"email": "mail@jannisr.de"
},
{
"name": "Koto Hajime",
"email": "toxictoxer@gmail.com"
}
],
"dependencies": {
"comma-separated-tokens": "^1.0.0",
"property-information": "^4.0.0",
"space-separated-tokens": "^1.0.0",
"style-to-object": "^0.2.1",
"unist-util-is": "^2.0.0",
"web-namespaces": "^1.1.2"
},
"deprecated": false,
"description": "Transform HAST to something else through a hyperscript DSL",
"devDependencies": {
"browserify": "^16.0.0",
"hyperscript": "^2.0.2",
"nyc": "^12.0.0",
"prettier": "^1.13.5",
"react": "^16.1.1",
"react-dom": "^16.1.1",
"rehype": "^5.0.0",
"remark-cli": "^5.0.0",
"remark-preset-wooorm": "^4.0.0",
"tape": "^4.0.0",
"tinyify": "^2.4.3",
"unist-builder": "^1.0.1",
"vdom-to-html": "^2.3.1",
"virtual-dom": "^2.1.1",
"xo": "^0.21.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/syntax-tree/hast-to-hyperscript#readme",
"keywords": [
"hast",
"rehype",
"vdom",
"virtual",
"dom",
"hyperscript",
"dsl",
"html"
],
"license": "MIT",
"name": "hast-to-hyperscript",
"nyc": {
"check-coverage": true,
"lines": 100,
"functions": 100,
"branches": 100
},
"prettier": {
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"bracketSpacing": false,
"semi": false,
"trailingComma": "none"
},
"remarkConfig": {
"plugins": [
"preset-wooorm"
]
},
"repository": {
"type": "git",
"url": "git+https://github.com/syntax-tree/hast-to-hyperscript.git"
},
"scripts": {
"build": "npm run build-bundle && npm run build-mangle",
"build-bundle": "browserify index.js -s hastToHyperscript > hast-to-hyperscript.js",
"build-mangle": "browserify index.js -p tinyify -s hastToHyperscript > hast-to-hyperscript.min.js",
"format": "remark . -qfo && prettier --write '**/*.js' && xo --fix",
"test": "npm run format && npm run build && npm run test-coverage",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test.js"
},
"version": "5.0.0",
"xo": {
"prettier": true,
"esnext": false,
"rules": {
"unicorn/prefer-type-error": "off",
"guard-for-in": "off",
"no-self-compare": "off"
}
}
}

161
node_modules/hast-to-hyperscript/readme.md generated vendored Normal file
View File

@ -0,0 +1,161 @@
# hast-to-hyperscript [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov]
Transform [HAST][] to something else through a [hyperscript][] DSL.
## Installation
[npm][]:
```bash
npm install hast-to-hyperscript
```
## Usage
```javascript
var toH = require('hast-to-hyperscript')
var h = require('hyperscript')
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
console.log(doc)
```
Yields:
```html
<p class="bravo" id="alpha">charlie <strong>delta</strong> echo.</p>
```
## API
### `toH(h, node[, options|prefix])`
Transform [HAST][] to something else through a [hyperscript][] DSL.
###### Parameters
* `h` ([`Function`][h])
* `node` ([`Element`][element])
* `prefix` — Treated as `{prefix: prefix}`
* `options.prefix` (`string` or `boolean`, optional)
— Prefix to use as a prefix for keys passed in `attrs` to `h()`,
this behaviour is turned off by passing `false`, turned on by passing
a `string`. By default, `h-` is used as a prefix if the given `h`
is detected as being `virtual-dom/h` or `React.createElement`
* `options.space` (enum, `'svg'` or `'html'`, default: `'html'`)
— Whether `node` is in the `'html'` or `'svg'` space.
If an `svg` element is found when inside the HTML space, `toH` automatically
switches to the SVG space when entering the element, and switches back when
leaving
###### 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 invoking `h()` previously
###### Returns
`*` — Anything.
###### Caveats
**Nodes**: Most hyperscript implementations only support elements and text (as
leave nodes). HAST supports `doctype`, `comment`, and `root` as well.
* If anything other than an `element` or `root` node is given,
`hast-to-hyperscript` throws
* If a `root` is given with one element child, that element is
transformed
* If a `root` with no children, a non-element only child, or more than one
children, the children are wrapped in a `div` element
If unknown nodes are found deeper in the tree, they are ignored: only `text`
and `element` nodes are transformed.
**Support**: Although there are lots of libs mentioning support for this
interface, there are significant differences between them. For example,
hyperscript doesnt 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:
* [`React.createElement`][react]
* [`virtual-dom/h`][vdom]
* [`hyperscript`][hyperscript]
## Related
* [`hastscript`][hastscript]
## Contribute
See [`contributing.md` in `syntax-tree/hast`][contributing] for ways to get
started.
This organisation has a [Code of Conduct][coc]. By interacting with this
repository, organisation, or community you agree to abide by its terms.
## License
[MIT][license] © [Titus Wormer][author]
<!-- Definitions -->
[travis-badge]: https://img.shields.io/travis/syntax-tree/hast-to-hyperscript.svg
[travis]: https://travis-ci.org/syntax-tree/hast-to-hyperscript
[codecov-badge]: https://img.shields.io/codecov/c/github/syntax-tree/hast-to-hyperscript.svg
[codecov]: https://codecov.io/github/syntax-tree/hast-to-hyperscript
[npm]: https://docs.npmjs.com/cli/install
[license]: LICENSE
[author]: http://wooorm.com
[hast]: https://github.com/syntax-tree/hast
[element]: https://github.com/syntax-tree/hast#element
[vdom]: https://github.com/Matt-Esch/virtual-dom/tree/master/virtual-hyperscript
[hyperscript]: https://github.com/dominictarr/hyperscript
[h]: #function-hname-attrs-children
[react]: https://facebook.github.io/react/docs/glossary.html#react-elements
[hastscript]: https://github.com/syntax-tree/hastscript
[contributing]: https://github.com/syntax-tree/hast/blob/master/contributing.md
[coc]: https://github.com/syntax-tree/hast/blob/master/code-of-conduct.md