mdast-util-to-hast
Advanced tools
Comparing version 9.1.0 to 9.1.1
@@ -5,7 +5,6 @@ 'use strict' | ||
var detab = require('detab') | ||
var u = require('unist-builder') | ||
function code(h, node) { | ||
var value = node.value ? detab(node.value + '\n') : '' | ||
var value = node.value ? node.value + '\n' : '' | ||
var lang = node.lang && node.lang.match(/^[^ \t]+(?=[ \t]|$)/) | ||
@@ -12,0 +11,0 @@ var props = {} |
@@ -5,7 +5,7 @@ 'use strict' | ||
var collapse = require('collapse-white-space') | ||
var u = require('unist-builder') | ||
function inlineCode(h, node) { | ||
return h(node, 'code', [u('text', collapse(node.value))]) | ||
var value = node.value.replace(/\r?\n|\r/g, ' ') | ||
return h(node, 'code', [u('text', value)]) | ||
} |
@@ -6,48 +6,25 @@ 'use strict' | ||
var u = require('unist-builder') | ||
var wrap = require('../wrap') | ||
var all = require('../all') | ||
function listItem(h, node, parent) { | ||
var children = node.children | ||
var head = children[0] | ||
var raw = all(h, node) | ||
var result = all(h, node) | ||
var head = result[0] | ||
var loose = parent ? listLoose(parent) : listItemLoose(node) | ||
var props = {} | ||
var result | ||
var container | ||
var wrapped = [] | ||
var length | ||
var index | ||
var length | ||
var child | ||
// Tight lists should not render `paragraph` nodes as `p` elements. | ||
if (loose) { | ||
result = raw | ||
} else { | ||
result = [] | ||
length = raw.length | ||
index = -1 | ||
while (++index < length) { | ||
child = raw[index] | ||
if (child.tagName === 'p') { | ||
result = result.concat(child.children) | ||
} else { | ||
result.push(child) | ||
} | ||
} | ||
} | ||
if (typeof node.checked === 'boolean') { | ||
if (loose && (!head || head.type !== 'paragraph')) { | ||
result.unshift(h(null, 'p', [])) | ||
if (!head || head.tagName !== 'p') { | ||
head = h(null, 'p', []) | ||
result.unshift(head) | ||
} | ||
container = loose ? result[0].children : result | ||
if (container.length !== 0) { | ||
container.unshift(u('text', ' ')) | ||
if (head.children.length !== 0) { | ||
head.children.unshift(u('text', ' ')) | ||
} | ||
container.unshift( | ||
head.children.unshift( | ||
h(null, 'input', { | ||
@@ -65,7 +42,26 @@ type: 'checkbox', | ||
if (loose && result.length !== 0) { | ||
result = wrap(result, true) | ||
length = result.length | ||
index = -1 | ||
while (++index < length) { | ||
child = result[index] | ||
// Add eols before nodes, except if this is a loose, first paragraph. | ||
if (loose || index !== 0 || child.tagName !== 'p') { | ||
wrapped.push(u('text', '\n')) | ||
} | ||
if (child.tagName === 'p' && !loose) { | ||
wrapped = wrapped.concat(child.children) | ||
} else { | ||
wrapped.push(child) | ||
} | ||
} | ||
return h(node, 'li', props, result) | ||
// Add a final eol. | ||
if (length && (loose || child.tagName !== 'p')) { | ||
wrapped.push(u('text', '\n')) | ||
} | ||
return h(node, 'li', props, wrapped) | ||
} | ||
@@ -72,0 +68,0 @@ |
@@ -6,6 +6,8 @@ 'use strict' | ||
var u = require('unist-builder') | ||
var trimLines = require('trim-lines') | ||
function text(h, node) { | ||
return h.augment(node, u('text', trimLines(node.value))) | ||
return h.augment( | ||
node, | ||
u('text', String(node.value).replace(/[ \t]*(\r?\n|\r)[ \t]*/g, '$1')) | ||
) | ||
} |
{ | ||
"name": "mdast-util-to-hast", | ||
"version": "9.1.0", | ||
"version": "9.1.1", | ||
"description": "mdast utility to transform to hast", | ||
@@ -36,7 +36,4 @@ "license": "MIT", | ||
"@types/unist": "^2.0.3", | ||
"collapse-white-space": "^1.0.0", | ||
"detab": "^2.0.0", | ||
"mdast-util-definitions": "^3.0.0", | ||
"mdurl": "^1.0.0", | ||
"trim-lines": "^1.0.0", | ||
"unist-builder": "^2.0.0", | ||
@@ -55,4 +52,4 @@ "unist-util-generated": "^1.0.0", | ||
"tape": "^5.0.0", | ||
"tinyify": "^2.0.0", | ||
"xo": "^0.30.0" | ||
"tinyify": "^3.0.0", | ||
"xo": "^0.33.0" | ||
}, | ||
@@ -59,0 +56,0 @@ "scripts": { |
@@ -109,2 +109,6 @@ # mdast-util-to-hast | ||
* [`node.data.hChildren`][hchildren] configures the hast element’s children | ||
* GFM (and this project) uses the obsolete `align` attribute on `td` and `th` | ||
elements; combine this utility with | ||
[`@mapbox/hast-util-table-cell-style`][hast-util-table-cell-style] | ||
to use `style` instead | ||
@@ -338,5 +342,5 @@ ##### Examples | ||
[chat-badge]: https://img.shields.io/badge/chat-spectrum-7b16ff.svg | ||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg | ||
[chat]: https://spectrum.chat/unified/syntax-tree | ||
[chat]: https://github.com/syntax-tree/unist/discussions | ||
@@ -349,7 +353,7 @@ [npm]: https://docs.npmjs.com/cli/install | ||
[contributing]: https://github.com/syntax-tree/.github/blob/master/contributing.md | ||
[contributing]: https://github.com/syntax-tree/.github/blob/HEAD/contributing.md | ||
[support]: https://github.com/syntax-tree/.github/blob/master/support.md | ||
[support]: https://github.com/syntax-tree/.github/blob/HEAD/support.md | ||
[coc]: https://github.com/syntax-tree/.github/blob/master/code-of-conduct.md | ||
[coc]: https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct.md | ||
@@ -370,2 +374,4 @@ [position]: https://github.com/syntax-tree/unist#positional-information | ||
[hast-util-table-cell-style]: https://github.com/mapbox/hast-util-table-cell-style | ||
[hast]: https://github.com/syntax-tree/hast | ||
@@ -389,3 +395,3 @@ | ||
[rehype-stringify]: https://github.com/rehypejs/rehype/tree/master/packages/rehype-stringify | ||
[rehype-stringify]: https://github.com/rehypejs/rehype/tree/HEAD/packages/rehype-stringify | ||
@@ -392,0 +398,0 @@ [handlers]: lib/handlers |
@@ -29,3 +29,3 @@ // Minimum TypeScript Version: 3.2 | ||
* Only do this when using [`hast-util-to-html`](https://github.com/syntax-tree/hast-util-to-html) | ||
* ([`rehype-stringify`](https://github.com/rehypejs/rehype/tree/master/packages/rehype-stringify)) or | ||
* ([`rehype-stringify`](https://github.com/rehypejs/rehype/tree/HEAD/packages/rehype-stringify)) or | ||
* [`hast-util-raw`](https://github.com/syntax-tree/hast-util-raw) | ||
@@ -52,3 +52,3 @@ * ([`rehype-raw`](https://github.com/rehypejs/rehype-raw)) later: `raw` nodes are not a standard part of | ||
* Take a look at | ||
* [`lib/handlers/`](https://github.com/syntax-tree/mdast-util-to-hast/blob/master/lib/handlers) | ||
* [`lib/handlers/`](https://github.com/syntax-tree/mdast-util-to-hast/blob/HEAD/lib/handlers) | ||
* for examples. | ||
@@ -55,0 +55,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
32817
8
402
697
- Removedcollapse-white-space@^1.0.0
- Removeddetab@^2.0.0
- Removedtrim-lines@^1.0.0
- Removedcollapse-white-space@1.0.6(transitive)
- Removeddetab@2.0.4(transitive)
- Removedrepeat-string@1.6.1(transitive)
- Removedtrim-lines@1.1.3(transitive)