Allow redirecting to stdout
pomdtr opened this issue · comments
By default, pandocotomatic does not redirect the output to stdout but to stdout like pandoc.
It make it harder to implement a chaining of command.
True. In the past I have though about adding stdin/out, but always decided against it because I had no clear use-case for it. Can you give me one or more real-world use-cases with examples of when, how, and why you would like to use stdin/out with pandocomatic?
Furthermore, because I have never taken into account input from stdin/out, the current implementation of pandocomatic assumes input and output files all over the place. That means that just bolting it on somehow is not a good idea. However, moving forward to the next major version, I could redesign pandocomatic to support stdin/out.
My school use an webinterface for the documentation of student's project. It uses an exotic format, dokuwiki.
In order to use markdown, and the advantages of my editor, i usually run pandoc -t dokuwiki input.md | pbcopy
, and i paste the content of my clipboard into the web interface.
And you would like to be able to run pandocomatic input.md | pbcopy
?
I tried to automatically copy the results of a pandocomatic conversion to the clipboard with the xclip
command-line utility in a postprocessor:
-
copy.sh
inPATH
:#!/usr/bin/env bash xclip <&0
-
copy-to-clipboard
template in my pandocomatic configuration file:templates: copy-to-clipboard: pandoc: from: markdown to: dokuwiki postprocessors: - copy.sh
-
a
test.md
file that uses that template:--- pandocomatic_: use-template: copy-to-clipboard ... Hello World! This whole document is converted to *dokuwiki* and copied to the clipboard!
Unfortunately, if I try to run this via pandocomatic -c my-config.yaml -i test.md
pandocomatic does not quit. I have to press control+D to quit the pandocomatic process. On the other hand, the contents of the conversion are being copied to the clipboard.
I am not sure why pandocomatic does not quit when using the copy.sh
postprocessor script, but this might be an interesting avenue for you to explore further.
I also think it's doable with a postprocessor, but it would be a nice to have a toml setting to toggle it :)
In asciidoctor, also in ruby, you can toggle this behavior by using the asciidoctor -o - test.adoc
, and pandoc does it by default
I've marked this issue as a "should have" requirement for the next major version of pandocomatic. If you have any other use cases for stdin / stdout or other comments, please feel free to add to this issue.
(Note. As of yet I do not know when I will be working on the next major version, so it can take quite a long while before this will be implemented)
Another usecase for chaining commands using stdin / stdout is for apps like Marked 2. The app can use a custom processors to generate styled html. It uses stdin/out for auto loading. I've been thinking of ways to wrap pandocomatic or use its pre/post processors to handle this usecase. Any advice on a how to achieve stdin/out using a wrapper?
Finished implementing output to STDOUT. I've added a new command line option, --stdout
, to print the result of pandocomatic on standard output. This command line option does not work together with --output
, nor with converting whole directories. It'll be available in pandocomatic 0.3 that's coming in the next months.