Files
upgrading-ethereum-book/plugins/my-strip-html-comments/index.js
Ben Edgington 41a52ffdf7 Tidy up plugins
2022-12-28 17:44:47 +00:00

20 lines
401 B
JavaScript

const visit = require('unist-util-visit')
// Remove HTML comments from the Markdown AST
module.exports = ({ markdownAST }) => {
try {
visit(markdownAST, 'html', (node, index, parent) => {
if (node.value.startsWith('<!-- ')) {
parent.children.splice(index, 1)
return [visit.SKIP, index]
}
})
} catch (err) {
console.error(err)
}
return markdownAST
}