Skip to content

Instantly share code, notes, and snippets.

@charlesetc
Last active May 25, 2017 16:32
Show Gist options
  • Save charlesetc/a867e6888c1dc589e01f0405c69dd016 to your computer and use it in GitHub Desktop.
Save charlesetc/a867e6888c1dc589e01f0405c69dd016 to your computer and use it in GitHub Desktop.
Use pandoc to build directory md->html
#!/bin/bash
name=$(basename $(pwd))
style=kate
flags=" -s --highlight-style $style"
if [ -f "$name.html" ] ; then
flags="$flags -A $name.html "
fi
if [ -f "$name.css" ] ; then
flags="$flags -c /$name.css "
cp $name.css build/$name.css
fi
find . -name "*.md" | while read file ; do
dname=`dirname "$file"`
bname=$dname/`basename "$file" .md`
mkdir -p build/$dname
fileflags=""
if [ -f "$bname.html" ] ; then
fileflags="$fileflags -A $bname.html "
fi
if [ -f "$bname.css" ] ; then
cp $bname.css build/$bname.css
fileflags="$fileflags -c ./$bname.css "
fi
pandoc $file $fileflags $flags -o build/$bname.html
done
# static files
if [ -d "static" ] ; then
cp ./static/* build
fi
@charlesetc
Copy link
Author

Usage: nspace

It looks at the directory you're in. dirname.html and dirname.css are always inserted -- filename.css and filename.html are done on a per-file basis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment