summary refs log tree commit diff
path: root/bin/md-preview
blob: 07d06e5ab5943a2f54692d821e8922c48647259e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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