#!/bin/sh # Turns text files into citable XHTML documents. Newline=" " IFS=$Newline POOL="$1" XHTMLHeader=' ' if [ -d "$POOL" ] || [ -f "$POOL" ] ; then Lint ( ) { sed -e 's/&/\&/g' -e 's//\>/g' -e 's/"/\"/g' -e "s/'/\'/g" } Text2Body () { echo "Processing $LINKNAME ..." 1>&2 number=0 echo "

File: <$LINKNAME>

" echo "
    " for line in $(cat "$@") ; do number=$(($number+1)) echo "
  1. $(echo $line | Lint)
  2. " done echo "
" unset number } if [ -d "$POOL" ] ; then DIR="$POOL" ; POOL="$(ls "$POOL" | sed /.xhtml$/d)" ; fi if [ "$POOL" != "" ] ; then echo Files to process: $(echo $POOL | column -t) for FILE in $POOL ; do LINKNAME="$(echo $DIR$FILE | sed 's/.*\///' | Lint)" FILENAME="$(ls -l $DIR$FILE | sed 's/.*-> .*\///' | Lint)" XHTMLHead=" $LINKNAME " echo "$XHTMLHeader$Newline$XHTMLHead$Newline " > "$LINKNAME.xhtml" Text2Body "$DIR$FILE" >> "$LINKNAME.xhtml" echo " $Newline" >> "$LINKNAME.xhtml" done echo "Done processing!" else echo "No files to process here." fi else echo "This isn't a valid directory or file." fi