#!/bin/bash # Thu May 1 23:44:42 EDT 2003 # NAME: png2html # Copyright 2003, Chris F.A. Johnson # Released under the terms of the GNU General Public License version() { echo " $progname, version $version Copyright $copyright, $author $email This is free software, released under the terms of the GNU General Public License. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. " } usage() { echo " $progname - USAGE: $progname [OPTIONS] OPTIONS: -h - help: print this message -H - help: print more detailed message -v - verbose: -V - print version information Copyright 2003, Chris F.A. Johnson " } verbose=0 longusage=0 version="1.0" copyright=2003 author="Chris F.A. Johnson" progname=${0##*/} while getopts vVhH-: var do case "$var" in -) case $OPTARG in help) usage; exit ;; version) version; exit ;; esac ;; h) usage; exit ;; H) longusage=1; usage; exit ;; v) verbose=$(( $verbose + 1 )) ;; V) version; exit ;; *);; esac done shift $(( $OPTIND - 1 )) #[ "${1:+X}" ] && file=$1 || read -p "File name: " file #[ -f "$file" ] || exit 1 NL=$'\n' TAB=$'\t' header=0 comment=0 move=0 cat "$@" | sed -e '/^[^[]/ s/[0-9]\./& /g' -e 's/{/{ /' -e 's/}/ }/' | tr -s ' \t\r' '\n' | while read -r line do [ $verbose -ge 1 ] && { echo $line continue } if [ $header -eq 1 -o $comment -eq 1 ] then case $line in *]) printf "%s\n" "$line";header=0 ;; *}) printf "%s" "$line";comment=0 ;; *) printf "%s " "$line" ;; esac continue fi case $line in \[*) printf "%s " "$line"; header=1 ;; \{*) printf "\n%s " "$line"; comment=1 ;; 0-1|1-0|1/2-1/2) printf "\n%11s-%s\n\n" ${line%-*} ${line#*-} ;; [0-9]*... ) printf "\n%3s. %-8s" ${line%%.*} "..."; m=0 ;; [0-9]* ) printf "\n%4s " $line; m=0 ;; O-O*|0-0*) printf " %-8s" ${line//0/O} ;; [a-hRNBQK]*) printf " %-8s" $line ;; esac done echo