npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mklevel

v1.0.3

Published

Modify heading levels

Downloads

19

Readme

Heading Levels

Build Status npm version Coverage Status

Indent and outdent heading levels

Increases and decreases heading levels so the structure of a document may be modified.

Useful when you have a standalone document that you wish to include in another document but the headings in the standalone document should be indented to fit the structure of the parent document.

Install

npm i mklevel --save

For the command line interface install mkdoc globally (npm i -g mkdoc).



Usage

Create the stream and write a commonmark document:

var lvl = require('mklevel')
  , ast = require('mkast');
ast.src('# 1\n\n## 2\n\n### 3\n\n')
  .pipe(lvl({levels: [1, 2, -1, 0, 0, 0]}))
  .pipe(ast.stringify({indent: 2}))
  .pipe(process.stdout);

Example

Increment all heading levels:

mkcat README.md | mklevel --all=1 | mkout

Decrement all heading levels:

mkcat README.md | mklevel --all=-1 | mkout

Convert level 2 headings to level 5:

mkcat README.md | mklevel -2=3 | mkout

Convert level 1 and 3 headings to level 2:

mkcat README.md | mklevel -1=1 -3=-1 | mkout

Help

mklevel [options]

Modify heading levels.

  -1=[NUM]         Modify level 1 headings by NUM
  -2=[NUM]         Modify level 2 headings by NUM
  -3=[NUM]         Modify level 3 headings by NUM
  -4=[NUM]         Modify level 4 headings by NUM
  -5=[NUM]         Modify level 5 headings by NUM
  -6=[NUM]         Modify level 6 headings by NUM
  -a, --all=[NUM]  Modify all headings by NUM
  -h, --help       Display this help and exit
  --version        Print the version and exit

Report bugs to https://github.com/mkdoc/mklevel/issues

API

level

level([opts][, cb])

Gets the heading level stream.

See Level for additional options.

Returns an output stream.

  • opts Object processing options.
  • cb Function callback function.

Options

  • input Readable input stream.
  • output Writable output stream.

Level

new Level([opts])

Increases and decreases heading levels.

Takes the integer values in the levels option and applies them by index to the headings in the stream.

The level modifier for level one headings is at index zero in the list.

If a level modifier would take a heading level beyond the permitted 1-6 range the value is clamped, so the following is a noop:

{levels: [-1]}

Because level one headings cannot be modified below one.

To convert all level one headings to level two:

{levels: [1]}

To increment headings 1-4 by one:

{levels: [1,1,1,1]}

To decrement all heading levels (except level 1 which cannot be decremented):

{all: -1}
  • opts Object stream options.

Options

  • levels Array list of integer level modifiers.
  • all Number use this value for all levels.

License

MIT


Created by mkdoc on March 27, 2016