New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hast-to-hyperscript

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hast-to-hyperscript - npm Package Compare versions

Comparing version 7.0.0 to 7.0.1

10

index.js

@@ -70,4 +70,3 @@ 'use strict'

// Transform a HAST node through a hyperscript interface
// to *anything*!
// Transform a hast node through a hyperscript interface to *anything*!
function toH(h, node, ctx) {

@@ -135,4 +134,4 @@ var parentSchema = ctx.schema

// Ensure no React warnings are triggered for
// void elements having children passed in.
// Ensure no React warnings are triggered for void elements having children
// passed in.
result =

@@ -166,3 +165,4 @@ elements.length === 0 ? h(name, attributes) : h(name, attributes, elements)

if (value !== null && typeof value === 'object' && 'length' in value) {
// Accept `array`. Most props are space-separater.
// Accept `array`.
// Most props are space-separated.
value = (info.commaSeparated ? commas : spaces).stringify(value)

@@ -169,0 +169,0 @@ }

{
"name": "hast-to-hyperscript",
"version": "7.0.0",
"version": "7.0.1",
"description": "Transform HAST to something else through a hyperscript DSL",

@@ -37,21 +37,21 @@ "license": "MIT",

"browserify": "^16.0.0",
"hyperscript": "^2.0.2",
"hyperscript": "^2.0.0",
"nyc": "^14.0.0",
"prettier": "^1.13.5",
"react": "^16.6.1",
"react-dom": "^16.6.1",
"prettier": "^1.0.0",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"rehype": "^7.0.0",
"remark-cli": "^6.0.0",
"remark-preset-wooorm": "^4.0.0",
"remark-preset-wooorm": "^5.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",
"vue": "^2.6.10",
"vue-server-renderer": "^2.6.10",
"tinyify": "^2.0.0",
"unist-builder": "^1.0.0",
"vdom-to-html": "^2.0.0",
"virtual-dom": "^2.0.0",
"vue": "^2.0.0",
"vue-server-renderer": "^2.0.0",
"xo": "^0.24.0"
},
"scripts": {
"format": "remark . -qfo && prettier --write '**/*.js' && xo --fix",
"format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix",
"build-bundle": "browserify index.js -s hastToHyperscript > hast-to-hyperscript.js",

@@ -58,0 +58,0 @@ "build-mangle": "browserify index.js -s hastToHyperscript -p tinyify > hast-to-hyperscript.min.js",

@@ -1,10 +0,19 @@

# hast-to-hyperscript [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov]
# hast-to-hyperscript
Transform [HAST][] to something else through a [hyperscript][] DSL.
[![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]
## Installation
[**hast**][hast] utility to transform a [*tree*][tree] to something else through
a [hyperscript][] DSL.
## Install
[npm][]:
```bash
```sh
npm install hast-to-hyperscript

@@ -15,3 +24,3 @@ ```

```javascript
```js
var toH = require('hast-to-hyperscript')

@@ -50,10 +59,11 @@ var h = require('hyperscript')

### `toH(h, node[, options|prefix])`
### `toH(h, tree[, options|prefix])`
Transform [HAST][] to something else through a [hyperscript][] DSL.
Transform a [**hast**][hast] [*tree*][tree] to something else through a
[hyperscript][] DSL.
###### Parameters
* `h` ([`Function`][h])
* `node` ([`Element`][element])
* `h` ([`Function`][h]) — Hyperscript function
* `tree` ([`Node`][node]) — [*Tree*][tree] to transform
* `prefix` — Treated as `{prefix: prefix}`

@@ -63,4 +73,5 @@ * `options.prefix` (`string` or `boolean`, optional)

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`
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'`)

@@ -70,3 +81,3 @@ — Whether `node` is in the `'html'` or `'svg'` space.

switches to the SVG space when entering the element, and switches back when
leaving
exiting

@@ -79,3 +90,3 @@ ###### Returns

Transform [HAST][] to something else through a hyperscript DSL.
Create an [*element*][element] from the given values.

@@ -86,4 +97,4 @@ ###### Parameters

* `attrs` (`Object.<string>`) — Attributes to set
* `children` (`Array.<* | string>`) — List of children and text,
where children are the result of invoking `h()` previously
* `children` (`Array.<* | string>`) — List of children (results of previously
invoking `h()`)

@@ -94,23 +105,31 @@ ###### Returns

###### Caveats
##### Caveats
**Nodes**: Most hyperscript implementations only support elements and text (as
leave nodes). HAST supports `doctype`, `comment`, and `root` as well.
###### Nodes
* 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
Most Hyperscript implementations only support [*elements*][element] and
[*texts*][text].
[**hast**][hast] supports [*doctype*][doctype], [*comment*][comment], and
[*root*][root] as well.
If unknown nodes are found deeper in the tree, they are ignored: only `text`
and `element` nodes are transformed.
* If anything other than an `element` or `root` node is given, `toH` throws
* If a [*root*][root] is given with no [*children*][child], an empty `div`
[*element*][element] is returned
* If a [*root*][root] is given with one [*element*][element] [*child*][child],
that element is transformed
* Otherwise, the children are wrapped in a `div` [*element*][element]
**Support**: 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:
If unknown nodes (a node with a [*type*][type] not defined by [**hast**][hast])
are found as [*descendants*][descendant] of the given [*tree*][tree], they are
ignored: only [*text*][text] and [*element*][element] are transformed.
###### Support
Although there are lots of libraries mentioning support for a hyperscript-like
interface, there are significant differences between them.
For example, [`hyperscript`][hyperscript] doesn’t support classes in `attrs` and
[`virtual-dom/h`][vdom] needs an `attributes` object inside `attrs` most of the
time.
`toH` works around these differences for:
* [`React.createElement`][react]

@@ -127,7 +146,9 @@ * Vue’s [`createElement`][vue]

See [`contributing.md` in `syntax-tree/hast`][contributing] for ways to get
See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
started.
See [`support.md`][support] for ways to get help.
This organisation has a [Code of Conduct][coc]. By interacting with this
repository, organisation, or community you agree to abide by its terms.
This project has a [Code of Conduct][coc].
By interacting with this repository, organisation, or community you agree to
abide by its terms.

@@ -140,10 +161,28 @@ ## License

[travis-badge]: https://img.shields.io/travis/syntax-tree/hast-to-hyperscript.svg
[build-badge]: https://img.shields.io/travis/syntax-tree/hast-to-hyperscript.svg
[travis]: https://travis-ci.org/syntax-tree/hast-to-hyperscript
[build]: https://travis-ci.org/syntax-tree/hast-to-hyperscript
[codecov-badge]: https://img.shields.io/codecov/c/github/syntax-tree/hast-to-hyperscript.svg
[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/hast-to-hyperscript.svg
[codecov]: https://codecov.io/github/syntax-tree/hast-to-hyperscript
[coverage]: https://codecov.io/github/syntax-tree/hast-to-hyperscript
[downloads-badge]: https://img.shields.io/npm/dm/hast-to-hyperscript.svg
[downloads]: https://www.npmjs.com/package/hast-to-hyperscript
[size-badge]: https://img.shields.io/bundlephobia/minzip/hast-to-hyperscript.svg
[size]: https://bundlephobia.com/result?p=hast-to-hyperscript
[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

@@ -155,14 +194,14 @@

[hast]: https://github.com/syntax-tree/hast
[contributing]: https://github.com/syntax-tree/.github/blob/master/contributing.md
[element]: https://github.com/syntax-tree/hast#element
[support]: https://github.com/syntax-tree/.github/blob/master/support.md
[coc]: https://github.com/syntax-tree/.github/blob/master/code-of-conduct.md
[vdom]: https://github.com/Matt-Esch/virtual-dom/tree/master/virtual-hyperscript
[hyperscript]: https://github.com/dominictarr/hyperscript
[hyperscript]: https://github.com/hyperhype/hyperscript
[h]: #function-hname-attrs-children
[react]: https://reactjs.org/docs/glossary.html#react-elements
[react]: https://facebook.github.io/react/docs/glossary.html#react-elements
[vue]: https://vuejs.org/v2/guide/render-function.html#createElement-Arguments

@@ -172,4 +211,24 @@

[contributing]: https://github.com/syntax-tree/hast/blob/master/contributing.md
[tree]: https://github.com/syntax-tree/unist#tree
[coc]: https://github.com/syntax-tree/hast/blob/master/code-of-conduct.md
[child]: https://github.com/syntax-tree/unist#child
[type]: https://github.com/syntax-tree/unist#type
[descendant]: https://github.com/syntax-tree/unist#descendant
[hast]: https://github.com/syntax-tree/hast
[node]: https://github.com/syntax-tree/hast#nodes
[text]: https://github.com/syntax-tree/hast#text
[doctype]: https://github.com/syntax-tree/hast#doctype
[root]: https://github.com/syntax-tree/hast#root
[comment]: https://github.com/syntax-tree/hast#comment
[element]: https://github.com/syntax-tree/hast#element
[h]: #function-hname-attrs-children
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc