Skip to content

Instantly share code, notes, and snippets.

@j4mie
Created September 18, 2009 13:49
Show Gist options
  • Save j4mie/189059 to your computer and use it in GitHub Desktop.
Save j4mie/189059 to your computer and use it in GitHub Desktop.
#!/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