md-stream-utils

0.1.2 • Public • Published

md-stream-utils

Set of utilities to work with Markdown.

The basis of this work come from https://github.com/alanshaw/md-tokenizer

An alternative to https://github.com/chjj/marked

Installation

Run the following commands to download and install the application:

Binary install sh npm i md-stream-utils -g

API install sh npm i md-stream-utils --save

Usage

md-block: A binary tool to parse Markdown content by block.

mb-block [inputfile [outputfile]] [-c 'content'] [-t 'text']

-c | --content    Content to match.
-t | --type       Block type to match.
  • Display 'Usage' heading from stdin:

    cat README.md | md-block -c 'Usage' -t 'heading'

  • Display 'Usage' heading from a file:

    md-block -c 'Usage' -t 'heading' README.md

md-paragraph: A binary tool to parse Markdown content by paragraph.

mb-paragraph [inputfile [outputfile]] [-c 'content']

-c | --content    Content to match.
  • Display 'Usage' section from stdin:

    cat README.md | md-paragraph -c 'Usage'

  • Display 'Usage' section from a file:

    md-paragraph -c 'Usage' README.md

md-colorize: A binary tool to colorize Markdown content.

md-colorize [inputfile [outputfile]]
  • Display 'Usage' section from stdin with color:

    cat README.md | md-paragraph -c 'Usage' | md-colorize

  • Display 'Usage' section from a file with color:

    md-paragraph -c 'Usage' README.md | md-colorize

API

Please check module index file.

For example to tokenize, format, color, and output a mardown file with interactive support, it looks like this

    var pumpable = new mds.PausableStream()
    pumpable.pause()
    input
      .pipe(mds.toTokenString())
      .pipe(argv._.length > 0 ? pumpable.stream : through2.obj())
      .pipe(mds.tokenize())
      .pipe(mds.format())
      .pipe(mds.colorize())
      .pipe(argv._.length > 0 ? mds.less(pumpable) : through2.obj())
      .pipe(mds.flattenToString(mds.resolveColors.transform))
      .pipe(output)

There are a bunch of filters, transformers available under lib/.

How to contribute

  1. File an issue in the repository, using the bug tracker, describing the contribution you'd like to make. This will help us to get you started on the right foot.
  2. Fork the project in your account and create a new branch: your-great-feature.
  3. Commit your changes in that branch.
  4. Open a pull request, and reference the initial issue in the pull request message.

License

See the LICENSE file.

Notes

It is not perfectly github markdown compatible.

Todo

  • improve the tests
  • provide configurable colors
  • fix background display

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.2
    0
    • latest

Version History

Package Sidebar

Install

npm i md-stream-utils

Weekly Downloads

0

Version

0.1.2

License

WTF

Last publish

Collaborators

  • maboiteaspam