Skip to content

Commit 349c1ce

Browse files
vhfwooorm
authored andcommitted
Externalise code to mdast-util-phrasing
Closes GH-33. Amended-by: Titus Wormer <[email protected]>
1 parent 13684de commit 349c1ce

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

lib/wrap.js

+3-19
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,7 @@ module.exports = wrap;
44

55
wrap.needed = needed;
66

7-
var is = require('unist-util-is');
8-
9-
/* https://github.com/syntax-tree/mdast */
10-
var inline = [
11-
'inlineCode',
12-
'emphasis',
13-
'break',
14-
'strong',
15-
'delete',
16-
'link',
17-
'image',
18-
'footnote',
19-
'linkReference',
20-
'imageReference',
21-
'footnoteReference',
22-
'text'
23-
];
7+
var phrasing = require('mdast-util-phrasing');
248

259
/* Wrap all inline runs of MDAST content in `paragraph` nodes. */
2610
function wrap(nodes) {
@@ -33,7 +17,7 @@ function wrap(nodes) {
3317
while (++index < length) {
3418
node = nodes[index];
3519

36-
if (is(inline, node)) {
20+
if (phrasing(node)) {
3721
if (queue === undefined) {
3822
queue = [];
3923
}
@@ -64,7 +48,7 @@ function needed(nodes) {
6448
var index = -1;
6549

6650
while (++index < length) {
67-
if (!is(inline, nodes[index])) {
51+
if (!phrasing(nodes[index])) {
6852
return true;
6953
}
7054
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
"hast-util-has-property": "^1.0.0",
2727
"hast-util-is-element": "^1.0.0",
2828
"hast-util-to-string": "^1.0.0",
29+
"mdast-util-phrasing": "^1.0.0",
2930
"rehype-minify-whitespace": "^2.0.3",
3031
"trim-trailing-lines": "^1.1.0",
31-
"unist-util-is": "^2.1.0",
3232
"unist-util-visit": "^1.1.1",
3333
"xtend": "^4.0.1"
3434
},

0 commit comments

Comments
 (0)