Last active
May 25, 2017 16:32
-
-
Save charlesetc/a867e6888c1dc589e01f0405c69dd016 to your computer and use it in GitHub Desktop.
Use pandoc to build directory md->html
This file contains hidden or 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 | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.