remark-replace-block

remark plugin to replace block context


Keywords
remark, replace, remark-plugin
License
ISC
Install
npm install remark-replace-block@1.0.0

Documentation

remark-replace-block

remark plugin to replace block content.

Note: if the block content is not found, the replace nodes is will added to the end.

Install

npm:

npm install remark-replace-block

Use

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