remark-captions
Advanced tools
Comparing version 2.0.1 to 2.1.0
@@ -56,2 +56,34 @@ 'use strict'; | ||
}); | ||
visit(tree, 'figure', function (figure, index, parent) { | ||
if (parent.type === 'paragraph') { | ||
if (index === 0) { | ||
parent.type = figure.type; | ||
parent.data = figure.data; | ||
parent.children = figure.children; | ||
return; | ||
} | ||
parent.type = 'tempWrapper'; | ||
} | ||
}); | ||
visit(tree, 'tempWrapper', function (wrapper, index, parent) { | ||
var _parent$children; | ||
var newChildren = []; | ||
wrapper.children.forEach(function (node, i) { | ||
var child = clone(node); | ||
if (child.type === 'figure') { | ||
newChildren.push(child); | ||
return; | ||
} | ||
if (child.type === 'text' && !child.value.trim()) { | ||
return; | ||
} else if (child.type === 'text') { | ||
child.value = child.value.trim(); | ||
} | ||
wrapper.children[i].type = 'paragraph'; | ||
wrapper.children[i].children = [child]; | ||
newChildren.push(wrapper.children[i]); | ||
}); | ||
(_parent$children = parent.children).splice.apply(_parent$children, [index, 1].concat(newChildren)); | ||
}); | ||
}; | ||
@@ -58,0 +90,0 @@ } |
{ | ||
"name": "remark-captions", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"repository": { | ||
@@ -36,18 +36,18 @@ "url": "https://github.com/zestedesavoir/zmarkdown/tree/master/packages/remark-captions", | ||
"clone": "^2.1.1", | ||
"unist-util-visit": "^1.1.3" | ||
"unist-util-visit": "^1.3.1" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.26.0", | ||
"babel-jest": "^22.0.4", | ||
"babel-jest": "^23.4.0", | ||
"babel-preset-env": "^1.6.1", | ||
"cross-env": "^5.0.5", | ||
"cross-env": "^5.2.0", | ||
"dedent": "^0.7.0", | ||
"del-cli": "^1.0.0", | ||
"eslint": "^4.5.0", | ||
"jest": "^22.0.5", | ||
"rehype-stringify": "^3.0.0", | ||
"eslint": "^5.1.0", | ||
"jest": "^23.4.1", | ||
"rehype-stringify": "^4.0.0", | ||
"remark-parse": "^5.0.0", | ||
"remark-rehype": "^3.0.0", | ||
"unified": "^6.1.5" | ||
"unified": "^7.0.0" | ||
} | ||
} |
@@ -52,2 +52,32 @@ const clone = require('clone') | ||
visit(tree, nodeType, externLegendVisitorCreator(externalBlocks))) | ||
visit(tree, 'figure', (figure, index, parent) => { | ||
if (parent.type === 'paragraph') { | ||
if (index === 0) { | ||
parent.type = figure.type | ||
parent.data = figure.data | ||
parent.children = figure.children | ||
return | ||
} | ||
parent.type = 'tempWrapper' | ||
} | ||
}) | ||
visit(tree, 'tempWrapper', (wrapper, index, parent) => { | ||
const newChildren = [] | ||
wrapper.children.forEach((node, i) => { | ||
const child = clone(node) | ||
if (child.type === 'figure') { | ||
newChildren.push(child) | ||
return | ||
} | ||
if (child.type === 'text' && !child.value.trim()) { | ||
return | ||
} else if (child.type === 'text') { | ||
child.value = child.value.trim() | ||
} | ||
wrapper.children[i].type = 'paragraph' | ||
wrapper.children[i].children = [child] | ||
newChildren.push(wrapper.children[i]) | ||
}) | ||
parent.children.splice(index, 1, ...newChildren) | ||
}) | ||
} | ||
@@ -54,0 +84,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
22023
422
Updatedunist-util-visit@^1.3.1