diff options
author | Franck Cuny <franck.cuny@gmail.com> | 2016-12-12 17:09:30 -0800 |
---|---|---|
committer | Franck Cuny <franck.cuny@gmail.com> | 2016-12-12 17:09:30 -0800 |
commit | d0a681c5b2386dc16a99b176d1bea5d6867c6be1 (patch) | |
tree | 7c2b467127d8a2264cd4b2121595124dbfd1515f /bin/md-preview | |
parent | [tmux] New window PATH is $HOME (diff) | |
download | emacs.d-d0a681c5b2386dc16a99b176d1bea5d6867c6be1.tar.gz |
[bin] Add a script to render markdown to HTML.
Diffstat (limited to 'bin/md-preview')
-rwxr-xr-x | bin/md-preview | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/bin/md-preview b/bin/md-preview new file mode 100755 index 0000000..07d06e5 --- /dev/null +++ b/bin/md-preview @@ -0,0 +1,24 @@ +#!/bin/bash + +# Render a markdown file to HTML, as a preview. + +set -e + +INPUT="${1:-README.md}" +OUTPUT="${2:-/tmp/output.html}" + +if [ ! -f "${INPUT}" ]; then + echo "You need to specify an input file" 1>&2 + exit 1 +fi + +[ -e "${OUTPUT}" ] && rm "${OUTPUT}" + +pandoc -f markdown_github -c https://goo.gl/OVmlwT --self-contained -o "${OUTPUT}" "${INPUT}" + +if [ -e "${OUTPUT}" ]; then + open "${OUTPUT}" +else + echo "Failed." + exit 1 +fi |