Created
September 18, 2009 13:49
-
-
Save j4mie/189059 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Convert a directory of .markdown files to HTML and PDF. | |
# Requires: markdown and htmldoc | |
for i in $( ls *.markdown ); | |
do | |
echo Compiling $i | |
name=$( echo $i | sed 's/.markdown//' ) | |
echo Generating Markdown... | |
markdown=`markdown $i` | |
title=$( echo "${markdown}" | grep '<h1>' | sed 's/<h1>\(.*\)<\/h1>/\1/' ) | |
echo Title is: $title | |
html="<html>\n<head>\n<title>${title}</title>\n</head>\n<body>\n${markdown}\n</body>\n</html>" | |
echo Generating HTML... | |
echo "$html" | htmldoc -t html - > html/${name}.html | |
echo Generating PDF... | |
echo "$html" | htmldoc -t pdf - > pdf/${name}.pdf | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment