: Filter for converting a MATHS document into HTML. LOCALHOSTDOMAIN=.csci.csusb.edu; export LOCALHOSTDOMAIN LOCALHOST=www$LOCALHOSTDOMAIN; export LOCALHOST if [ $# -eq 0 ]; then echo Usage: $0 input_file\[.mth\]; exit 1; fi if expr $1 : '.*\.mth$' >/dev/null then mthfile=$1; name=`expr $mthfile : '\(.*\)\.mth$`; htmlfile=$name.html else name=$1; mthfile=$1.mth; htmlfile=$1.html fi if expr $mthfile : ".*/" >/dev/null then source=expr $name : ".*/\([^/]*\)$" else source=$name fi tmp=/tmp/mth2html$$; index=$tmp.index; contents=$tmp.contents trap "rm $tmp*" 1 2 3 # # extract contents list and index sed -n '/^\.[ OC]/p' $mthfile| ascii2html| awk 'BEGIN{n=0; } /^\.Open/{ for(i=1;i<=n;i++)$2=": " $2;n++; print} /^\. ./{ for(i=1;i<=n;i++)$2=": " $2; print} /^\.Close/{n--; if(n<0)n=0; }'| sed 's/^\.Open *\([: ]*\)\(.*\)$/
\1<\/pre>/ bdone } s/^$/
/ s/^[ ]*For /
For / /::/bnwff /|-/{ s/^[ ]*(\([^),]*\)\([^)]*\))[ ]*|-[ ]*/- (\1<\/X>\2)|-/ :whileX /<.X>/{ s/<.X>,[ ]*\([^),]*\)/<\/A>, \1<\/X>/ s/<.X>[ ]*)/<\/A>) / bwhileX } s/^[ ]*|-[ ]*/
- (above)|-/ s/|-[ ]*(\(.*\)):/|-<\/A>(\1): / s/^[ ][ ]*(\([^)][^)]*\)):[ ]*/
- (\1): / s/(\([^)][^)]*\)):/(\1<\/A>): / bnwff } s/(\([^)][^)]*\)):[ ]*/(\1<\/A>): / s/^[ ][ ]*/
- / :nwff /{.*}/!{ s/^[ ]*Let[ ]*{/
- Let{
/ s/^[ ]*[pP]o[ ]*{/
- Po{
/ s/^[ ]*Case[ ]*{/
- Case{
/ s/^[ ]*Else[ ]*/
- Else/ s/^[ ]*Consider[ ]*{/
- Consider{
/ s/^\(.*\)Net[ ]*{[ ]*/\1 Net{
/ } :ends /{.*}/!{ s/^
" echo "
\(}[.,]*\)[ ]*$/
\1<\/ol>/ s/^[ ]*\(}[.,]*\)[ ]*$/
\1<\/ol>/ /^[ ]*}=::.*$/{ s/^[ ]*\(}=::.*\)$/<\/ol>
\1/ bdone } } /^\.See /{ s/\/\/www\//\/\/'$LOCALHOST'\// s/^\.See \(.*\):\(\/\/.*\)\/\([^/]*\)\.\([^.][^.]*\)#\(.*\)$/\5\[\3<\/cite>\]<\/A>/ s/^\.See \(.*\):\(\/\/.*\)\/$/ \[\1:\2\/<\/cite>\] <\/A>/ s/^\.See \(.*\):\(\/\/.*\)\/\([^/]*\)$/ \[\3<\/cite>\] <\/A>/ s/^\.See \(.*\):\(\/\/.*\)\/\([^/]*\)\.\([^.]*\)$/ \[\3<\/cite>\] <\/A>/ s/^\.See \(.*\):\(\/[^/].*\)$/ [\2] <\/A>/ s/^\.See \(.*\)$/ \[\1<\/cite>\] <\/A>/ bdone } /::/bdefs /^[ ]/{ s/^[ ]\(.*\)$/
\1/ bdone } /^\./{ s/^\.Open\(.\) *\(.*\)$/\2<\/H\1><\/A>/ s/^\.Source *\(.*\)$/\1<\/cite>/ s/^\.Address *\(.*\)$/\1<\/address>/ s/^\.Image *\([^ ]*\)[ ]\(.*\)$/ / s/^\.\([1-6]\) \(.*\)$/ \2<\/H\1><\/A>/ bdone } :defs /::/{ /^[ ]*\([\\A-Za-z0-9_.!@#$%^&*-+|<>=~ ]*\)[ ]*::\([^=]*\)=\(.*\)$/s// - \1<\/A>::\2=\3/ /^[ ]*\([\\A-Za-z0-9_.!@#$%^&*-+|<>=~ ]*\)[ ]*::[ ]*\([^=]*\)$/s//
- \1<\/A>::\2/ /^[ ]*\([\\A-Za-z0-9_.!@#$%^&*-+|<>=~ ]*\)[ ]*\(([^)]*)\)::\([^=]*\)=\(.*\)$/s//
- \1<\/A>\2::\3=\4/ /^[ ]*\([\\A-Za-z0-9_.!@#$%^&*-+|<>=~ ]*\)[ ]*\(([^)]*)\)::\([^=]*\)$/s//
- \1<\/A>\2::\3/ /^[ ]*\([\\A-Za-z0-9_.!@#$%^&*-+|<>=~ ]*\)[ ]*\(([^)]*)\)::\([^=]*\)$/s//
- \1<\/A>\2::\3/ /^[ ]*\([\\A-Za-z0-9_.!@#$%^&*-+|<>=~ ]*\)[ ]*\(([^)]*)\)::\([^=]*\)$/s//
- \1<\/A>\2::>\3/ /^
- /!s/\(.*\)::\([^=]*\)$/
- \1::\2/ /^
- /!s/\(.*\)::\([^=]*\)=/
- \1::\2=/ } :done ' echo "
" echo 'Labels and Definitions in Alphabetical Order
' echo "" cat $index echo "
" [ -r $HOME/.signature.html ] && ( echo '
'; cat $HOME/.signature.html) echo "" ) >$htmlfile rm $tmp*