#!/bin/bash set -e #(( dummy = 1 )) [[ ! -x `which git` ]] && echo git executable not found && exit 1 [[ ! -x `which markdown` ]] && echo markdown executable not found && exit 1 [[ -z $1 ]] && echo git folder? && exit 1 repo=${1%%/} [[ ! -d $repo/ ]] && echo $repo/ not found && exit 1 if [[ -d $repo/.git/ ]]; then cd $repo/ git pull git status cd ../ fi echo echo COPYING TO $repo-www/ echo rm -rf $repo-www/ cp -a $repo/ $repo-www/ rm -rf $repo-www/.git/ cd $repo-www/ echo #echo LISTING SYMLINKS AND SPECIAL FILES #echo #find ./ ! -type f ! -type d #echo #echo LISTING NON-MARKDOWN AND NON-PNG FILES #echo #find ./ -type f | grep -vE '\.md$|\.mdown$|\.png$' | grep -vE '/bin/|/dotfiles/|/css/' #echo echo -n MARKDOWN TO HTML for md in `find ./ -type f | grep -vE '^\./bin/' | grep -E '\.md$|\.mdown$' | grep -v '/ssi-' | sort`; do dest=${md%\.md*} # allow MD links in the title title=`grep '^# ' $md | head -1 | sed -r 's/^# +//; s/<[^>]*>//g; s/\[//g; s/\]//g; s/\([^\)]*\)//g'` [[ -z $title ]] && echo NO TITLE FOUND FOR $md # what happens when there is a double quote in some title?... (( dummy == 1 )) && echo -e "$dest \t\t\t $title" && continue cat > $dest < $title EOF9 #-f links,image,html,smarty,strikethrough,toc,autolink,footnote #awk '($0 ~ /https?:\/\/[^ ]+/) {printf("%s\n", $0, text); next } { text = $0 }' $md \ markdown -f autolink,fencedcode $md \ | sed -r 's%
%
%g;
			  s%
%
%g' \ >> $dest && echo -n . || echo $md FAILED cat >> $dest <<-EOF9 EOF9 rm -f $md unset dest title done && echo DONE; unset md cd ../