% compile 3 timws: latex tex4ht-mathplayer
%            or   xhlatex tex4ht-mathplayer "html,3,sections+"
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% tex4ht-mathplayer.tex                                  %
% Copyright (C) 2002--            Eitan M. Gurari        %
%                                                        %
% This work may be distributed and/or modified under the %
% conditions of the LaTeX Project Public License, either %
% version 1.3 of this license or (at your option) any    %
% later version. The latest version of this license is   %
% in                                                     %
%   http://www.latex-project.org/lppl.txt                %
% and version 1.3 or later is part of all distributions  %
% of LaTeX version 2003/12/01 or later.                  %
%                                                        %
% This work has the LPPL maintenance status "maintained".%
%                                                        %
% This Current Maintainer of this work                   %
% is Eitan M. Gurari.                                    %
%                                                        %
% If you modify this file your changing the signature    %
% in \message{(signature)} below will be appreciated.    %
%                                                        %
%                             gurari@cse.ohio-state.edu  %
%                 http://www.cse.ohio-state.edu/~gurari  %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
\message{(<signature>)}

%%%%%%%%%%%%%%%%%% load style files %%%%%%%%%%%%%%%%%%%%%%%%%%

\ifx \HTML\UnDef
   \def\HTML{mathplayer}                   
   \def\CONFIG{\jobname}
   \def\MAKETITLE{\author{Eitan M. Gurari}}         
   \def\next{\input mktex4ht.4ht  \endinput}
   \expandafter\next
\fi

%%%%%%%%%%%%%%%%%%%%% definitions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcount\tmpcnt  \tmpcnt\time  \divide\tmpcnt  60
\edef\temp{\the\tmpcnt}
\multiply\tmpcnt  -60 \advance\tmpcnt  \time

\edef\version{\the\year-\ifnum \month<10 0\fi
  \the\month-\ifnum \day<10 0\fi\the\day
   -\ifnum \temp<10 0\fi \temp
   :\ifnum \tmpcnt<10 0\fi\the\tmpcnt}

\def\CopyYear.#1.{%
   \ifnum #1=\year #1\space\space\space\space\space\space
    \else          #1--\the\year\fi
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Preamble}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\<mathplayer\><<<
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
% mathplayer.4ht                        |version %
% Copyright (C) |CopyYear.2002.       Eitan M. Gurari         %
|<TeX4ht copyright|>
>>>



\<TeX4ht copyright\><<<
%                                                        %
% This work may be distributed and/or modified under the %
% conditions of the LaTeX Project Public License, either %
% version 1.3 of this license or (at your option) any    %
% later version. The latest version of this license is   %
% in                                                     %
%   http://www.latex-project.org/lppl.txt                %
% and version 1.3 or later is part of all distributions  %
% of LaTeX version 2003/12/01 or later.                  %
%                                                        %
% This work has the LPPL maintenance status "maintained".%
%                                                        %
% This Current Maintainer of this work                   %
% is Eitan M. Gurari.                                    %
%                                                        %
% If you modify this program your changing its signature %
% with a directive of the following form will be         %
% appreciated.                                           %
%            \message{signature}                         %
%                                                        %
%                             gurari@cse.ohio-state.edu  %
%                 http://www.cse.ohio-state.edu/~gurari  %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\immediate\write-1{version |version}
>>>


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Start Here}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%
\section{Header}
%%%%%%%%%%%%%%%%

\<configure mathplayer Preamble\><<<
\:CheckOption{xht} \if:Option 
  \Configure{html}{xht}
\else \:CheckOption{xml} \if:Option 
  \Configure{html}{xml}
\else
  \Configure{html}{html}
  \Configure{mathml}{m:}
\fi \fi
>>>


\<dtd lang\><<<
\expandafter
\ifx \csname a:dtd-lang\endcsname\relax EN\else
  \csname a:dtd-lang\endcsname
\fi
>>>

\<configure mathplayer tex4ht\><<<
\Configure{VERSION}{}
\:CheckOption{xht} \if:Option
   |<DOCTYPE and namespaces for xml and xht|>
\else \:CheckOption{xml} \if:Option
   |<DOCTYPE and namespaces for xml and xht|>
\else 
   \Configure{DOCTYPE}
    {\HCode{<!DOCTYPE html PUBLIC
                "-//W3C//DTD XHTML 1.1 plus MathML 2.0//|<dtd lang|>"\Hnewline
%                "http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd"\Hnewline
                "http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd"\Hnewline
                >\Hnewline }}
   \Configure{@HTML}
     {xmlns:m="http://www.w3.org/1998/Math/MathML"\Hnewline
      xmlns:dsi="http://www.dessci.com/mathml" \Hnewline}
   \Configure{@HEAD}
     {\HCode{
        <object id="MathPlayer" 
                classid="clsid:32F66A20-7614-11D4-BD11-00104BD3F987"
        ></object>\Hnewline
        <?import namespace="m" implementation="\#MathPlayer" ?>\Hnewline
        <!--http://www.dessci.com/webmath/mathplayer/-->\Hnewline
    }}
    \Configure{@BODY}
       {\HCode{<script language="javascript">\Hnewline<!--\Hnewline
               |<check for ie 5.5 and mathplayer|>\Hnewline-->\Hnewline
               </script>\Hnewline
       }}
    \Configure{math-xmlns}{}
\fi \fi
>>>

\<DOCTYPE and namespaces for xml and xht\><<<
   \Configure{DOCTYPE}
       {\HCode{<!DOCTYPE html PUBLIC
                "-//W3C//DTD XHTML 1.1 plus MathML 2.0//|<dtd lang|>"\Hnewline
                "http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd"\Hnewline
%                "http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd"\Hnewline
%                [<!ENTITY mathml "http://www.w3.org/1998/Math/MathML">]\Hnewline
                >\Hnewline }}
    \Configure{@HTML}
        {xmlns:dsi="http://www.dessci.com/mathml" \Hnewline}
>>>


\<configure mathplayer tex4ht\><<<
\:CheckOption{xht} \if:Option
\else \:CheckOption{xml} \if:Option
\else
   \Configure{$}
      {\Configure{@math}{display="inline"}\DviMath}
      {\EndDviMath\HCode{<span></span>}}{}
\fi\fi
>>>

Without the extra span mathplayer overlaps the table entries.



\<check for ie 5.5 and mathplayer\><<<
if(   navigator.appName=="Microsoft Internet Explorer"   \Hnewline
   && navigator.platform=="Win32"                        \Hnewline
   && parseFloat(navigator.appVersion.substr(            \Hnewline
                navigator.appVersion.indexOf("MSIE ")+5))>="5.5"  \Hnewline
){                                                       \Hnewline
  try {                                                  \Hnewline
    var oMP = new ActiveXObject("MathPlayer.Factory.1"); \Hnewline
  }                                                      \Hnewline
  catch(e) { alert("Can't find Design Science's MathPalyer" +  \Hnewline
        "(http://www.dessci.com/webmath/mathplayer)");}  \Hnewline
} else {                                                 \Hnewline
  alert("Requires MSIE version 5.5 or later");           \Hnewline
}                                                        \Hnewline
>>>

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Wrapping in Tables}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%

The attribute \verb+nowrap="nowrap"+ in table cells prevents
Mathplayer from displaying them its own way, and one gets minimal
cells, overlapped: it ought to be avoided altogether.

\<configure mathplayer tex4ht\><<<
\Configure{halignTD} {}{}
   {<}{\ifmathml \HCode{ columnalign="left"}\else
        \HCode{ align="left" }\fi}
   {-}{\ifmathml \HCode{ columnalign="center"}\else
        \HCode{ align="center" }\fi}
   {>}{\ifmathml \HCode{ columnalign="right"}\else
        \HCode{ align="right" }\fi}
   {^}{\ifmathml \HCode{ rowalign="top"}\else
        \HCode{ valign="top" }\fi}
   {=}{\ifmathml \HCode{ rowalign="baseline"}\else
        \HCode{ valign="baseline" }\fi}
   {||}{\ifmathml \HCode{ rowalign="center"}\else
        \HCode{ valign="middle" }\fi}
   {_}{\ifmathml \HCode{ rowalign="bottom"}\else
        \HCode{ valign="bottom" }\fi}
   {p}{\ifmathml \HCode{ columnalign="left"}\else
        \HCode{ align="left"}\fi}
   {}
>>>







%%%%%%%%%%%%%%%%%%%%%
\section{Cross References}
%%%%%%%%%%%%%%%%%%%%%


\<configure mathplayer tex4ht\><<<
\LinkCommand\mtxt:link{\a:mathml maction,%
   actiontype="link" dsi:href, id, 
   \a:mathml class="label"|<mtext ref decoration|>,,}
\LinkCommand\msp:link{\a:mathml maction,%
   actiontype="link" dsi:href, id,
   \a:mathml class="label"|<mstyle ref decoration|>,,}
\def\Link{\ifmathml
     \ifmtext |<end mtext|>\HCode{</\a:mathml mtext>}%
              \expandafter\expandafter\expandafter\mtxt:link
     \else    \expandafter\expandafter\expandafter\msp:link\fi
   \else \expandafter\M:Link\fi}
\def\EndLink{\ifmathml 
     \ifmtext    |<end mtext|>|<end mtext ref decoration|>%
       \Endmtxt:link \HCode{<\a:mathml mtext\Hnewline 
                   \a:mathml class="endlabel">}|<start mtext|>%
     \else  \HCode{|<end mstyle ref decoration|></\a:mathml
                               maction><!--endlabel-->}\fi
   \else \expandafter\M:EndLink\fi}
>>>

\<mtext ref decoration\><<<
><\a:mathml mtext  mathbackground="yellow"%
>>>

\<end mtext ref decoration\><<<
\HCode{</\a:mathml mtext>}%
>>>

\<mstyle ref decoration\><<<
><\a:mathml mstyle  mathbackground="yellow"%
>>>

\<end mstyle ref decoration\><<<
</\a:mathml mstyle>%
>>>


\begin{verbatim}
 JUST BACKGROUND (one could add colour, and it would be fine to include the
 labels, if any)
 <m:mstyle \a:mathml mathbackground="yellow"> <m:maction
  actiontype="link" dsi:href="#x1-2r1"  class="label"><m:mrow
 ><m:mn>1</m:mn><!--tex4ht:ref: equ1 --></m:mrow></m:maction></m:mstyle >

 HIGHLIGHT ON MOUSEOVER
 <m:maction
  actiontype="highlight" dsi:color="pink" ><m:maction
  actiontype="link" dsi:href="#x1-2r1"  class="label"><m:mtext
 background="yellow" >1<!--tex4ht:ref:
 equ1 --></m:mtext></m:maction></m:maction>

 TOOLTIP CLUE ON MOUSEOVER
 <m:mrow>
 <m:maction actiontype="tooltip" ><m:maction
  actiontype="link" dsi:href="#x1-2r1"  class="label"><m:mrow ><m:mn
 background="yellow" >1</m:mn></m:mrow></m:maction>
 <m:mtext>click to jump!</m:mtext>
 <!--tex4ht:ref: equ1 --></m:maction><!--endlabel--></m:mrow>

* <m:mtext m:mathbackground="yellow" > disables background colour in all
  the (math-)links - this one coming from a typo in mathplayer.4ht, inserting
  m: before mathbackground;

  m: also problematic on actiontype
\end{verbatim}

\<start mtext\><<<
\ht:special{t4ht@,&\#x00A0;}%
>>>
\<end mtext\><<<
\ht:special{t4ht@,}%
>>>



The area of the clickable links can be enlarged with a cpde similar to
the following one.

\begin{verbatim}
  \let\svLink=\Link
  \let\svEndLink=\EndLink
  \Odef\Link[#1]#2#3{%
     \svLink[#1]{#2}{#3}%
     \ifmathml\ifmtext\else \HCode{<m:mpadded width="4">}\fi\fi}
  \def\EndLink{%
     \ifmathml\ifmtext\else \HCode{</m:mpadded>}\fi\fi
     \svEndLink}
\end{verbatim}


%%%%%%%%%%%%%%%%%%
\section{Namespace Prefixes}
%%%%%%%%%%%%%%%%%%

\<configure mathplayer tex4ht\><<<
\:CheckOption{xht} \if:Option
\else \:CheckOption{xml} \if:Option
\else
\Configure{DviMath}
   {\a:DviMathML \mathmltrue
      \ifOption{mml-fonts}{}{|%\mml:htfsym|%\NoFonts}%
      \IgnoreRule \HCode{<!--l.
      \the\inputlineno-->}\HCode{<\a:mathml math\Hnewline}%
         |<disable a:mathml for math attr|>%
         \HCode{\csname a:math-xmlns\endcsname \Hnewline \a:@math>}%
      |<end disable a:mathml for math attr|>\a:math
      |<sv dvimath par|>\IgnorePar}
   {\Tg</\a:mathml math>\EndIgnoreRule
    \ifOption{mml-fonts}{}{|%\ext:htfsym|%\EndNoFonts}%
    \mathmlfalse \b:DviMathML |<recall dvimath par|>}
\fi\fi
>>>


\<recall dvimath par\><<<
\sv:ignore
>>>

\<sv dvimath par\><<<
\edef\sv:ignore{\if:nopar  
    \noexpand\IgnorePar\else \noexpand\ShowPar\fi}%
>>>

\<disable a:mathml for math attr\><<<
\let\sva:mathml=\a:mathml \let\a:mathml=\empty
>>>

\<end disable a:mathml for math attr\><<<
\let\a:mathml=\sva:mathml 
>>>




\endinput
