Skip to content

Commit

Permalink
feat: add -d, --depth flags
Browse files Browse the repository at this point in the history
This PR adds support for specifying depth via
-d and --depth flags.

Also closes #3
  • Loading branch information
ycd committed Jan 21, 2021
1 parent 8b8df0e commit 7ad78a9
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@
```
Usage: toc [options]
Options:
-p, --path <path> Path for the markdown file.
-a, --append Append toc after <!--toc-->, or write to stdout.
-b, --bulleted Write as bulleted, or write as numbered list.
-s, --skip Skip the first given number of headers.
-h, --help Show this message and exit.
-p, --path <path> Path for the markdown file.
-a, --append Append toc after <!--toc-->, or write to stdout.
-b, --bulleted Write as bulleted, or write as numbered list.
-s, --skip Skip the first given number of headers.
-d, --depth Set the number of maximum heading level to be included.
-h, --help Show this message and exit.
```

Add `<!--toc-->` to your markdown to the place where you want to add Table of Contents. That's it.

Give the markdown file as an input with `-p`, `--path` flags.

```
$ toc -p path/to/markdown.md
Expand All @@ -45,19 +47,27 @@ $ toc -p path/to/markdown.md
Create numbered list instead of bulleted list.

```
$ toc -p path/to/markdown.md --bulleted=false
$ toc --bulleted=false
```

Write result to standard output instead of appending.

```
$ toc -p path/to/markdown.md --append=false
$ toc --append=false
```

Skip the first `n` number of headers via `-s`, `--skip` flags.

```
$ toc -p path/to/markdown.md --skip 2
$ toc --skip 2
```

Set the number of maximum heading level to be included with `-d`, `--depth` flags.

Set maximum heading level to 3 (h3)

```
$ toc --depth 3
```

---
Expand Down Expand Up @@ -112,19 +122,20 @@ Binary downloads of example are available from [the releases section on GitHub](
$ go build .
$ cp toc /usr/local/toc
```

3. Verify installation

```
$ toc -h
Usage: toc [options]
Options:
-p, --path <path> Path for the markdown file.
-a, --append Append toc after <!--toc-->, or write to stdout.
-b, --bulleted Write as bulleted, or write as numbered list.
-s, --skip Skip the first given number of headers.
-h, --help Show this message and exit.
-p, --path <path> Path for the markdown file.
-a, --append Append toc after <!--toc-->, or write to stdout.
-b, --bulleted Write as bulleted, or write as numbered list.
-s, --skip Skip the first given number of headers.
-d, --depth Set the number of maximum heading level to be included.
-h, --help Show this message and exit.
```
---

Expand Down

0 comments on commit 7ad78a9

Please sign in to comment.