{\SGMLgrabber{sqrt}\sqrt}
% \end{macrocode}
%
% \changes{v0.08}{1996/03/16}{Add basic support for array element}
%
% Hate allocating registers, so this will probably go, but for now
% give myself four (global) count registers to play with.
% \begin{macrocode}
\newcount\HTMLrow
\newcount\HTMLcol
\newcount\HTMLrowspan
\newcount\HTMLcolspan
% \end{macrocode}
%
% The HTML array element. Support for ALIGN, COLSPAN, ROWSPAN
% LABELS, LDELIM and RDELIM. However not all combinations of alignment
% and labels do `the right thing'.
%
% \changes{v0.09}{1996/03/21}{COLSPEC support for ARRAY}
%
% Uses a \TeX\ primitive |\halign| construction, rather than use the
% \LaTeX\ |array| environment directly.
% \begin{macrocode}
\SGMLdef{{\ifnum`}=0\fi
\let\do\arraydo
\let\doimplied\arrayimplied
\let\HTMLal.%
\let\HTMLar.%
\global\HTMLrow\z@
\let\HTMLabox\vcenter
\the\toks@
\setbox\z@\vbox\bgroup\halign\bgroup
\strut\span\HTMLacolspec\cr\nocr}
% \end{macrocode}
%
% \begin{macro}{\HTMLacolspec}
% \changes{v0.09}{1996/03/21}{macro added}
% \begin{macrocode}
\def\HTMLacolspec{##&#}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\HTMLamakepream}
% \changes{v0.09}{1996/03/21}{macro added}
% \begin{macrocode}
\def\HTMLamakepream#1{%
\let\HTMLacolspec\@empty
\let\@sharp\relax
\lowercase{\@tfor\@tempc:=#1}\do{%
\if\@tempc l%
\edef\HTMLacolspec{\HTMLacolspec\@sharp\hfill&}%
\else
\if\@tempc c%
\edef\HTMLacolspec{\HTMLacolspec\hfill\@sharp\hfill&}%
\else
\if\@tempc r%
\edef\HTMLacolspec{\HTMLacolspec\hfill\@sharp&}%
\else
\if\@tempc +%
\edef\HTMLacolspec{\HTMLacolspec$+$}%
\else
\if\@tempc -%
\edef\HTMLacolspec{\HTMLacolspec$-$}%
\else
\if\@tempc =%
\edef\HTMLacolspec{\HTMLacolspec$=$}%
\fi
\fi
\fi
\fi
\fi
\fi}%
\def\@sharp{########}%
\edef\HTMLacolspec{\HTMLacolspec&\@sharp}}
% \end{macrocode}
% \end{macro}
%
% \begin{macrocode}
\SGMLdef{\HTMLendarray}
% \end{macrocode}
%
% \begin{macrocode}
\let\HTMLcr\cr
% \end{macrocode}
%
% \begin{macro}{\HTMLendarray}
% Non LABELS ending
% \begin{macrocode}
\def\HTMLendarray{%
\endi\crcr\egroup\egroup
\ifx\HTMLabox\vtop
\setbox\z@\vtop{\unvbox\z@}%
\else
\ifx\HTMLabox\vcenter
\dimen@\ht\z@
\advance\dimen@\dp\z@
\divide\dimen@\tw@
\advance\dimen@-\ht\z@
\setbox\z@\hbox{\raise\dimen@\box\z@}%
\fi
\fi
\dimen@=\ht\z@
\setbox\z@
\hbox{$\left\HTMLal\kern-1em\vcenter{\box\z@}\kern-1em\right\HTMLar$}%
\advance\dimen@-\ht\z@
\raise\dimen@\box\z@
\ifnum`{=0\fi}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\HTMLendarraylabels}
% LABELS ending
% \begin{macrocode}
\def\HTMLendarraylabels{%
\endi\crcr\strut\cr\egroup\egroup
\setbox2=\vsplit\z@ to \baselineskip
\setbox\z@\vbox{\unvbox\z@\global\setbox\@ne\lastbox}%
\setbox4\hbox{\unhbox\@ne\unskip\global\setbox\@ne\lastbox}%
\vcenter{%
\box2
\hbox{$\kern\wd\@ne
\left\HTMLal\kern-\wd\@ne
\vcenter{\box\z@}%
\right\HTMLar$}}%
\ifnum`{=0\fi}}
% \end{macrocode}
% \end{macro}
%
% \begin{macrocode}
\def\nocr{\relax\iffalse{\fi\let\HTMLcr\relax\iffalse}\fi}
% \end{macrocode}
%
% \begin{macrocode}
\SGMLdef{%
\endi\HTMLcr
\global\advance\HTMLrow\@ne
\global\HTMLcol\z@}
% \end{macrocode}
%
% \begin{macrocode}
\SGMLdef
{}
% \end{macrocode}
%
% \begin{macrocode}
\SGMLdef- {%
\let\do\itemdo
\gdef\@gtempa{\global\advance\HTMLcol\@ne}%
\gdef\@gtempb{}%
\gdef\@gtempc{}%
\global\HTMLcolspan\@ne
\the\toks@
\endi%
\@gtempc
\@gtempa
% \end{macrocode}
%
% If an earlier row contained an entry spanning down to this point,
% need to jump across to the next column (and perhaps further).
% \begin{macrocode}
\spanifneeded
% \end{macrocode}
%
% |\@gtempb| is normally empty but will be defined if the item had an
% ALIGN attribute.
% \begin{macrocode}
\@gtempb
% \end{macrocode}
% First box each entry which allows measuring needed (but not yet
% done) for vertical spanning.
% \begin{macrocode}
\setbox\z@\hbox\bgroup$%
\def\endi{\unskip$\egroup%
\quad\HTMLaleft\box\z@\HTMLaright\quad&}%
\ignorespaces}
% \end{macrocode}
%
% \begin{macro}{\spanifneeded}
% If the current row/column is in the list of spanned entries, jump to
% next column and look again.
% \begin{macrocode}
\def\spanifneeded{%
\edef\@tempa{\noexpand\in@{,\the\HTMLrow/\the\HTMLcol,}{\spanitems}}%
\@tempa
\ifin@
\@firstofone{&}\global\advance\HTMLcol\@ne
\expandafter\spanifneeded
\fi}
% \end{macrocode}
% \end{macro}
%
% As usual handle end tags that may be omitted by making them
% translate to empty.
% \begin{macrocode}
\SGMLdef
{}
% \end{macrocode}
%
% \begin{macro}{\HTMLaleft}
% \begin{macro}{\HTMLaright}
% Default stuff to put around the entries. Locally redefined by an
% ALIGN attribute.
% \begin{macrocode}
\let\HTMLaleft\hfil
\let\HTMLaright\hfil
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\endi}
% Code to end an item. Extra indirection used to handle omitted tags.
% \begin{macrocode}
\let\endi\relax
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\arraydo}
% \changes{v0.09}{1996/03/21}{COLSPEC added}
% Handle ARRAY attributes.
% \begin{macrocode}
\def\arraydo#1#2{%
\def\@tempa{#1}\def\@tempb{#2}%
\def\@tempc{align}%
\ifx\@tempa\@tempc
\def\@tempc{top}%
\ifx\@tempb\@tempc
\let\HTMLabox\vtop
\else
\def\@tempc{bottom}%
\ifx\@tempb\@tempc
\let\HTMLabox\vbox
\fi
\fi
\else
\def\@tempc{ldelim}%
\ifx\@tempa\@tempc
\let\HTMLal\@tempb
\else
\def\@tempc{rdelim}%
\ifx\@tempa\@tempc
\let\HTMLar\@tempb
\else
\def\@tempc{labels}%
\ifx\@tempa\@tempc
\let\HTMLendarray\HTMLendarraylabels
\else
\def\@tempc{colspec}%
\ifx\@tempa\@tempc
\HTMLamakepream{#2}%
\fi
\fi
\fi
\fi
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\arrayimplied}
\def\arrayimplied#1{%
\def\@tempa{labels}\def\@tempb{#1}%
\ifx\@tempa\@tempb
\let\HTMLendarray\HTMLendarraylabels
\fi}
% \end{macro}
%
% \begin{macro}{\itemdo}
% Handle ITEM attributes
% \begin{macrocode}
\def\itemdo#1#2{%
\def\@tempa{#1}\def\@tempb{#2}%
\def\@tempc{colspan}%
\ifx\@tempa\@tempc
\global\HTMLcolspan#2\relax
\gdef\@gtempa{\@multispan#2\relax\global\advance\HTMLcol#2\relax}%
\else
\def\@tempc{align}%
\ifx\@tempa\@tempc
\def\@tempc{left}%
\ifx\@tempb\@tempc
\gdef\@gtempb{\let\HTMLaleft\relax}%
\else
\def\@tempc{right}%
\ifx\@tempb\@tempc
\gdef\@gtempb{\let\HTMLaright\relax}%
\fi
\fi
\else
\def\@tempc{rowspan}%
\ifx\@tempa\@tempc
\global\HTMLrowspan#2\relax
\gdef\@gtempc{%
\@tempcnta=\HTMLrow
\advance\@tempcnta\HTMLrowspan
% \end{macrocode}
%
% Double loop adds all the entries below this a ROWSPAN entry
% to |\spanitems| list.
% \begin{macrocode}
\loop
\@tempcntb=\HTMLcol
\advance\@tempcntb\HTMLcolspan
\advance\@tempcnta\m@ne
\ifnum\@tempcnta>\HTMLrow
{\loop
\xdef\spanitems{%
\spanitems\the\@tempcnta/\the\@tempcntb,}%
\advance\@tempcntb\m@ne
\ifnum\@tempcntb>\HTMLcol
\repeat}%
\repeat}%
\fi
\fi
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\spanitems}
% Initial value for list of spanned entries.
% \begin{macrocode}
\def\spanitems{,}
% \end{macrocode}
% \end{macro}
%
% \begin{macrocode}
\SGMLentity{thinsp}{\,}
\SGMLentity{emsp}{\quad}
% \end{macrocode}
%
% Far from final list of math symbol entity names\ldots
% \begin{macrocode}
\SGMLentity{alpha}{\alpha}
\SGMLentity{beta}{\beta}
\SGMLentity{gamma}{\gamma}
\SGMLentity{Gamma}{\Gamma}
% \end{macrocode}
%
% \begin{macrocode}
\SGMLentity{int}{\int}
\SGMLentity{sum}{\sum}
% \end{macrocode}
%
% \begin{macrocode}
\SGMLentity{lbrace}{\lbrace}
\SGMLentity{rbrace}{\rbrace}
% \end{macrocode}
%
% \begin{macrocode}
\SGMLentity{times}{\times}
\SGMLentity{cup}{\cup}
\SGMLentity{cap}{\cap}
\SGMLentity{vee}{\vee}
\SGMLentity{wedge}{\wedge}
\SGMLentity{infty}{\infty}
\SGMLentity{oplus}{\oplus}
\SGMLentity{ominus}{\ominus}
\SGMLentity{otimes}{\otimes}
% \end{macrocode}
%
% \begin{macrocode}
\SGMLentity{sin}{\sin}
\SGMLentity{cos}{\cos}
\SGMLentity{tan}{\tan}
% \end{macrocode}
%
% \section{HTML3 Tables}
% \changes{v0.09}{1996/03/21}{TABLE added (mjd)}
% Not done yet, but here is a start\ldots
%
% Final version will probably need primitive |\halign| coding
% as for (but hopefully better than) array stuff above. Also
% will need to be lontable-like.
%
% This is all very slapdash and temporary [mjd,1996/03/20].
% Don't expect good-looking results, just results, occasionally.
%
% \begin{macrocode}
\SGMLdef{\begin{table}[htp]\centering\begin{tabular}{*{10}c}}
\SGMLdef
{\end{tabular}\end{table}}
\SGMLdef{\ifhmode\expandafter\\\fi\relax}
\SGMLdef
{\\\relax}
\SGMLdef{\ifvmode\else\expandafter\hiddenamp\fi}
\def\hiddenamp{&}
% \end{macrocode}
% if | | | is present for each cell, then | | | doesn't
% need to do anything
% \begin{macrocode}
\SGMLdef{}
% \end{macrocode}
%
% Whoa, if I'm to define caption properly I'd have to look up
% how/where it's used. Who, lazy old me?
%
% \begin{macrocode}
\SGMLdef{\end{tabular}\begingroup\bfseries}
\SGMLdef{\endgroup\par\smallskip\begin{tabular}{*{10}{c}}}
% \end{macrocode}
%
% \begin{macrocode}
%