Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert strings of text with pandoc

Tags:

linux

pandoc

If my app has a string that's in markdown, '## Hello', can I use pandoc to convert it to HTML directly? I don't want to write it to a file first, but all of the documentation and examples I can find shows files.

I want to do something like this: pandoc -f markdown -t html '## Hello'.

Is this possible?

Note: I'm using a pandoc-bin which is a node wrapper. I don't think this effects my question as the library seems to wrap the original syntax.

like image 308
emersonthis Avatar asked Oct 18 '22 08:10

emersonthis


1 Answers

In Posix-Shell (using Here String):

$ pandoc -f markdown -t html <<< "# Hello"
<h1 id="hello">Hello</h1>

In Bash (using Process Substitution):

$ pandoc -f markdown -t html <(echo "# Hello")
<h1 id="hello">Hello</h1>

Refer

  • bash - What does <<< mean? - Unix & Linux Stack Exchange
like image 193
Porcupine Avatar answered Oct 21 '22 05:10

Porcupine