remark-behead
Increase or decrease heading depth
Last updated 14 days ago by mrzmmr .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install remark-behead 
SYNC missed versions from official npm registry.

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

Current Tags

  • 2.3.3                                ...           latest (14 days ago)

13 Versions

  • 2.3.3                                ...           14 days ago
  • 2.3.2                                ...           4 months ago
  • 2.3.1                                ...           8 months ago
  • 2.3.0                                ...           a year ago
  • 2.2.1                                ...           a year ago
  • 2.1.0                                ...           3 years ago
  • 2.0.1                                ...           3 years ago
  • 2.0.0                                ...           3 years ago
  • 1.5.5                                ...           4 years ago
  • 1.5.3                                ...           4 years ago
  • 1.5.1                                ...           5 years ago
  • 1.4.12                                ...           5 years ago
  • 1.4.11                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 70
Dev Dependencies (3)

Copyright 2014 - 2016 © taobao.org |