: Filter for converting a MATHS document into HTML. # was WWWHOST=www.csci.csusb.edu; export WWWHOST # //www/ host where page is published # was WWWHOST=ftp.csci.csusb.edu; export WWWHOST # //www/ host where page is published WWWHOST=csci.csusb.edu; export WWWHOST # //www/ host where page is published WEBHOST=ftp.csci.csusb.edu\\/public\\/faculty\\/dick; export WEBHOST # //web/ host where page is published 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 elif expr $1 : '.*\.html$' >/dev/null then htmlfile="$1"; name=`expr $htmlfile : '\(.*\)\.html$'`; mthfile=$name.mth echo "Assuming that $htmlfile is to be made from $mthfile" else name=$1; mthfile=$1.mth; htmlfile=$1.html fi txtfile=$name.txt unix2dos <$mthfile >$txtfile escapedName=`echo $name|sed 's/\\//\\\\\\//'` BIBLIOGRAPHYURL="http:\\/\\/csci.csusb.edu\\/dick\\/biba.php?from=$escapedName\\&search=" LOOKUPURL="http:\\/\\/csci.csusb.edu\\/dick\\/bib.php?from=$escapedName\\&search=" htmlbase=`basename $htmlfile` mthbase=`basename $mthfile` export mthfile name htmlfile 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 /u/faculty/dick/bin/expand.includes $mthfile| sed -n '/^\.[ OCNBSL]/p'| 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[^.]/||/^\.Close$/{n--; if(n<0)n=0; }'| sed -n 's/^\.Open *\([: ]*\)\(.*\)$/
  • \1\2<\/A>/p s/^\. *\([: ]*\)\(.*\)$/
  • \1\2<\/A>/p' >$contents # extract index /u/faculty/dick/bin/expand.includes $mthfile|ascii2html | tex2html | sed -n ' /::/{ /^[ ]*\([A-Za-z0-9_]*\)[ ]*([^)]*)[ ]*::=[ ]*.*$/s//
  • \1<\/A> (Function definition)/p /^[ ]*For .*,[ ]*\([A-Za-z0-9_]*\)[ ]*([^)]*)[ ]*::=[ ]*.*$/s//
  • \1<\/A> (Function definition)/p /^[ ]*\([A-Za-z0-9_&;=+*-]*\)[ ]*::=[ ]*.*$/s//
  • \1 <\/A>(Definition)/p /^[ ]*\([A-Za-z0-9_]*\)[ ]*([^)]*)[ ]*::[ ]*.*$/s//
  • \1<\/A> (Function Declaration)/p /^[ ]*For .*,[ ]*\([A-Za-z0-9_]*\)[ ]*([^)]*)[ ]*::[ ]*.*$/s//
  • \1<\/A> (Function Declaration)/p /^[ ]*\([A-Za-z0-9_]*\)[ ]*::[ ]*.*$/s//
  • \1 <\/A>(Declaration)/p bdone } /|-/{ s/^.*(.*|-[ ]*(\([^)]*\)):[^:].*$/
  • \1 <\/A>(Theorem)/p s/^[^(]*|-[ ]*(\([^)][^)]*\)):[^:].*$/
  • \1 <\/A>(Axiom)/p bdone } s/^[ ][ ]*(\([^)][^)]*\)):[^:].*$/
  • \1 <\/A>(Formula)/p s/^[^ ].*(\([^)][^)]*\)):[^:].*$/
  • \1 <\/A>(Label)/p s/(\([^)][^)]*\)):[^:].*$/
  • \1 <\/A>(Label)/p s/^[^ ].*--(\([^)]*\))$/
  • \1 <\/A>(Label)/p s/^\.Key [ ]*\(.*\)$/
  • \1 <\/A>(Key)/p :done' |sort >$index # /u/faculty/dick/bin/expand.includes $mthfile|br 511|awk 'BEGIN{n=1; } /^\.Open/{ $1=$1 n;n++; if(n>6)n=6;} /^\. ./{ $1=$1 n; } /^\.Close[^.]/||/^\.Close$/{n--; if(n<1)n=1; } {print}'|ascii2html| tex2html | sed '/^\.As_is/bend s/`\([^`]*\)`/\1<\/span>/g :end'| ( if [ -x ./standard.header.sh ] then ./standard.header.sh $name else echo "$name on "`date`"" fi if [ -x ./standard.include.sh ] then ./standard.include.sh $source.mth else if [ -r standard.include.html ] then cat standard.include.html fi fi if fgrep -ls ".pdf" $mthfile >/dev/null then echo '
    Opening the PDF files on this page may require you to download' echo '' echo 'Adobe Reader or an equivalent viewer (GhostScript).
    ' fi if fgrep -ls ".ppt" $mthfile >/dev/null then echo '
    Opening the PPT files on this page may require you to download' echo 'a viewer for MS Power Point files.
    ' fi echo '

    Contents

    ' echo "
      " sed '/^\.Close/{ s/^\.Close\.Net \(.*\)/<\/ol>
      (End of Net \1<\/A>)<\/div>
      / s/^\.Close\.Net.*/<\/ol>
      (End of Net)<\/div>
      / s/^\.Close\.Let\(.*\)/<\/ol>
      (Close Let \1)
      / s/^\.Close\.Consider\(.*\)/<\/ol>
      (Close Consider \1)
      / s/^\.Close\.Case\(.*\)/<\/ol>
      (Close Case \1)
      / s/^\.Close\.List.*/<\/ol>
      / s/^\.Close\.Set.*/<\/ul>/ s/^\.Close\.Box.*/<\/ol>
      / s/^\.Close\.Table.*/<\/table>/ s/^\.Close\.Tuple.*/<\/ul>/ /^\.Close \(.*\)/s//<\/ol>

      . . . . . . . . . ( end of section \1<\/A>) <\/em>\<\<<\/A>Contents | End\>\><\/A>/ /^\.Close/s/.*/<\/ol>/ bdone } /^\.As_is/{ s/^\.As_is\(.*\)/

      \1<\/pre>/
      bdone
      }
      s/^$/

      / /|-/{ s/^[ ]*([ ]*)|-[ ]*/ (above)|-/ s/^[ ]*(\([^),]*\)\([^)]*\))[ ]*|-[ ]*/(\1<\/X>\2)|-/ :whileX /<.X>/{ s/<.X>,[ ]*\([^),]*\)/<\/A>, \1<\/X>/ s/<.X>[ ]*)/<\/A>) / bwhileX } /::/bdollars s/[ ]*|-[ ]*/|-/ s/^|-(\([^)][^)]*\)):[ ]*\(.*\)$/

    1. |- (\1<\/A>): \2<\/span>/ s/^|-\(.*\)$/
    2. |-\1<\/span>/ s/\(.*(.*\)|-*(\(.*\)):\(.*\)$/
    3. \1|-<\/A> (\2<\/A>): \3<\/span>/ s/^[ ]*\((.*\)|-\(.*\)$/
    4. \1|-\2<\/span> / bnwff } /::/!{ s/^(\([^)][^)]*\)):[ ]*/
      (
      \1<\/A>): / s/^ [ ]*(\([^)][^)]*\)):[ ]*/
    5. (\1<\/A>): / s/^ [ ]*(\([^)][^)]*\)):[ ]*\(.*\)$/
    6. (\1<\/A>): \2<\/span>/ /\1<\/span>/ /\1/ } :nwff s/--(\([^)][^)]*\))$/-- -- --(\1<\/A>)
      / /{.*}/!{ s/^[ ]*Let[ ]*{/
    7. Let{
        / s/^[ ]*[pP]o[ ]*{/
      1. Po{
          / s/^[ ]*Case[ ]*{/
        1. Case{
            / s/^[ ]*Else[ ]*/
          1. Else/ s/^[ ]*Consider[ ]*{/
          2. Consider{
              / s/^\(.*\)Net[ ]*{[ ]*/\1
              Net{
                / } :ends /{.*}/!{ s/^
                \(}[.,]*\)[ ]*$/
                \1<\/ol>/ s/^
              1. \(}[.,]*\)[ ]*$/
                \1<\/ol>/ s/^[ ]*\(}[.,]*\)[ ]*$/
                \1<\/ol>/ /^[ ]*}=::./{ s/^[ ]*\(.*}=::\)[ ]*\(.*\)\.$/<\/ol>
                \1\2<\/A>.<\/div>/ bdone } } /^\.See /{ s/^\.See[ ]*mailto:\(.*\)\([,.:; ]*\)$/\1<\/A>\2/ s/^\.See[ ]*telnet:\(.*\)\([,.:; ]*\)$/\1<\/A>\2/ s/^\.See[ ]*ftp:\(.*\)\([,.:; ]*\)$/\1<\/A>\2/ s/^\.See[ ]*news:\(.*\)\([,.:; ]*\)$/\1<\/A>\2/ s/^\.See[ ]*file:\(.*\)\([,.:; ]*\)$/\1<\/A>\2/ s/^\.See \('$BIBLIOGRAPHYURL'\)#[ ]*\(.*\)[ ]*$/\[\2<\/cite><\/A>\]/ s/^\.See [ ]*\[\(.*\)\][ ]*$/\[\1<\/cite><\/A>\]/ s/^\.See [ ]*\[\(.*\)\]\(.*\)$/\[\1<\/cite><\/A>\]\2/ s/\/\/www\//\/\/'$WWWHOST'\// s/\/\/web\//\/\/'$WEBHOST'\// s/^\.See \(.*\):\(\/\/.*\)\/\([^/]*\)\.\([^.][^.]*\)#\(.*\)$/\[ \5 in \3<\/cite> <\/A>\]/ s/^\.See \(.*\):\(\/\/.*\)\/\([,.:; ][,.:; ]*\)$/\[ \1:\2\/<\/cite><\/A> \] \3 / s/^\.See \(.*\):\(\/\/.*\)\/$/\[ \1:\2\/<\/cite> <\/A>\]/ s/^\.See \(.*\):\(\/\/.*\)\/\([^/]*\)\([,.:; ][,.:; ]*\)$/\[ \3<\/cite><\/A>\] \4 / s/^\.See \(.*\):\(\/\/.*\)\/\([^/]*\)$/\[ \3<\/cite> <\/A>\]/ s/^\.See \(.*\):\(\/\/.*\)\/\([^/]*\)\.\([^.]*\)\([,.:; ][,.:; ]*\)$/\[ \3<\/cite><\/A>\] \5/ s/^\.See \(.*\):\(\/\/.*\)\/\([^/]*\)\.\([^.]*\)$/\[ \3<\/cite><\/A>\] / s/^\.See \(.*\):\(\/[^/].*\)\([,.:; ][,.:; ]*\)$/ [\2]<\/A> \3/ s/^\.See \(.*\):\(\/[^/].*\)$/ [\2] <\/A>/ s/^\.See \(.*\)\([,.:; ][,.:; ]*\)$/\[ \1<\/cite><\/A>\] \2 / s/^\.See \.\/\(.*\)$/\[ \1<\/cite> <\/A>\]/ s/^\.See \(\.\.\/.*\)$/\[ \1<\/cite> <\/A>\]/ s/^\.See \(.*\)$/\[ \1<\/cite> <\/A>\]/ bdone } /^\.Key /{ s/^\.Key [ ]*\(.*\)$/ \1<\/strong> <\/A>/ bdone } /^\.Find /{ s/^\.Find [ ]*\(.*\)$/\1<\/cite><\/A>/ bdone } /^\.Quiz [ ]*.*[ ][ ]*.*$/{ s/^\.Quiz [ ]*\(.*\)[ ][ ]*\(.*\)/?<\/A>/ bdone } /^\.Quiz /{ s/^\.Quiz [ ]*\(.*\)/?<\/A>/ bdone } :dollars /^\.[ OC]/!s/$\([=A-Za-z\\][A-Za-z0-9_\\]*\)/\1<\/em><\/A>/g /::/bdefs /^[ ]/{ s/^[ ]\(.*\)$/
                \1/ bdone } /^\./{ s/^\.Open\(.\) *\(.*\)$/
                \2<\/H\1><\/A>
                  / s/^\.Bibliography *\(.*\)$/
                  \1

                  References<\/A><\/h2>/ s/^\.Set[ ]*$/