Preview Markdown

Have you ever wanted to preview README before pushing it to GitHub? Here’s a way.


  1. Download GitHub Markdown CSS to your home directory
  2. Add preview_md() function to your .bash_profile
    # add to ~/.bash_profile or ~/.bash_rc
    preview_md() {
        # $1 is argument specifying file to preview
            pandoc -o md_preview.html \
            --from markdown_github \
            --to html -c ~/github_md.css $1 
            && open md_preview.html \
            && sleep 2 && rm -f md_preview.html
  • Make sure Pandoc is installed on your machine. On Mac: $ brew install pandoc will do the trick!


Preview a markdown file: $ preview_md

$ preview_md
  • preview markdown in GitHub style
  • keeps your directory clean (deletes preview file automatically)
  • renders in your browser (no programs to install)

Happy documenting!