Created
November 10, 2011 23:50
-
-
Save bxt/1356663 to your computer and use it in GitHub Desktop.
Bash script for invoking MarkdownJ to convert Markdown to HTML on CLI
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 | |
usestdi=off | |
filename=$1 | |
if [ $1 = "-h" ] ; then | |
echo "Usage: $0 mdfile [outfile]"; exit | |
fi | |
if [ $1 = "-" ] ; then | |
usestdi=on | |
filename=md2html-stdin | |
fi | |
outfile="`basename "$filename" .md`.html" | |
if [ $# -gt 1 ]; then | |
outfile="$2" | |
fi | |
> "$outfile" | |
cat <<"HEADER" > "$outfile" | |
<!DOCTYPE html> | |
<style> | |
body { | |
font-size:12px; | |
font-family:Arial,sans-serif; | |
max-width:400px; | |
margin:0 auto; | |
color:#000; | |
} | |
</style> | |
HEADER | |
if [ $usestdi == "on" ]; then | |
java -cp ~/Download/markdownj-1.0.2b4-0.3.0.jar com.petebevin.markdown.MarkdownProcessor >> "$outfile" | |
else | |
java -cp ~/Download/markdownj-1.0.2b4-0.3.0.jar com.petebevin.markdown.MarkdownProcessor < "$filename" >> "$outfile" | |
fi | |
echo $filename $outfile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment