less-style markdown viewer for UNIX systems less-style markdown viewer for UNIX systems unix unix

less-style markdown viewer for UNIX systems


Pandoc can convert Markdown to groff man pages.

This (thanks to nenopera's comment):

 pandoc -s -f markdown -t man foo.md | man -l -

should do the trick. The -s option tells it to generate proper headers and footers.

There may be other markdown-to-*roff converters out there; Pandoc just happens to be the first one I found.

Another alternative is the markdown command (apt-get install markdown on Debian systems), which converts Markdown to HTML. For example:

markdown README.md | lynx -stdin

(assuming you have the lynx terminal-based web browser).

Or (thanks to Danny's suggestion) you can do something like this:

markdown README.md > README.html && xdg-open README.html

where xdg-open (on some systems) opens the specified file or URL in the preferred application. This will probably open README.html in your preferred GUI web browser (which isn't exactly "less-style", but it might be useful).


I tried to write this in a comment above, but I couldn't format my code block correctly. To write a 'less filter', try, for example, saving the following as ~/.lessfilter:

#!/bin/shcase "$1" in    *.md)        extension-handler "$1"        pandoc -s -f markdown -t man "$1"|groff -T utf8 -man -        ;;    *)        # We don't handle this format.        exit 1esac# No further processing by lesspipe necessaryexit 0

Then, you can type less FILENAME.md and it will be formatted like a manpage.


If you are into colors then maybe this is worth checking as well:

terminal_markdown_viewer

It can be used straightforward also from within other programs, or python modules.

And it has a lot of styles, like over 200 for markdown and code which can be combined.

pic2

Disclaimer

  • It is pretty alpha there may be still bugs

  • I'm the author of it, maybe some people like it ;-)