derlin / bitdowntoc

Online and command-line Markdown TOC generator, with built-in support for BitBucket Server, GitHub, Gitlab, dev.to and more!
https://bitdowntoc.derlin.ch
Other
82 stars 7 forks source link

feat: support reading from stdin #39

Closed derlin closed 4 months ago

derlin commented 4 months ago

bitdowntoc JVM can now read from stdin, by passing "-" as argument.

Note that this option is incompatible with '--inplace'. Also add tests for the cli.

Closes: #33

0xdevalias commented 4 months ago

From a super basic test, looks like it works:

⇒ echo "# Foo\n[TOC]\n## Bar\n### Baz\n## Bar2" | java -jar ~/Desktop/bitdowntoc-jvm-2.0.2-SNAPSHOT.jar -
# Foo
<!-- TOC start (generated with https://github.com/derlin/bitdowntoc) -->

- [Bar](#bar)
   * [Baz](#baz)
- [Bar2](#bar2)

<!-- TOC end -->
<!-- TOC --><a name="bar"></a>
## Bar
<!-- TOC --><a name="baz"></a>
### Baz
<!-- TOC --><a name="bar2"></a>
## Bar2

And also ran it over a much more complex markdown file and it generated an equivalent TOC as the one from the online version, so LGTM! 👌🏻