@mkusaka/toc
toc for multiple markdown document
Last updated 5 months ago by mkusaka .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @mkusaka/toc 
SYNC missed versions from official npm registry.

@mkusaka/toc

table of contents

generate multiple markdwon document link cli.

install

yarn global add @mkusaka/toc
# or
npm install -g @mkusaka/toc

usage

cd /path/to/folder

install, and run

mdoctoc "glob pattern"

then markdown link comes to standard streams.

example

document/sample.md

# some
# markdown
## like this

document/sample2.md

# some2
# markdown2
## like this2

document/nested/sample3.md

# some3
# markdown3
## like this3

then output like follow.

$ mdoctoc "document/**/*.md"
[document/nested/sample3](./document/nested/sample3.md)
- [some3](./document/nested/sample3.md#some3)
- [markdown3](./document/nested/sample3.md#markdown3)
  - [like this3](./document/nested/sample3.md#like%20this3)

[document/sample](./document/sample.md)
- [some](./document/sample.md#some)
- [markdown](./document/sample.md#markdown)
  - [like this](./document/sample.md#like%20this)

[document/sample2](./document/sample2.md)
- [some2](./document/sample2.md#some2)
- [markdown2](./document/sample2.md#markdown2)
  - [like this2](./document/sample2.md#like%20this2)

if above toc shown at document/readme.md, we can specify it and script returns better toc path.

$ mdoctoc "document/**/*.md" "document/README.md"
[nested/sample3](./nested/sample3.md)
- [some3](./nested/sample3.md#some3)
- [markdown3](./nested/sample3.md#markdown3)
  - [like this3](./nested/sample3.md#like%20this3)

[sample](./sample.md)
- [some](./sample.md#some)
- [markdown](./sample.md#markdown)
  - [like this](./sample.md#like%20this)

[sample2](./sample2.md)
- [some2](./sample2.md#some2)
- [markdown2](./sample2.md#markdown2)
  - [like this2](./sample2.md#like%20this2)

if you want filter depth(# → depth 1, ## → depth 2). run like follow

# (sorry, second "./" argument required if use depth option right now... it will be option using commander.js)
$ mdoctoc "document/**/*.md" "./" 1
[document/nested/sample3](./document/nested/sample3.md)
- [some3](./document/nested/sample3.md#some3)
- [markdown3](./document/nested/sample3.md#markdown3)

[document/sample](./document/sample.md)
- [some](./document/sample.md#some)
- [markdown](./document/sample.md#markdown)

[document/sample2](./document/sample2.md)
- [some2](./document/sample2.md#some2)
- [markdown2](./document/sample2.md#markdown2)

TODO

  • use tj/commander.js: node.js command-line interfaces made easy
  • validate globed file extension (may need .md only)
  • add sort option
  • add show depth option
  • deal with relative file
    • ex: document/first/sample.md (with content only # foo), document/second/README.md. node script.js "document/**/*.md" "document/second/README.md" then expected output path for sample.md is [foo](../first/sample.md#foo).
  • add tests

Current Tags

  • 0.0.15                                ...           latest (5 months ago)

12 Versions

  • 0.0.15                                ...           5 months ago
  • 0.0.14                                ...           5 months ago
  • 0.0.12                                ...           8 months ago
  • 0.0.10                                ...           a year ago
  • 0.0.9                                ...           a year ago
  • 0.0.8                                ...           a year ago
  • 0.0.7                                ...           a year ago
  • 0.0.6                                ...           a year ago
  • 0.0.5                                ...           a year ago
  • 0.0.3                                ...           a year ago
  • 0.0.2                                ...           a year ago
  • 0.0.1                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |