Search code examples
bashmacosmarkdownpandocmanpage

How do I view Markdown file like a man page without making a temporary file?


I'd like to read Markdown files like man pages. I can do this:

pandoc README.md -t man --standalone > tmp_file && man ./tmp_file

However, I'd like to do this without creating a temporary file. I tried:

man <(pandoc README.md -t man –standalone)

But I got an error:

fgets: Undefined error: 0
Error reading man page /dev/fd/63
No manual entry for /dev/fd/63

Any ideas? I did look at this question, but that doesn't work on macOS's version of man, it seems.

I really don't care about using man, per se, but I'd like to be able to view prettily-formatted Markdown files in the terminal. pandoc can convert to groff, which I can then send to man to get the nice display. Is there a program that man uses under the hood that might work?


Solution

  • Try this pipe to groff:

    pandoc -s -f markdown -t man README.md | groff -T utf8 -man | less
    

    (Source)