Skip to content

Instantly share code, notes, and snippets.

@reasonset
Created June 21, 2016 07:52
Show Gist options
  • Save reasonset/10d1fb30aacfa5643e37740ca185c66d to your computer and use it in GitHub Desktop.
Save reasonset/10d1fb30aacfa5643e37740ca185c66d to your computer and use it in GitHub Desktop.
#!/usr/bin/zsh
# Generate HTML files from Markdown files.
# It convert foo/bar.md to foo/bar.html
# This needs Pandoc.
STYLE_FILE="$HOME/local/repos/markdown-css/build/github/github.css"
BODY_CLASS="github"
PANDOC_OPTS=(-s --self-contained -t html5 -c $STYLE_FILE --toc)
for i in **/*.md
do
pandoc "$i" $PANDOC_OPTS -o "${i:r}".html && sed -i -e 's/<body>/<body class="'"$BODY_CLASS"'">/' "${i:r}".html
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment