Closed 0xdevalias closed 7 months ago
@0xdevalias Thanks for the issue! This makes sense. I propose to support "-" as an argument to read from stdin:
echo "aaa" | java -jar bitdowntoc.jar -
I created a pull request, can you have a look and see if this works for you? (the built jar can be downloaded from the workflow run of the PR).
I created a pull request, can you have a look and see if this works for you?
@derlin Gave it a go, looks good!
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! 👌🏻
Originally posted by @0xdevalias in https://github.com/derlin/bitdowntoc/issues/39#issuecomment-2081923838
It would be awesome if we could pipe markdown directly into the CLI rather than needing to specify an input file:
And then ideally it would write the output to STDOUT so we could pipe it elsewhere as well.