Created
June 14, 2019 14:38
-
-
Save patrickarlt/2ee1f4ba753a4c3c084d74a7728ab157 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var unified = require("unified"); | |
var remarkParse = require("remark-parse"); | |
var remarkStringify = require("remark-stringify"); | |
var { matches } = require("unist-util-select"); | |
var remove = require("unist-util-remove"); | |
var markdown = ` | |
# Test | |
# No Really | |
## Test | |
Foo | |
`; | |
function plugin(options) { | |
return function transformer(tree, file) { | |
remove(tree, function(node) { | |
return matches(`heading[depth=1]`, node); | |
}); | |
}; | |
} | |
unified() | |
.use(remarkParse) | |
.use(plugin) | |
.use(remarkStringify) | |
.process(markdown) | |
.then(file => console.log(file.contents)); | |
/* | |
## Test | |
Foo | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment