remark plugin to replace block content.
Note: if the block content is not found, the replace nodes is will added to the end.
npm:
npm install remark-replace-block
We have the following file, example.md
# title
## API
- this one
- this two
And the script, example.js
const remark = require('remark');
const replaceBlock = require('remark-replace-block');
const vfile = require('to-vfile');
remark()
.use(replaceBlock, { type: 'heading', depth: 2, value: 'API' }, '## update\n* - this is change')
.process(vfile.readSync('example.md'), function (err, file) {
if (err) throw err
console.log(String(file))
})
Yields:
# title
## update
- this is change