Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mdast-util-to-hast

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mdast-util-to-hast - npm Package Compare versions

Comparing version 3.0.3 to 3.0.4

1

lib/all.js

@@ -8,3 +8,2 @@ 'use strict'

/* Transform the children of `parent`. */
function all(h, parent) {

@@ -11,0 +10,0 @@ var nodes = parent.children || []

@@ -9,3 +9,2 @@ 'use strict'

/* Transform all footnote definitions, if any. */
function generateFootnotes(h) {

@@ -12,0 +11,0 @@ var footnotes = h.footnotes

@@ -8,5 +8,4 @@ 'use strict'

/* Transform a block quote. */
function blockquote(h, node) {
return h(node, 'blockquote', wrap(all(h, node), true))
}

@@ -7,5 +7,4 @@ 'use strict'

/* Transform an inline break. */
function hardBreak(h, node) {
return [h(node, 'br'), u('text', '\n')]
}

@@ -8,3 +8,2 @@ 'use strict'

/* Transform a code block. */
function code(h, node) {

@@ -11,0 +10,0 @@ var value = node.value ? detab(node.value + '\n') : ''

@@ -7,5 +7,4 @@ 'use strict'

/* Transform deletions. */
function strikethrough(h, node) {
return h(node, 'del', all(h, node))
}

@@ -7,5 +7,4 @@ 'use strict'

/* Transform emphasis. */
function emphasis(h, node) {
return h(node, 'em', all(h, node))
}

@@ -7,3 +7,2 @@ 'use strict'

/* Transform a reference to a footnote. */
function footnoteReference(h, node) {

@@ -10,0 +9,0 @@ var identifier = node.identifier

@@ -7,3 +7,2 @@ 'use strict'

/* Transform an inline footnote. */
function footnote(h, node) {

@@ -10,0 +9,0 @@ var identifiers = []

@@ -7,5 +7,4 @@ 'use strict'

/* Transform a heading. */
function heading(h, node) {
return h(node, 'h' + node.depth, all(h, node))
}

3

lib/handlers/html.js

@@ -7,6 +7,5 @@ 'use strict'

/* Return either a `raw` node, in dangerous mode, or
* nothing. */
// Return either a `raw` node, in dangerous mode, or nothing.
function html(h, node) {
return h.dangerous ? h.augment(node, u('raw', node.value)) : null
}

@@ -8,3 +8,2 @@ 'use strict'

/* Transform a reference to an image. */
function imageReference(h, node) {

@@ -11,0 +10,0 @@ var def = h.definition(node.identifier)

@@ -7,3 +7,2 @@ 'use strict'

/* Transform an image. */
function image(h, node) {

@@ -10,0 +9,0 @@ var props = {src: normalize(node.url), alt: node.alt}

@@ -32,5 +32,5 @@ 'use strict'

/* Return nothing for nodes which are ignored. */
// Return nothing for nodes which are ignored.
function ignore() {
return null
}

@@ -8,5 +8,4 @@ 'use strict'

/* Transform inline code. */
function inlineCode(h, node) {
return h(node, 'code', [u('text', collapse(node.value))])
}

@@ -9,3 +9,2 @@ 'use strict'

/* Transform a reference to a link. */
function linkReference(h, node) {

@@ -12,0 +11,0 @@ var def = h.definition(node.identifier)

@@ -8,3 +8,2 @@ 'use strict'

/* Transform a link. */
function link(h, node) {

@@ -11,0 +10,0 @@ var props = {href: normalize(node.url)}

@@ -9,3 +9,2 @@ 'use strict'

/* Transform a list-item. */
function listItem(h, node, parent) {

@@ -48,3 +47,3 @@ var children = node.children

/* According to github-markdown-css, this class hides bullet. */
// According to github-markdown-css, this class hides bullet.
props.className = ['task-list-item']

@@ -51,0 +50,0 @@ }

@@ -8,3 +8,2 @@ 'use strict'

/* Transform a list. */
function list(h, node) {

@@ -11,0 +10,0 @@ var props = {}

@@ -7,5 +7,4 @@ 'use strict'

/* Transform a paragraph. */
function paragraph(h, node) {
return h(node, 'p', all(h, node))
}

@@ -9,5 +9,4 @@ 'use strict'

/* Transform a `root`. */
function root(h, node) {
return h.augment(node, u('root', wrap(all(h, node))))
}

@@ -7,5 +7,4 @@ 'use strict'

/* Transform importance. */
function strong(h, node) {
return h(node, 'strong', all(h, node))
}

@@ -9,3 +9,2 @@ 'use strict'

/* Transform a table. */
function table(h, node) {

@@ -12,0 +11,0 @@ var rows = node.children

@@ -8,5 +8,4 @@ 'use strict'

/* Transform text. */
function text(h, node) {
return h.augment(node, u('text', trimLines(node.value)))
}

@@ -5,5 +5,4 @@ 'use strict'

/* Transform a thematic break / horizontal rule. */
function thematicBreak(h, node) {
return h(node, 'hr')
}
'use strict'
module.exports = toHAST
module.exports = toHast

@@ -15,3 +15,3 @@ var xtend = require('xtend')

/* Factory to transform. */
// Factory to transform.
function factory(tree, options) {

@@ -31,4 +31,3 @@ var settings = options || {}

/* Finalise the created `right`, a HAST node, from
* `left`, an MDAST node. */
// Finalise the created `right`, a hast node, from `left`, an mdast node.
function augment(left, right) {

@@ -38,3 +37,3 @@ var data

/* Handle `data.hName`, `data.hProperties, `hChildren`. */
// Handle `data.hName`, `data.hProperties, `hChildren`.
if (left && 'data' in left) {

@@ -68,3 +67,3 @@ data = left.data

/* Create an element for a `node`. */
// Create an element for a `node`.
function h(node, tagName, props, children) {

@@ -93,4 +92,4 @@ if (

/* Transform `tree`, which is an MDAST node, to a HAST node. */
function toHAST(tree, options) {
// Transform `tree`, which is an mdast node, to a hast node.
function toHast(tree, options) {
var h = factory(tree, options)

@@ -97,0 +96,0 @@ var node = one(h, tree)

@@ -10,3 +10,3 @@ 'use strict'

/* Transform an unknown node. */
// Transform an unknown node.
function unknown(h, node) {

@@ -20,3 +20,3 @@ if (text(node)) {

/* Visit a node. */
// Visit a node.
function one(h, node, parent) {

@@ -26,3 +26,3 @@ var type = node && node.type

/* Fail on non-nodes. */
// Fail on non-nodes.
if (!type) {

@@ -35,3 +35,3 @@ throw new Error('Expected node, got `' + node + '`')

/* Check if the node should be renderered a text node. */
// Check if the node should be renderered a text node.
function text(node) {

@@ -38,0 +38,0 @@ var data = node.data || {}

@@ -8,3 +8,3 @@ 'use strict'

/* Return the content of a reference without definition as markdown. */
// Return the content of a reference without definition as markdown.
function revert(h, node) {

@@ -11,0 +11,0 @@ var subtype = node.referenceType

@@ -7,4 +7,4 @@ 'use strict'

/* Wrap `nodes` with newlines between each entry.
* Optionally adds newlines at the start and end. */
// Wrap `nodes` with newlines between each entry. Optionally adds newlines at
// the start and end.
function wrap(nodes, loose) {

@@ -11,0 +11,0 @@ var result = []

{
"name": "mdast-util-to-hast",
"version": "3.0.3",
"description": "Transform MDAST to HAST",
"version": "3.0.4",
"description": "Transform mdast to hast",
"license": "MIT",

@@ -46,4 +46,4 @@ "keywords": [

"format": "remark . -qfo && prettier --write '**/*.js' && xo --fix",
"build-bundle": "browserify index.js -s mdastUtilToHAST > mdast-util-to-hast.js",
"build-mangle": "browserify index.js -s mdastUtilToHAST -p tinyify > mdast-util-to-hast.min.js",
"build-bundle": "browserify index.js -s mdastUtilToHast > mdast-util-to-hast.js",
"build-mangle": "browserify index.js -s mdastUtilToHast -p tinyify > mdast-util-to-hast.min.js",
"build": "npm run build-bundle && npm run build-mangle",

@@ -50,0 +50,0 @@ "test-api": "node test",

@@ -8,3 +8,3 @@ # mdast-util-to-hast

Transform [MDAST][] to [HAST][].
Transform [mdast][] to [hast][].

@@ -36,3 +36,3 @@ > **Note**: You probably want to use [remark-rehype][].

var vfile = require('to-vfile')
var toHAST = require('mdast-util-to-hast')
var toHast = require('mdast-util-to-hast')

@@ -43,3 +43,3 @@ var tree = unified()

console.log(inspect(toHAST(tree)))
console.log(inspect(toHast(tree)))
```

@@ -60,5 +60,5 @@

### `toHAST(node[, options])`
### `toHast(node[, options])`
Transform the given [MDAST][] tree to a [HAST][] tree.
Transform the given [mdast][] tree to a [hast][] tree.

@@ -79,3 +79,3 @@ ##### Options

Object mapping [MDAST nodes][mdast] to functions handling those elements.
Object mapping [mdast nodes][mdast] to functions handling those elements.
Take a look at [`lib/handlers/`][handlers] for examples.

@@ -94,6 +94,6 @@

* Unknown nodes with `value` are transformed to `text` nodes
* [`node.data.hName`][hname] configures the HAST element’s tag-name
* [`node.data.hProperties`][hproperties] is mixed into the HAST element’s
* [`node.data.hName`][hname] configures the hast element’s tag-name
* [`node.data.hProperties`][hproperties] is mixed into the hast element’s
properties
* [`node.data.hChildren`][hchildren] configures the HAST element’s children
* [`node.data.hChildren`][hchildren] configures the hast element’s children

@@ -105,3 +105,3 @@ ##### Examples

`node.data.hName` sets the tag-name of an element.
The following [MDAST][]:
The following [mdast][]:

@@ -116,3 +116,3 @@ ```js

Yields, in [HAST][]:
Yields, in [hast][]:

@@ -131,3 +131,3 @@ ```js

`node.data.hProperties` in sets the properties of an element.
The following [MDAST][]:
The following [mdast][]:

@@ -144,3 +144,3 @@ ```js

Yields, in [HAST][]:
Yields, in [hast][]:

@@ -163,3 +163,3 @@ ```js

`node.data.hChildren` sets the children of an element.
The following [MDAST][]:
The following [mdast][]:

@@ -185,3 +185,3 @@ ```js

Yields, in [HAST][] (**note**: the `pre` and `language-js` class are normal
Yields, in [hast][] (**note**: the `pre` and `language-js` class are normal
`mdast-util-to-hast` functionality):

@@ -214,7 +214,7 @@

* [`mdast-util-to-nlcst`](https://github.com/syntax-tree/mdast-util-to-nlcst)
— Transform MDAST to NLCST
— Transform mdast to nlcst
* [`hast-util-sanitize`](https://github.com/syntax-tree/hast-util-sanitize)
— Sanitize HAST nodes
— Sanitize hast nodes
* [`hast-util-to-mdast`](https://github.com/syntax-tree/hast-util-to-mdast)
— Transform HAST to MDAST
— Transform hast to mdast
* [`remark-rehype`](https://github.com/remarkjs/remark-rehype)

@@ -239,17 +239,17 @@ — rehype support for remark

[build-badge]: https://img.shields.io/travis/syntax-tree/hast-util-to-hast.svg
[build-badge]: https://img.shields.io/travis/syntax-tree/mdast-util-to-hast.svg
[build]: https://travis-ci.org/syntax-tree/hast-util-to-hast
[build]: https://travis-ci.org/syntax-tree/mdast-util-to-hast
[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/hast-util-to-hast.svg
[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/mdast-util-to-hast.svg
[coverage]: https://codecov.io/github/syntax-tree/hast-util-to-hast
[coverage]: https://codecov.io/github/syntax-tree/mdast-util-to-hast
[downloads-badge]: https://img.shields.io/npm/dm/hast-util-to-hast.svg
[downloads-badge]: https://img.shields.io/npm/dm/mdast-util-to-hast.svg
[downloads]: https://www.npmjs.com/package/hast-util-to-hast
[downloads]: https://www.npmjs.com/package/mdast-util-to-hast
[chat-badge]: https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg
[chat]: https://spectrum.chat/unified/rehype
[chat]: https://spectrum.chat/unified/remark

@@ -256,0 +256,0 @@ [npm]: https://docs.npmjs.com/cli/install

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