Is it possible for Pandoc to take text as an input argument rather than an input file?

Viewed 211

I can't seem to figure out if this is possible. Still trying to learn the tool - I've figured out how to run it on an input file and generate outputs, but would it be possible for it to, for example, take a text as an input and generate an output file.

For e.g., instead of

pandoc -i somefile.md -o -f markdown -t docx output.md

could I do

pandoc "# hello there! \n\nI went to the market" -o -f markdown -t docx output.md

Am I missing some option in the doc?

1 Answers

You can pass text input to pandoc. I did so by using the pipe operator:

echo "# hello there! \n\nI went to the market" | pandoc -f markdown -t docx -o foo.docx

This works with other text markups:

echo "* hello there! \n\nI went to the market" | pandoc -f org -t docx -o foo.docx

If you are targeting another text-based markup, you can even get it to print out text:

echo "# hello there! \n\nI went to the market" | pandoc -f markdown -t org
* hello there!
  :PROPERTIES:
  :CUSTOM_ID: hello-there
  :END:

I went to the market
Related