unified

Project: mrzmmr/remark-behead

Package: remark-behead@2.3.3

  1. Dependencies: 5·Dependents: 5
  2. Increase or decrease heading depth
  1. remark 186
  2. plugin 131
  3. mdast 81
  4. remark-plugin 71

remark-behead

Build Status Coverage Status

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' */

standard-readme compliant David David

Tests

npm install
npm test

Contribute

PRs accepted and greatly appreciated.

License

MIT © mrzmmr