COMMENT(-- $Id: masonyodl.yo,v 1.1.1.1 2001/03/11 07:50:05 sashav Exp $ --)
COMMENT(-----------------------------------------------------------------------
-- We want more functionality and some better layout
-- proto changes:
--     starttable(nColumns)(Alignment)(borderwidth)
------------------------------------------------------------------------------)
NEWCOUNTER(RRindentlevel)
NEWCOUNTER(RRnl)
SETCOUNTER(RRindentlevel)(0)
\
DEFINEMACRO(nltxt)(0)(\
    IFZERO(RRnl)()( ADDTOCOUNTER(RRnl)(-1)nltxt()))
\
UNDEFINEMACRO(XXnl)
DEFINEMACRO(XXnl)(0)(\
    NOTRANS(
)\
    whentxt(SETCOUNTER(RRnl)(RRindentlevel)nltxt()))
\
DEFINEMACRO(P)(0)(\
    SETCOUNTER(RRnl)(0)\
    whenhtml(SETCOUNTER(RRnl)(1)htmlcommand(<p>))\
    IFZERO(RRnl)(nl())())
\
UNDEFINEMACRO(starttable)
DEFINEMACRO(starttable)(3)(\
    SETCOUNTER(XXtablewidth)(ARG1)\
    whenhtml(IFZERO(ARG3)(htmlcommand(<table>))\
			 (htmlcommand(<table border=ARG3>))XXnl())\
    whenlatex(latexcommand(\begin{tabular}{)ARG2+latexcommand(}))\
    whenman(roffcmd(.TS)()()())\
    whenman(IFZERO(ARG3)(roffcmd(tab(`);)()()())\
			(roffcmd(allbox,tab(`);)()()()))\
    whenman(ARG2 NOTRANS(.
))\
    whenms(roffcmd(.TS)()()())\
    whenms(IFZERO(ARG3)(roffcmd(tab(`);)()()())\
		       (roffcmd(allbox,tab(`);)()()()))\
    whenms(ARG2+mscommand(.))\
    SETCOUNTER(XXtablewidth)(ARG1)\
    SETCOUNTER(XXparcounter)(0))
COMMENT(        For HTML, we'll need <table>, for
        LaTeX we'll need \begin{tabular}{alignment}. Also, we don't want
        paragraph delimiters.)
\
UNDEFINEMACRO(cell)
DEFINEMACRO(cell)(1)(\
    ADDTOCOUNTER(XXtableline)(1)\
    whenhtml(htmlcommand(<td>) ARG1 \
             IFZERO(XXcellcounter)\
                (htmlcommand(<br>))\
                ()\
             htmlcommand(</td>) XXnl())\
    whenlatex(ARG1 \
              IFZERO(XXcellcounter)\
                ()(latexcommand( & )))\
    whentxt( ARG1 )\
    whenms( ARG1 )\
             IFZERO(XXcellcounter)\
                ()\
                (mscommand(`\))\
    whenman( ARG1 )\
             IFZERO(XXcellcounter)\
                ()\
                (mancommand(`\))\
    ADDTOCOUNTER(XXcellcounter)(-1))
COMMENT(For HTML we need:
<td> text </td>, so that's fairly easy. If we're already at the last
cell, we need <td> text <br></td>.
For LaTeX: we need text followed by &, unless
        we're already at the last cell 'cuz in that case we need only text.
        Also we need to decrement the cell counter..)
\
UNDEFINEMACRO(cells)
DEFINEMACRO(cells)(2)(\
    ADDTOCOUNTER(XXtableline)(ARG1)\
    ADDTOCOUNTER(XXcellcounter)(-ARG1)\
    ADDTOCOUNTER(XXcellcounter)(1)\
    whenhtml(htmlcommand(<td colspan=ARG1 align=center>) ARG2 \
             IFZERO(XXcellcounter)\
                (htmlcommand(<br>))\
                ()\
             htmlcommand(</td>) XXnl())\
    whenlatex(\
    latexcommand(\multicolumn{)ARG1+latexcommand(}{c}{)ARG2+latexcommand(})\
              IFZERO(XXcellcounter)\
                ()(latexcommand( & )))\
    whentxt( ARG1 )\
    whenms( ARG1 )\
             IFZERO(XXcellcounter)\
                ()\
                (mscommand(`\))\
    whenman( ARG1 )\
             IFZERO(XXcellcounter)\
                ()\
                (mancommand(`\))\
    ADDTOCOUNTER(XXcellcounter)(-1))
\
DEFINEMACRO(indent)(1)(\
    whenhtml(htmlcommand(<ul>)ARG1+htmlcommand(</ul>))\
    whentxt(ADDTOCOUNTER(RRindentlevel)(4)ARG1+ADDTOCOUNTER(RRindentlevel)(-4))\
    whenman(roffcmd(.RS)()()()roffcmd(.IP)()()()ARG1+roffcmd(.RE)()()())\
    whenms())
\
DEFINEMACRO(startdl)(0)(\
    whenhtml(htmlcommand(<dl>))\
    whentxt(ADDTOCOUNTER(RRindentlevel)(4))\
    whenman(startdit()))
\
DEFINEMACRO(enddl)(0)(\
    whenhtml(htmlcommand(</dl>))\
    whentxt(ADDTOCOUNTER(RRindentlevel)(-4))\
    whenman(enddit()))
\
DEFINEMACRO(dl)(2)(\
    whenhtml(htmlcommand(<dt>)ARG1+htmlcommand(</dt><dd>)\
	     ARG2+htmlcommand(</dd>))\
    whentxt(ADDTOCOUNTER(RRindentlevel)(2)dit(ARG1)\
	    ADDTOCOUNTER(RRindentlevel)(2)nl()\
	    ARG2+ADDTOCOUNTER(RRindentlevel)(-4))\
    whenman(dit(ARG1)ARG2))
\
DEFINEMACRO(manpageauthors)(0)(\
    manpagesection(AUTHORS)\
    DEFINESYMBOL(XXmanpageAuthor))
