mdast-util-to-hast
Advanced tools
Comparing version 6.0.0 to 6.0.1
@@ -18,3 +18,4 @@ 'use strict' | ||
// No need to check if `identifier` exists, as it’s guaranteed to not exist. | ||
// No need to check if `identifier` exists in `footnoteOrder`, it’s guaranteed | ||
// to not exist because we just generated it. | ||
footnoteOrder.push(identifier) | ||
@@ -21,0 +22,0 @@ |
@@ -7,5 +7,5 @@ 'use strict' | ||
// Return either a `raw` node, in dangerous mode, or nothing. | ||
// Return either a `raw` node in dangerous mode, otherwise nothing. | ||
function html(h, node) { | ||
return h.dangerous ? h.augment(node, u('raw', node.value)) : null | ||
} |
@@ -32,5 +32,5 @@ 'use strict' | ||
// Return nothing for nodes which are ignored. | ||
// Return nothing for nodes that are ignored. | ||
function ignore() { | ||
return null | ||
} |
@@ -21,3 +21,3 @@ 'use strict' | ||
/* Tight lists should not render 'paragraph' nodes as 'p' tags */ | ||
// Tight lists should not render `paragraph` nodes as `p` elements. | ||
if (loose) { | ||
@@ -61,2 +61,3 @@ result = raw | ||
// According to github-markdown-css, this class hides bullet. | ||
// See: <https://github.com/sindresorhus/github-markdown-css>. | ||
props.className = ['task-list-item'] | ||
@@ -63,0 +64,0 @@ } |
@@ -22,3 +22,3 @@ 'use strict' | ||
// Like GitHub, add a class for custom styling | ||
// Like GitHub, add a class for custom styling. | ||
while (++index < length) { | ||
@@ -25,0 +25,0 @@ if ( |
@@ -39,3 +39,3 @@ 'use strict' | ||
// Handle `data.hName`, `data.hProperties, `hChildren`. | ||
// Handle `data.hName`, `data.hProperties, `data.hChildren`. | ||
if (left && 'data' in left) { | ||
@@ -69,3 +69,3 @@ data = left.data | ||
// Create an element for a `node`. | ||
// Create an element for `node`. | ||
function h(node, tagName, props, children) { | ||
@@ -93,3 +93,3 @@ if ( | ||
// Mimick CM behavior of link definitions. | ||
// https://github.com/syntax-tree/mdast-util-definitions/blob/8d48e57/index.js#L26 | ||
// See: <https://github.com/syntax-tree/mdast-util-definitions/blob/8d48e57/index.js#L26>. | ||
if (!own.call(footnoteById, id)) { | ||
@@ -96,0 +96,0 @@ footnoteById[id] = definition |
@@ -32,3 +32,3 @@ 'use strict' | ||
// Check if the node should be renderered a text node. | ||
// Check if the node should be renderered as a text node. | ||
function text(node) { | ||
@@ -35,0 +35,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 line feeds between each entry. | ||
// Optionally adds line feeds at the start and end. | ||
function wrap(nodes, loose) { | ||
@@ -11,0 +11,0 @@ var result = [] |
{ | ||
"name": "mdast-util-to-hast", | ||
"version": "6.0.0", | ||
"version": "6.0.1", | ||
"description": "Transform mdast to hast", | ||
@@ -37,11 +37,11 @@ "license": "MIT", | ||
"nyc": "^14.0.0", | ||
"prettier": "^1.13.3", | ||
"prettier": "^1.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", | ||
"tinyify": "^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 mdastUtilToHast > mdast-util-to-hast.js", | ||
@@ -71,7 +71,2 @@ "build-mangle": "browserify index.js -s mdastUtilToHast -p tinyify > mdast-util-to-hast.min.js", | ||
"esnext": false, | ||
"rules": { | ||
"no-var": "off", | ||
"prefer-arrow-callback": "off", | ||
"guard-for-in": "off" | ||
}, | ||
"ignores": [ | ||
@@ -78,0 +73,0 @@ "mdast-util-to-hast.js" |
@@ -6,13 +6,16 @@ # mdast-util-to-hast | ||
[![Downloads][downloads-badge]][downloads] | ||
[![Size][size-badge]][size] | ||
[![Sponsors][sponsors-badge]][collective] | ||
[![Backers][backers-badge]][collective] | ||
[![Chat][chat-badge]][chat] | ||
Transform [mdast][] to [hast][]. | ||
[**mdast**][mdast] utility to transform to [**hast**][hast]. | ||
> **Note**: You probably want to use [remark-rehype][]. | ||
> **Note**: You probably want to use [`remark-rehype`][remark-rehype]. | ||
## Installation | ||
## Install | ||
[npm][]: | ||
```bash | ||
```sh | ||
npm install mdast-util-to-hast | ||
@@ -31,3 +34,3 @@ ``` | ||
```javascript | ||
```js | ||
var inspect = require('unist-util-inspect') | ||
@@ -61,3 +64,3 @@ var unified = require('unified') | ||
Transform the given [mdast][] tree to a [hast][] tree. | ||
Transform the given [mdast][] [tree][] to a [hast][] [tree][]. | ||
@@ -68,4 +71,8 @@ ##### Options | ||
Whether to allow `html` nodes and inject them as raw HTML (`boolean`, default: | ||
`false`). Only do this when compiling later with `hast-util-to-html`. | ||
Whether to allow [`html`][mdast-html] nodes and inject them as raw HTML | ||
(`boolean`, default: `false`). | ||
Only do this when using [`hast-util-to-html`][to-html] | ||
([`rehype-stringify`][rehype-stringify]) or [`hast-util-raw`][raw] | ||
([`rehype-raw`][rehype-raw]) later: `raw` nodes are not a standard part of | ||
[hast][]. | ||
@@ -75,7 +82,8 @@ ###### `options.commonmark` | ||
Set to `true` (default: `false`) to prefer the first when duplicate definitions | ||
are found. The default behaviour is to prefer the last duplicate definition. | ||
are found. | ||
The default behaviour is to prefer the last duplicate definition. | ||
###### `options.handlers` | ||
Object mapping [mdast nodes][mdast] to functions handling those elements. | ||
Object mapping [mdast][] [nodes][mdast-node] to functions handling them. | ||
Take a look at [`lib/handlers/`][handlers] for examples. | ||
@@ -85,11 +93,12 @@ | ||
[`HASTNode`][hast]. | ||
[`HastNode`][hast-node]. | ||
##### Notes | ||
* `yaml` and `toml` nodes are ignored | ||
* [`yaml`][mdast-yaml] and `toml` nodes are ignored (created by | ||
[`remark-frontmatter`][remark-frontmatter]) | ||
* [`html`][mdast-html] nodes are ignored if `allowDangerousHTML` is `false` | ||
* [`position`][unist-position]s are properly patched | ||
* Unknown nodes with `children` are transformed to `div` elements | ||
* Unknown nodes with `value` are transformed to `text` nodes | ||
* [`position`][position]s are properly patched | ||
* Unknown nodes with [`children`][child] are transformed to `div` elements | ||
* Unknown nodes with `value` are transformed to [`text`][hast-text] nodes | ||
* [`node.data.hName`][hname] configures the hast element’s tag-name | ||
@@ -220,7 +229,9 @@ * [`node.data.hProperties`][hproperties] is mixed into the hast element’s | ||
See [`contributing.md` in `syntax-tree/mdast`][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. | ||
@@ -245,5 +256,15 @@ ## License | ||
[size-badge]: https://img.shields.io/bundlephobia/minzip/mdast-util-to-hast.svg | ||
[size]: https://bundlephobia.com/result?p=mdast-util-to-hast | ||
[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/remark | ||
[chat]: https://spectrum.chat/unified/syntax-tree | ||
@@ -256,18 +277,42 @@ [npm]: https://docs.npmjs.com/cli/install | ||
[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 | ||
[position]: https://github.com/syntax-tree/unist#positional-information | ||
[tree]: https://github.com/syntax-tree/unist#tree | ||
[child]: https://github.com/syntax-tree/unist#child | ||
[mdast]: https://github.com/syntax-tree/mdast | ||
[hast]: https://github.com/syntax-tree/hast | ||
[mdast-node]: https://github.com/syntax-tree/mdast#nodes | ||
[mdast-yaml]: https://github.com/syntax-tree/mdast#yaml | ||
[mdast-html]: https://github.com/syntax-tree/mdast#html | ||
[unist-position]: https://github.com/syntax-tree/unist#location | ||
[hast]: https://github.com/syntax-tree/hast | ||
[handlers]: lib/handlers | ||
[hast-text]: https://github.com/syntax-tree/hast#text | ||
[hast-node]: https://github.com/syntax-tree/hast#nodes | ||
[to-html]: https://github.com/syntax-tree/hast-util-to-html | ||
[raw]: https://github.com/syntax-tree/hast-util-raw | ||
[remark-rehype]: https://github.com/remarkjs/remark-rehype | ||
[contributing]: https://github.com/syntax-tree/mdast/blob/master/contributing.md | ||
[remark-frontmatter]: https://github.com/remarkjs/remark-frontmatter | ||
[coc]: https://github.com/syntax-tree/mdast/blob/master/code-of-conduct.md | ||
[rehype-raw]: https://github.com/rehypejs/rehype-raw | ||
[rehype-stringify]: https://github.com/rehypejs/rehype/tree/master/packages/rehype-stringify | ||
[handlers]: lib/handlers | ||
[hname]: #hname | ||
@@ -274,0 +319,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27727
627
314