deck2data (894B)
1 #!/bin/sh 2 3 # temporary script to workaround stdio buffering problem 4 # takes a deck file and converts all cards to html 5 # outputs 1 per line in the form "cardid\tfront\tback" 6 7 . ./config 8 9 usage() { 10 echo "usage: $0 cards.deck" 11 exit 1 12 } 13 14 [ $# -eq 1 ] || usage 15 16 # remove extension 17 deck=${1%.*} 18 19 # hack to expand DELIM 20 IFS=$(printf $DELIM) 21 22 while read id _; do 23 path="$deck"/"$id" 24 front=$(md2html "$path"/front.md | tr -d '\n' | 25 sed 's;src="\([^"]*\)";src="/_/'$path'/\1";g') 26 back=$(md2html "$path"/back.md | tr -d '\n' | 27 sed 's;src="\([^"]*\)";src="/_/'$path'/\1";g') 28 29 extra="$path"/extra.html 30 if [ -f "$extra" ]; then 31 extra=$(cat "$extra" | tr -d '\n') 32 front="$(echo "$front" | sed 's@==EXTRA==@'"$extra"'@g')" 33 back="$(echo "$back" | sed 's@==EXTRA==@'"$extra"'@g')" 34 fi 35 36 printf "%s\t%s\t%s\n" "$id" "$front" "$back" 37 done < $1 \ 38 | sed 's:\*\(\[[^*]*\)\*:<em>\1</em>:g' \ 39 | rubify