: Filter for converting a MATHS document into HTML. WWWHOST=www.csci.csusb.edu; export WWWHOST # //www/ host where page is published WEBHOST=web.csusb.edu; 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 BIBLIOGRAPHYURL="http:\\/\\/www.csci.csusb.edu\\/cgi-bin\\/dick\\/bib?from=$name\\&search=" htmlbase=`basename $htmlfile` mthbase=`basename $mthfile` 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 '/^\.[ OCNBSL]/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[^.]/||/^\.Close$/{n--; if(n<0)n=0; }'| sed -n 's/^\.Open *\([: ]*\)\(.*\)$/
  • \1\2<\/A>/p s/^\. *\([: ]*\)\(.*\)$/
  • \1\2<\/A>/p' >$contents # ascii2html <$mthfile | 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 :done' |sort >$index # /u/faculty/dick/bin/expand.includes $mthfile|br 255|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| sed '/^\.As_is/bend s/`\([^`]*\)`/\1<\/i>/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 echo '

    Contents' echo '(index)

    ' echo "
      " sed '/^\.Close/{ s/^\.Close\.Net \(.*\)/<\/ol><\/div>
      (End of Net \1<\/A>)
      / s/^\.Close\.Net.*/<\/ol><\/div>
      (End of Net)
      / 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.*/<\/tr><\/td><\/table>/ s/^\.Close\.Tuple.*/<\/ul>/ /^\.Close \(.*\)/s//

      . . . . . . . . . ( end of section \1<\/A>) <\/em>\<\<<\/A>Contents | Index\>\><\/A>/ /^\.Close/d 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/^[ ]*|-[ ]*(\([^)][^)]*\)):[ ]*/

    1. |- (\1<\/A>): / s/^[ ]*|-[ ]*/
    2. |-/ s/\(.*(.*\)|-[ ]*(\(.*\)):/
    3. \1|-<\/A> (\2<\/A>): / s/^[ ]*\((.*\)|-/
    4. \1|- / s/^[ ][ ]*(\([^)][^)]*\)):[ ]*/
    5. (\1<\/A>): / s/^(\([^)][^)]*\)):[ ]*/
      (
      \1<\/A>): / bnwff } /)::/!s/^(\([^)][^)]*\)):[ ]*/
      (\1): / /)::/!s/(\([^)][^)]*\)):[ ]*/(
      \1<\/A>): / /::/!s/^[ ][ ]*/
    6. / :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><\/div>
                \1\2<\/A>./ 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>\]/ 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[ ]*$/