remark-behead
Increase or decrease heading depth
Remark-behead is a remark plugin to increase or decrease heading depths. Passing a negative value to the depth option will decrease the heading depth. Passing a positive value to the depth option will increase the heading depth.
Table of Contents
Install
npm install --save remark-behead
Usage
const behead = require('remark-behead')
const remark = require('remark')
remark()
.use(behead, { after: 0, depth: 1 })
.process([
'# foo',
'# bar',
'# baz'
].join('\n'))
.then(vfile => vfile.toString())
.then(markdown => console.log(markdown))
.catch(err => console.error(err))
/*
* result :
*
* # foo
*
* ## bar
*
* ## baz
*
*/
Options
options.after
Manipulates heading nodes after but not including the given string. Behead will start working after the first occurrence of the given string.
example
remark()
.use(behead, { after: 'foo', depth: 1 })
.processSync('# foo\n# bar\n# baz')
/* # foo\n\n## bar\n\n## baz\n */
options.before
Manipulates heading nodes before but not including the given string. Behead will stop working at the first occurrence of the given string.
example
remark()
.use(behead, { before: 'baz', depth: 1 })
.processSync('# foo\n\n# bar\n# baz\n')
/* ## foo\n\n## bar\n\n# baz\n */
options.between
Manipulates hading nodes between but not including the two given strings, starting with options.between[0] and ending with options.between[1].
example
remark()
.use(behead, { between: [ 0, 'baz' ], depth: 1 })
.processSync('# foo\n# bar\n# baz')
/* # foo\n\n## bar\n\n# baz\n' */
Tests
npm install
npm test
Contribute
PRs accepted and greatly appreciated.
License
MIT © mrzmmr