Skip to content

Instantly share code, notes, and snippets.

@graphaelli
Created February 6, 2013 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save graphaelli/4724481 to your computer and use it in GitHub Desktop.
Save graphaelli/4724481 to your computer and use it in GitHub Desktop.
markdown previewer
#!/usr/bin/env python
""" .vimrc: autocmd BufEnter *.md exe 'noremap <F5> :!mdpreview.py %<CR>' """
import subprocess, sys, tempfile
with tempfile.NamedTemporaryFile(suffix=".html", delete=False) as mdhtml:
subprocess.check_call(["pandoc", "--to=html", "--from=markdown", "-o", mdhtml.name, sys.argv[1]])
# webbrowser.open_new_tab ... chrome howto?
subprocess.check_call(["open", "-a", "Google Chrome", mdhtml.name])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment