How to convert RTF to Markdown on the UNIX/OSX command line similar to pandoc

halloleo picture halloleo · May 26, 2015 · Viewed 8.5k times · Source

How do I convert RTF (say from stdin) to Markdown with a command line tool under UNIX/OSX.

I am looking for something like pandoc. However pandoc itself does not allow RTF as an input format. :-( So, I'd be happy either with a similar tool to pandoc or a pointer to an external RTF reader for pandoc.

Answer

halloleo picture halloleo · May 27, 2015

On Mac OSX I can use the pre-installed textutil command for the RTF-to-HTML conversion, then convert via pandoc to markdown. So a command line which takes RTF from stdin and writes markdown to stdout looks like this:

textutil -stdin -convert html  -stdout | pandoc --from=html --to=markdown