% compile 3 timws: latex tex4ht-svg   
%           or   xhlatex tex4ht-svg "html,3,sections+"
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% tex4ht-svg.tex                                         %
% Copyright (C) 2001--            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{svg,html4-svg}                   
   \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}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\<svg\><<<
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
% svg.4ht                               |version %
% Copyright (C) |CopyYear.2001.       Eitan M. Gurari         % 
%                                                        %
% This program can redistributed and/or modified unde r  %
% the terms of the LaTeX Project Public License          %
% Distributed from CTAN archives in directory            %
% macros/latex/base/lppl.txt; either version 1 of the    %
% License, or (at your option) any later version.        %
%                                                        %
% If you modify this program your changing its signature %
% with a directive of the following form will be         %
% appreciated.                                           %
%            \message{signature}                         %
%                                                        %
%                                gartside@maths.ox.ac.uk % 
%                              gurari@cis.ohio-state.edu % 
%                    http://www.maths.ox.ac.uk/~gartside %
%                  http://www.cis.ohio-state.edu/~gurari % 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\immediate\write-1{version |version}
>>>

\<configure svg tex4ht\><<<    
\Configure{VERSION}
  {\IgnorePar\HCode{<?xml version="1.0"?> \Hnewline}}
\Configure{DOCTYPE}{\HCode
  {<!DOCTYPE html PUBLIC
     "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//|<dtd lang|>"\Hnewline
     "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">\Hnewline
   <!--http://www.w3.org/TR/XHTMLplusMathMLplusSVG/-->\Hnewline
}}
>>>

\<configure svg tex4ht\><<<    
\Configure{@DOCTYPE}
  {<!ENTITY \% svg.dtd PUBLIC "-//W3C//DTD SVG 20010719//|<dtd lang|>"\Hnewline
     "http://www.w3.org/TR/2001/PR-SVG-20010719/DTD/svg10.dtd">\Hnewline
   \%svg.dtd; \Hnewline}
>>>


\<configure html4-svg tex4ht\><<<    
\Configure{@DOCTYPE}
  {<!ENTITY \% misc "ins || del || script || noscript || svg">\Hnewline}
>>>


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

\<configure svg tex4ht\><<<    
\Configure{@HTML}
  {\Hnewline xmlns:svg="http://www.w3.org/2000/svg"\Hnewline }
>>>



%%%%%%%%%%%%%%%%%%
\chapter{Code}
%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%
\section{DVI Images}
%%%%%%%%%%%%%%%%%%





\<configure svg tex4ht\><<<    
\Configure{Picture}{.svg}
\:CheckOption{svg-} \if:Option 
   |<object svg|>
\else 
   \Log:Note{to request external SVG files
          use the command line option `svg-'}
   |<internal svg|>
\fi
>>>

\<object svg\><<<
\Configure{IMG}
  {\special{t4ht=<object type="image/svg-xml"><img src="}}
  {\special{t4ht=" alt="}}
  {" }
  {\special{t4ht=" }}
  {\special{t4ht=/></object>}}
>>>


\<internal svg\><<<
\Configure{IMG}
  {\special{t4ht=<!-- src="}}
  {\special{t4ht=" alt="}}
  {" }
  {\special{t4ht=" }}
  {\special{t4ht=-->}%
   \openin15=\PictureFile \relax
   \ifeof15  \:warning{\PictureFile\space is not available}%
   \else     \closein15  \special{t4ht*<\PictureFile}\fi
  }
>>>


%%%%%%%%%%%%%%%%%%
\section{Support for th4:draw}
%%%%%%%%%%%%%%%%%%




\<configure svg th4\><<<    
\:CheckOption{draw} \if:Option \:CheckOption{th4} \if:Option 
   \Configure{Fig}
      {\Svg}
      {\EndSvg}
   \:CheckOption{svg-} \if:Option 
      |<embed svg draw|>
   \else
      |<internal svg draw|>
   \fi
\fi \fi
>>>



\<external svg draw\><<<    
\HAssign\:svgN = 0
\def\Svg{%
  \gHAdvance\:svgN by 1
  \HCode{<embed src="\jobname\:svgN.svg"\Hnewline
     name="svg\:svgN" type="image/svg-xml"
%  height="600" width="600"
     \Hnewline pluginspage="http://www.adobe.com/svg/viewer/install/">}%   
  |<open embeded file|>%
  |<open embeded svg|>%
  \bgroup\Canvas \x:SUBOff  \x:SUPOff 
     \let\Picture=\empty \everymath{}\everydisplay{}%
}
\def\EndSvg{\EndCanvas\egroup
   |<close embeded svg|>%
   |<close embeded file|>}
>>>





\<internal svg draw\><<<    
\def\Svg{\HCode{<svg:svg>\Hnewline
                <svg:g style="stroke:black;  stroke-width:1;
                      stroke-opacity:1;">\Hnewline}%
  \bgroup\Canvas \x:SUBOff  \x:SUPOff 
     \let\Picture=\empty \everymath{}\everydisplay{}%
}
\def\EndSvg{\EndCanvas\egroup
   \HCode{</svg:g></svg:svg>}}
>>>




\<embed svg draw\><<<    
\let\:svg=\empty
\NewConfigure{Canvas}[4]{\ht:special{t4ht"%
   *%
   *d\Hnewline<!--width="\%.1f#4" %
   *D height="\%.1f#4" %
   *y above-baseline="\%.1f#4" -->%
   **\Hnewline<\:svg text x="\%.1f" y="\%.1f" >%
   *</\:svg text>%
   *\Hnewline<\:svg rect x="\%.1f#4" y="\%.1f#4"  
                   width="\%.1f#4"  height="\%.1f#4" />%
   *#1*#2*#1*#2*#3}}
\Configure{Canvas}{0.0000152587890625}{0.0}{0.5}{}
>>>


65536 scaled units = 1 pt. 1 / 65536 = 0.0000152587890625.

\<\><<<    
\NewConfigure{Canvas}[4]{\ht:special{t4ht"%
   *%
   *d\Hnewline<!--width="\%.0f#4;" %
   *D height="\%.0f#4;" -->\Hnewline %
%   **<svg:text x="\%.0f" y="\%.0f" >%
%   *</svg:text>\Hnewline %
   **<svg:foreignObject x="\%.0f" y="\%.0f" >%
   *</svg:foreignObject>\Hnewline %
%   *\Hnewline<svg:rect x="\%.0f#4" y="\%.0f#4"  
%                   width="\%.0f#4"  height="\%.0f#4"
%                   fill="black" stroke-width="0" />%
   *\Hnewline<svg:polyline points="\%.0f#4 \%.0f#4 \%.0f#4 \%.0f#4" 
                           style="stroke-width:\%.0f#4" />%
   *#1*#2*#1*#2*#3*2}}
>>>





\<open embeded file\><<<
\ht:special{t4ht>\jobname\:svgN.svg}%
\HCode{<?xml version="1.0" encoding="iso-8859-1"?>\Hnewline
<!DOCTYPE svg  PUBLIC "-//W3C//DTD SVG 1.0//|<dtd lang|>"\Hnewline
              "http://www.w3.org/TR/2001/PR-SVG-20010719/DTD/svg10.dtd">
\Hnewline}
>>>

\<close embeded file\><<<
\ht:special{t4ht<\jobname\:svgN.svg}%
>>>

\<open embeded svg\><<<
\HCode{<\:svg svg>\Hnewline
       <\:svg g style="stroke-width:0; fill:black;">\Hnewline}%
>>>

\<close embeded svg\><<<
\HCode{</\:svg g></\:svg svg>}%
>>>



%%%%%%%%%%%%%%%%%%
\chapter{Notes}
%%%%%%%%%%%%%%%%%%


Requires two compilations (e.g., with \verb!mzlatex try "html,svg"!)
for importing the SVG code.




\endinput

