All Projects → mrzmmr → remark-behead

mrzmmr / remark-behead

Licence: MIT license
Remark plugin to increase or decrease markdown heading weight.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to remark-behead

remark-admonitions
Add admonitions support to Remarkable
Stars: ✭ 90 (+542.86%)
Mutual labels:  remark, remark-plugin
remark-embed-images
plugin to embed local images as data URIs
Stars: ✭ 23 (+64.29%)
Mutual labels:  remark, remark-plugin
transformer-oembed
@remark-embedder transformer for oEmbed supported links
Stars: ✭ 25 (+78.57%)
Mutual labels:  remark, remark-plugin
remark-bookmarks
plugin to manage links
Stars: ✭ 15 (+7.14%)
Mutual labels:  remark, remark-plugin
remark-directive
remark plugin to support directives
Stars: ✭ 137 (+878.57%)
Mutual labels:  remark, remark-plugin
remark-footnotes
Legacy plugin to add support for pandoc footnotes — please use `remark-gfm` instead
Stars: ✭ 38 (+171.43%)
Mutual labels:  remark, remark-plugin
remark-highlight.js
Legacy plugin to highlight code blocks with highlight.js — please use `rehype-highlight` instead
Stars: ✭ 58 (+314.29%)
Mutual labels:  remark, remark-plugin
remark-man
plugin to compile markdown to man pages
Stars: ✭ 87 (+521.43%)
Mutual labels:  remark, remark-plugin
remark-autolink-headings
Legacy remark plugin to automatically add links to headings — please use `rehype-autolink-headings` instead
Stars: ✭ 63 (+350%)
Mutual labels:  remark, remark-plugin
cache
A cache for @remark-embedder
Stars: ✭ 12 (-14.29%)
Mutual labels:  remark, remark-plugin
remark-frontmatter
remark plugin to support frontmatter (YAML, TOML, and more)
Stars: ✭ 167 (+1092.86%)
Mutual labels:  remark, remark-plugin
remark-slate-transformer
remark plugin to transform remark syntax tree (mdast) to Slate document tree, and vice versa. Made for WYSIWYG markdown editor.
Stars: ✭ 62 (+342.86%)
Mutual labels:  remark, remark-plugin
remark-license
plugin to generate a license section
Stars: ✭ 15 (+7.14%)
Mutual labels:  remark, remark-plugin
twoslash
You take some Shiki, add a hint of TypeScript compiler, and 🎉 incredible static code samples
Stars: ✭ 596 (+4157.14%)
Mutual labels:  remark, remark-plugin
strip-markdown
plugin remove Markdown formatting
Stars: ✭ 84 (+500%)
Mutual labels:  remark, remark-plugin
remark-external-links
Legacy plugin to automatically add target and rel attributes to external links — please use `rehype-external-links` instead
Stars: ✭ 50 (+257.14%)
Mutual labels:  remark, remark-plugin
remark-hint
Sprinkle hints/tips/warnings on your documents
Stars: ✭ 36 (+157.14%)
Mutual labels:  remark, remark-plugin
gatsby-remark-numbered-footnotes
A small plugin to change named footnotes to numbered footnotes in your Gatsby pages using Markdown.
Stars: ✭ 15 (+7.14%)
Mutual labels:  remark
gatsby-remark-relative-images
Convert markdown image src(s) to be relative for gatsby-remark-images.
Stars: ✭ 79 (+464.29%)
Mutual labels:  remark-plugin
gatsby-remark-images-anywhere
Handle images with relative, absolute & remote path for gatsby-transformer-remark & gatsby-plugin-mdx
Stars: ✭ 22 (+57.14%)
Mutual labels:  remark

remark-behead

Build Status Coverage Status Standard Readme Compliant Dependency Status

Increase or decrease heading depth

remark-behead is a remark plugin to increase or decrease heading depths, where the depth is changed either relatively or by means of minimum.

Table of Contents

Install

npm install --save remark-behead

Usage

import behead from 'remark-behead';
import {remark} from 'remark';

remark()
	.use(behead, {depth: 1, after: 0})
	.process(['# foo', '# bar', '# baz'].join('\n'))
	.then((vfile) => vfile.toString())
	.then((markdown) => console.log(markdown))
	.catch((err) => console.error(err));
/*
 * # foo
 *
 * ## bar
 *
 * ## baz
 */

remark()
	.use(behead, {minDepth: 2})
	.process(['# foo', '## bar', '### baz'].join('\n'))
	.then((vfile) => vfile.toString())
	.then((markdown) => console.log(markdown))
	.catch((err) => console.error(err));
/*
 * ## foo
 *
 * ### bar
 *
 * #### baz
 */

Options

Specify the depth change by providing one of the following options:

  • depth [ Number ]
  • minDepth [ 2 | 3 | 4 | 5 | 6 ]

Specify the scope by providing one of the following options:

  • after [ NodeSpecifier ]
  • before [ NodeSpecifier ]
  • between array [ [ NodeSpecifier ] , [ NodeSpecifier ] ]

NodeSpecifier [ string | Number | Object ] - When string, look for a heading with given value. When number, look for node at given index. When object, look for a node with given keys / values.

options.depth

Passing a negative value will decrease the heading depth by the given amount. Passing a positive value will increase the heading depth by the given amount.

options.minDepth

The heading depth will be increased accordingly to match the given minimal depth. If there are no headings with a smaller depth than the minimum depth, nothing is changed.

options.after

Manipulates heading nodes after but not including the given node specifier.

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 node specifier.

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 heading nodes between but not including the two given node specifiers, 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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].