Skip to content

Instantly share code, notes, and snippets.

@shamille
Last active August 29, 2015 14:17
Show Gist options
  • Save shamille/2003c60930f29f83357f to your computer and use it in GitHub Desktop.
Save shamille/2003c60930f29f83357f to your computer and use it in GitHub Desktop.
Script to create web page from markdown file using pandoc and then update website via git
#!/bin/bash
# md-to-html.sh
# Script to create web page from markdown file using Pandoc
read -e -p "Enter filename: " mdFile
tmpFile=`cat $mdFile`
echo "$tmpFile" > forPandoc.txt
title="${mdFile%.*}"
echo "<html>
<head>
<title>"$title"</title>
</head>
<body>" > htmlFile.html
pandoc -f markdown -t html forPandoc.txt >> htmlFile.html
echo "</body></html>" >> htmlFile.html
extension=".html"
newFile="${title}${extension}"
mv -i htmlFile.html $newFile
git commit -m "change from script" $newFile | git push
rm forPandoc.txt
echo "All done. Your file is called $newFile."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment