% $Id: tex4ht-sty.tex 981 2021-09-14 20:14:03Z michal_h21 $
% tex tex4ht-sty   or   ht tex tex4ht-sty
%
% Copyright 2009-2020 TeX Users Group
% Copyright 1996-2009 Eitan M. Gurari
% Released under LPPL 1.3c+.
% See tex4ht-cpright.tex for license text.

\input common
\input DraTex.sty
\input AlDraTex.sty

\DrawOff

\writesixteen{----------Verify length of lines!!!!------------}
\writesixteen{----------Verify length of lines!!!!------------}
\writesixteen{----------Verify length of lines!!!!------------}
\writesixteen{----------Verify length of lines!!!!------------}


\newif\ifalprotex \alprotexfalse

\hbadness=10000     \vbadness=10000  \hfuzz=99in \vfuzz=99in


\def\Link#1\EndLink{}

\openin15=./tex4ht.sty
          \ifeof15

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% replacement for TeX4ht %%%%%%%%%%%%%%%%%%
\writesixteen{........dvi mode}
\csname newif\endcsname\ifHtml \Htmlfalse
\def\-#1{\ifx#1-\expandafter\TEMP\else\expandafter#1\fi}
\expandafter\let\csname bye\endcsname=\end
\def\TEMP#1/#2/#3/{}
\def\HTable#1{}
\def\'#1'{}
\def\`#1'{}
\let\TableOfContents=\relax
\def\Part#1{}
\def\Chapter#1{}
\def\Appendix#1{}
\def\Section#1{}
\def\SubSection#1{}
\def\Margin#1{}
\def\HCode#1{}
\def\LinkPort#1\EndLink{}
\def\EndLink{}
\expandafter\let\csname bye\endcsname=\end
\def\TagSec#1{}
\def\RefSec#1{}
\def\List#1{}   \let\ShortList=\List
\def\EndList{}
\def\item{}
\expandafter\let\expandafter\ifOption\csname iffalse\endcsname
\let\IgnorePar\empty
\let\EndP\empty
\catcode`\:=11
\def\Verb{\bgroup \catcode`\^=10 \catcode`\\=10  \catcode`\%=10
   \catcode`\{=10    \catcode`\}=10    \catcode`\#=10     \catcode`\#=10
   \leavevmode \:ctgs}
\def\:ctgs#1{\def\:eat##1#1{\egroup}\:eat }
\csname newcount\endcsname\tmp:cnt
          \def\no:catcodes#1#2#3{%
   \tmp:cnt=#1
   \def\no::catcodes{%
      \catcode\tmp:cnt=#3
      \ifnum\tmp:cnt<#2
          \advance\tmp:cnt by 1  \expandafter\no::catcodes
      \fi }%
   \no::catcodes }
           \let\:oldlq=\`
\let\:oldrq=\'
\def\'{\leavevmode \:cats  \::cats}
\def\::cats#1{\if  #1"\expandafter\:oldrq
              \else  \def\:eat##1#1{\tt ##1\egroup}\expandafter\:eat\fi}
\def\`{\leavevmode \:cats  \:::cats}
\def\:::cats#1{\if #1"\expandafter\:oldlq
               \else \def\:eat##1#1{`{\tt ##1}'\egroup}\expandafter\:eat\fi}
\def\:cats{\bgroup  \no:catcodes0{255}{12}\catcode`\ = 10
           \catcode`\^^M = 10 \catcode`\^^I = 10
}

\def\HPage{}  \def\EndHPage{}
\def\Verbatim{\bgroup\catcode`\\=12 \catcode`\#=12
   \catcode`\^=12 \catcode`\_=12
   \catcode`\{=12 \catcode`\}=12 \catcode`\%=12 \:vrb}
\long\def\:vrb#1EndVerbatim{\egroup}


   \closein15 
       \def\next{%\input DraTex.sty
\writesixteen{.................requesting non-html mode}%
                 \input ProTex.sty
             \AlProTex{sty,<<<>>>,|,title,list,[],ClearCode}}
   \catcode`\:=12
\else 
   \closein15 
      \def\next{%\input DraTex.sty
\writesixteen{.................requesting html mode}%
                \input tex4ht.sty
                \Preamble{xhtml,th4,family,sections+}
                \Configure{@HEAD}{\HCode{<link rev="made"\Hnewline 
                      href="mailto:gurari@cse.ohio-state.edu" />}}
%%
                \input ProTex.sty
             \AlProTex{sty,<<<>>>,|,title,list,[],ClearCode}
                \EndPreamble}

\fi

\next


\def\`{\Verb}
\def\'{\Verb}


\ifHtml
   \TocAt{Chapter,Section,SubSection,LikeSection,/Appendix,/Part}
   \TocAt{LikeChapter,Section,SubSection,LikeSection,/Appendix,/Part}
   \TocAt{Appendix,Section,SubSection,LikeSection,/Appendix,/Part}   
   \CutAt{Chapter,LikeChapter,Appendix,Part}
   \CutAt{LikeChapter,Chapter,Appendix,Part}
   \CutAt{Appendix,Chapter,LikeChapter,Part}
\else
   \def\ParentOf#1{}
   \csname TableOfContents\endcsname
\fi


%%%%%%%%%%%%%%%%%%%%%%%%%
\def\by{by}\def\={=}
\let\pReModifyOutputCode=\ModifyOutputCode
\def\ModifyOutputCode{%
   \def\by{}\def\={}%
   \pReModifyOutputCode}

\csname NoOutputCode\endcsname

\let\coDE=\<
\def\<{\vfil\par\coDE}

\tracingstats=1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\IgnorePar \EndP
\HCode{<h1>A Literate View of tex4ht.sty</h1>}






\csname TableOfContents\endcsname[ParentOf,Part,Chapter,%
                         Appendix,LikeChapter,Section,LikeSection]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Chapter{Outline of the Code}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



\Section{TeX4ht}

\<tex4ht\><<<
\ifnum\the\catcode`\%=14\else\expandafter\edef\csname
  \string:RestoreCatcodes\endcsname{\catcode`\%|=\the
  \catcode`\%}\catcode`\%|=14\fi
|<copyright|>
\ifx  \Preamble\UnDef  \else
   % fix for LaTeX hook system, \AtBeginDocument is not available at this moment
   \let\origatbegindocument\AtBeginDocument
   \def\AtBeginDocument#1{\AddToHook{begindocument/end}{#1}}
   \csname expand:after\endcsname{\csname 
       BeforeTeXIVht\endcsname\let\BeforeTeXIVht|=\UnDef}
   \let\AtBeginDocument\origatbegindocument

\fi
\def\writesixteen#1{\immediate\write99999{#1}}
|<save cat codes|>
|<ifs for TeX4ht|>
|<check if latex|>
\ifx  \Preamble\UnDef 
    \ifx \PLATFORM\:UnDef \else 
        \message{ [\PLATFORM] }\let\PLATFORM|=\:UnDef\fi
    |<early utilities|>
    |<first pass|>                   
    |<first pass for latex|>    
    \expandafter\ifx \csname tex4ht\endcsname\relax
       \let\:temp|=\empty
    \else
       |<temp := auto load Preamble|>
    \fi    
    \let\:tempc|=\:temp
    |<def early latex ifOption|>
    \pend:def\:tempc{\:RestoreCatcodes }    
    \append:def\:tempc{\endinput}
    \let\:temp|=\:tempc     
    \expandafter\:temp
\fi
|<second pass|>  
\ifx \Hinput\:UnDef \else                      
  \Hinput{tex4ht2}
  |<load protex|>
\fi
|<TeXivht = user file requests|>   
|<html-end of style file|>
\rmv:ifs  \let\rmv:ifs|=\:UnDef  
\:RestoreCatcodes    \TeXivht
\endinput  
 >>>










\<load sub tex4ht styles\><<<
\ifHtml      \def\:tempa{\:Hinclude}
\else
    \:CheckOption{th4}\if:Option  \def\:tempa{\input th4.4ht}
    \else  \let\:tempa|=\empty \fi  
\fi
\:CheckOption{core} \if:Option  \let\:tempa|=\empty \fi  
\:CheckOption{base} \if:Option  \let\:tempa|=\empty \fi  
\:tempa
>>>









We have in amsmath


\<utilities\><<<
\def\HLet#1{%
   \expandafter\ifx
      \csname o:\expandafter\:gobble\string#1:\endcsname\relax
      |<save old def of macro|>%
   \fi
   |<selector between old and new def|>%
   \expandafter\let
   \csname n:\expandafter\:gobble\string#1:\endcsname}
>>>


The original definition of \`'\.....' is stored in  \`'\o:...:', and
the new one in \`'\n:....:'.
 The selector is outside the \''\ifx' so that the \''\HLet' will
 work also on macros restored with \''\HRestore'.


\<utilities\><<<
\def\HRestore#1{\relax
   \expandafter\ifx
      \csname o:\expandafter\:gobble\string#1:\endcsname\relax
        \:warning{\string\HRestore\noexpand#1?}%
   \else 
      \expand:after{\let#1|=}\csname o:\expandafter
          \:gobble\string#1:\endcsname
   \fi}%
>>>

Don't erase the \`'o:...:', just in case a saving with let
is done before restoring. 


\<save old def of macro\><<<
\expandafter\let
   \csname o:\expandafter\:gobble\string#1:\endcsname|=#1%
>>>

\<selector between old and new def\><<<
\edef#1{\noexpand\ifx \noexpand\EndPicture\noexpand\:UnDef
   \noexpand\expandafter \expandafter\noexpand
      \csname n:\expandafter\:gobble\string#1:\endcsname
   \noexpand\else \noexpand\expandafter \expandafter\noexpand
      \csname o:\expandafter\:gobble\string#1:\endcsname
 \noexpand\fi}%
>>>

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Support for ProTex}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\<first pass\><<<
\NewConfigure{ProTex}[1]{\def\a:ProTex{#1}}
>>>


\<load protex\><<<
\ifx \a:ProTex\:UnDef 
\else \input ProTex.4ht \fi
>>>

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Support for httex}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\<temp := auto load Preamble\><<<
|<util for extracting options|>
|<options from /tex4ht|>
\expandafter\expandafter\expandafter
   \:temp\csname tex4ht\endcsname |<par del|>%
\ifx \:temp\relax
   |<temp := load tex /Preample|>
   \if:latex \let\:temp|=\empty \fi
\else
   \if:latex
      \let\config:file|=\:temp  \let\:temp|=\empty 
   \else
      \edef\:temp{\noexpand\input \:temp\space}
\fi \fi
>>>


\<extract tex4ht options\><<<
\ifx \:temp\relax
   \let\:tempd|=\:temp
   \let\:tempc|=\empty \config:opt #1,#2,|<par del|>%
\else     \:temp
   \let\:tempd|=\:temp
   \let\:tempc|=\empty \config:opt #2,|<par del|>%
\fi
\let\config:opt|=\:tempc
\let\:temp|=\:tempd
>>>

\<util for extracting options\><<<
\def\:tempc#1#2.#3|<par del|>{\edef\:tempa{#3}\edef\:temp{%
   #1\ifx \:tempa\empty  .cfg\fi}}
\def\config:opt#1,#2|<par del|>{\def\:temp{#1}\ifx \:temp\empty
   \else \ifx \:tempc\empty 
         \def\:tempc{#1}%
      \else
         \append:def\:tempc{,#1}
   \fi\fi
   \def\:temp{#2}\ifx \:temp\empty
   \else \def\:temp{\config:opt #2|<par del|>}\fi       
   \:temp}
>>>



\<temp := load tex /Preample\><<<
\ifx \config:opt\:UnDef
   \edef\config:opt{\ifx \config:file\empty html\fi}\fi
\def\:temp{\expandafter\expandafter\expandafter
   \Preamble\expandafter{\config:opt}\EndPreamble}
>>>


\Section{First Pass}

\<first pass\><<<
\ifx \Log:Needs\:UnDef \else 
   \:warning{Again `\noexpand\input tex4ht.sty'?}\fi
|<check that TeX4ht is not loaded after protex|>  |%still necessary?|%
|<define for /Preamble|>
|<define /Preamble|>
>>>



\<check if latex\><<<
\expandafter\ifx \csname @latex@error\endcsname\relax
    \:latexfalse  \tracingstats|=1
\else  
   \if:latex\else |<usepackage for latex|>\fi
   \:latextrue 
   \ifx \:providesfile \:UnDef
      \let\:providesfile\@providesfile
      \def\@providesfile#1{%
         \expandafter\ifx\csname @filelist\endcsname\relax
               \let\@providesfile\:providesfile
         \else \xdef\@filelist{\@filelist,#1}%
         \fi
         \:providesfile{#1}%
      }
   \fi
\fi
>>>



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\SubSection{Start Preamble}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\<define /Preamble\><<<
\def\:Preamble{\ifx \:next[%
  \def\Preamble[##1]##2{\egroup 
    |</def/Preamble(@@2)|>\input ##1   
    }
  \else
  \def\Preamble##1{\egroup |</def/Preamble(@@1)|>%
                  \input |<TeX4ht name|>.sty }
  \fi        \let\:Preamble|=\:UnDef     \Preamble  }
\def\Preamble{\bgroup  \catcode`\@|=12   \catcode`\_|=8  \catcode`\^|=7
  \futurelet\:next\:Preamble}
>>>


With the following definitions we can replace
\`'\input tex4ht.sty   \Htmltrue .... \Htmlfalse \Preamble{html,...}'
with \`'\input tex4ht.sty   \Htmltrue ....  \Preamble{...}'  
for defining html-enabled code between the \''\input' and the
\''\Preamble'.  That is, for using code that employs the
\''\ifHtml' command.



\</def/Preamble(@@1)\><<<
|<def :CheckOption|>%
\ifHtml  \Htmlfalse
     \def\Preamble{html,##1}\else \def\Preamble{##1}\fi
|<config options for /usepackage and httex|>%
|<extract Hinclude|>%
>>>

\</def/Preamble(@@2)\><<<
|<def :CheckOption|>%
\ifHtml  \Htmlfalse
     \def\Preamble{html,##2}\else \def\Preamble{##2}\fi
|<config options for /usepackage and httex|>%
|<extract Hinclude|>%
>>>

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\SubSection{End Preamble}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\<define /Preamble\><<<
\def\EndPreamble{\b:Preamble \global\let\missing:endpream\empty
  \csname |<live|>\file:id\endcsname \B:DY}
\def\B:DY{|<html paragraph breaks at entry to file|>%
  \HtmlEnv \IgnorePar \IgnoreIndent {\ht:everypar{}\leavevmode}\a:BODY
  \csname a:@BODY\endcsname}
\def\missing:endpream{\:warning{Missing \string\EndPreamble}}
>>>


\<close html doc\><<<
\missing:endpream
>>>

\<define /Preamble\><<<
\NewConfigure{@HTML}[1]{\concat:config\a:@HTML{#1}}
\let\a:@HTML|=\empty 
>>>

\<needs preamble\><<<
\:tempb
>>>


\<html config util\><<<
\NewConfigure{Preamble}{2}
>>>



\<remove garbage\><<<
\ifHtml \else \let\EndPreamble|=\empty \fi
>>>

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\SubSection{Selecting Preamble}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



\<def :CheckOption\><<<
\def\:CheckOption####1{\def\:temp{####1}%
   \:Optionfalse
   \expandafter\:ScanOptions\Preamble,,//}
\def\:ScanOptions####1,####2//{\def\:next{####1}%
   \ifx        \:next\empty           
   \else \ifx  \:temp\:next   \:Optiontrue   \let\:next|=\relax
   \else \def\:next{\:ScanOptions####2//}%
   \fi  \fi  \:next }
>>>





\<Hinput Configs\><<<
\def\:temp{\def\ifOption##1}
\expandafter\expandafter\expandafter\:temp
   \expandafter{\Preamble,,//\if:Option
   |<ifOption true|>\else |<ifOption false|>\fi  \tmp:toks=}
\pend:defI\ifOption{\def\:temp{##1}\:Optionfalse\:ScanOptions}
>>>


\<ifOption false\><<<
\def\:temp{%
   \def\:temp{\the\tmp:toks}%
   \afterassignment\:temp \tmp:toks=}%
\afterassignment\:temp
>>>


\<ifOption true\><<<
\def\:temp{\the\tmp:toks 
   \def\:temp{\tmp:toks={}}%
   \afterassignment\:temp \tmp:toks=}%
\afterassignment\:temp
>>>



The \''\ifOption' is implemented through a token list variable to
allow for nesting in macros and if statements. The older definition
hid the \''\if' under \''\ifOption' and  exposed just the
\''\else' and \''\fi'.




\<new ifs\><<<
\:tempa{if:Option}
>>>



The following code defines \`'\ifOption' just for flags defined in the
comamnd line (that is, flags known the first time tex4ht.sty is
loaded).  It doesn't yet see those options introduced by \`'\Preamble'
and the *.4ht files.


\<def early latex ifOption\><<<
\ifx \config:opt\:UnDef \else
   \ifx\tmp:toks\:UnDeF    \csname newtoks\endcsname\tmp:toks\fi
   \def\:temp{\def\ifOption##1}
   \expandafter\expandafter\expandafter\:temp
        \expandafter{\config:opt,,//\if:Option
   |<ifOption true|>\else |<ifOption false|>\fi  \tmp:toks=}
   \pend:defI\ifOption{\def\:temp{##1}\:Optionfalse\:ScanOptions}
\fi
>>>


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{LaTeX at First Pass}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\<first pass for latex\><<<
\if:latex 
   |<try taking care of hyperref.sty|>
   |<early latex subs/sups|> 
\fi
|<block package loading|>
|<xetex active characters|>
|<hook at usepackage|>
>>>

The following is a temporary patch, waiting fo a fix in hyperref.sty.


\<try taking care of hyperref.sty\><<<
\expandafter\def\csname opt@hyperref.sty\endcsname{tex4ht}
>>>

\<block package loading\><<<
\def\:dontusepackage#1{%
  \typeout{tex4ht warning: package #1 was prevented from loading}
  \@namedef{ver@#1.sty}{9999/12/31}%
  \@namedef{opt@#1.sty}{\:currentoptions}
}
>>>

Input definitions for Unicode blocks in XeLaTeX. It loads full Latin by
default, others must be activated using \`'xeuniuseblock{blockname}'

\<xetex active characters\><<<
\ifx\XeTeXversion\@undefined\else
\ifx\xeuniuseblock\@undefined
\input tuenc-xetex-input.4ht
\fi\fi
>>>

Add support for package commands redefining

\<hook at usepackage\><<<
\def\:AtEndOfPackage{\expandafter\g@addto@macro\csname pkg:end:hook:\@currname.sty\endcsname}
\def\init:package:hooks#1{\expandafter\def\csname pkg:end:hook:#1\endcsname{}}
\def\package:hooks#1{\csname pkg:end:hook:#1\endcsname}
>>>

\<hook at usepackage\><<<
\let\:onefilewithoptions\@onefilewithoptions
\def\@onefilewithoptions#1[#2][#3]#4{%
\init:package:hooks{#1.#4}%
   \let\:temp\@reset@ptions
   \def\@reset@ptions{%
      \let\@reset@ptions\:temp
      |<cats for usepackage|>\a:usepackage%
      \a:usepackage:lthooks{#1}{#4}
      |<recall usepackage cats|>}%
      \def\:currentoptions{#2}
\:onefilewithoptions#1[#2][#3]{#4}\package:hooks{#1.#4}}
\def\a:usepackage{\input usepackage.4ht }
>>>
\<cats for usepackage\><<<
\edef\TivhTcats{%
   \catcode`:=\the\catcode`:%
   \catcode`@=\the\catcode`@}%
\catcode`\:=11 \catcode`\@=11
>>>

\<recall usepackage cats\><<<
\TivhTcats
>>>

In October 2020, LaTeX kernel added new hook support. It can be used
for lot of stuff, including execution of code when a package is loaded.
It is more efficient and clean than the current TeX4ht system of package
handling. We can use it to execute code before and after package loading.

Files that contain code that should be executed before the package is loaded
can be requested using PackageHooks configuration. It needs to be included
in the "add to usepackage" placeholder that is available in tex4ht-4ht.tex.

Example:

\Verbatim
\<add to usepackage\><<<
\Configure{PackageHooks}{packagename.sty}{packagename-hooks.4ht}
>>>

\<packagename-hooks.4ht\><<<
% Some stuff executed before the package is loaded
\:AtEndOfPackage{
  % stuff executed after package is loaded
  % macro redefinitions and so on
}
>>> \AddFile{9}{packagename-hooks}

\EndVerbatim

\<hook at usepackage\><<<
\NewConfigure{PackageHooks}[2]{\expandafter\def\csname package:hooks:#1\endcsname{\input #2}}
\def\a:usepackage:lthooks#1#2{%
  \expandafter\ifcsname package:hooks:#1.#2\endcsname
  \csname package:hooks:#1.#2\endcsname
  \fi
}
>>>


%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Second Pass}
%%%%%%%%%%%%%%%%%%%%%%%%%


The definitions of the configurations should be ready before
\''\Hinput' is called for loading their values.  The cross references
also need to be resolved at that point (for the TITLE+, and possibly
other usages).

\<second pass\><<<
|<html option|>                  |%should be first|%
|<html+nohtml common to TeX4ht and protex|>
|<utilities|>
|<cross references|>
\ifHtml
   |<Hinput Configs|>
   \Hinput{Preamble}  \ht:special{t4ht.\:html} 
   |<scripting commands|>
   |<html Configure's|>   
   \Hinput{tex4ht}  
   |<hook on end|>
\fi
|<divisions|>
|<files|>
|<cut points|>
|<imports|>
|<lists|>
|<blocs for tocs|>
\ifHtml
   |<halign-based tables|>
\fi
|<streams|>
|<gif|> 
|<fonts|>
|<math|>
|<core tex|>
|<at doc start|>  |%after Preamble|%
\ifHtml
   |<dvi-based hooks|>
   |<more html tex|> 
\fi
|<local env|>                    |% after accents, {\vrb:tt\`} in particular|%
\ifx\beginL\@undefined \else
   \ifHtml 
      |<e tex|>
      \Hinput{etex4ht}  
\fi\fi
|<load sub tex4ht styles|>
|<debug|>
|<remove garbage|>
\ifHtml |<start html doc|> \fi   |%should be last|%
>>>



\Section{Copyright Note}

\input tex4ht-cpright.tex

\<copyright\><<<
% tex4ht.sty (|version), generated from |jobname.tex
% Copyright 2009-|the|year|empty TeX Users Group
% Copyright |CopyYear.1996. Eitan M. Gurari
|<TeX4ht copywrite|>
>>>



\Section{Category Codes}


\<save cat codes\><<<
\expandafter\edef\csname :RestoreCatcodes\endcsname{%
   \expandafter\ifx \csname :RestoreCatcodes\endcsname\relax\else
      \csname :RestoreCatcodes\endcsname \fi
   \ifnum \the\catcode`\ =10 \else
      \catcode`\noexpand\ =\the\catcode`\ \fi
   \ifnum \the\catcode`<=12 \else
      \catcode`\noexpand <|=\the\catcode`<\fi
   \ifnum \the\catcode`>=12 \else
      \catcode`\noexpand >|=\the\catcode`>\fi
   \ifnum \the\catcode`\?=12 \else
      \catcode`\noexpand \?|=\the\catcode`\?\fi
   \ifnum \the\catcode`+=12 \else
      \catcode`\noexpand +|=\the\catcode`+\fi
   \ifnum \the\catcode`*=12 \else
      \catcode`\noexpand *|=\the\catcode`*\fi
   \ifnum \the\catcode`;=12 \else
      \catcode`\noexpand ;|=\the\catcode`;\fi
   \ifnum \the\catcode`~=13 \else
      \catcode`\noexpand ~|=\the\catcode`~\fi
   \ifnum \the\catcode`$=3 \else
      \catcode`\noexpand $|=\the\catcode`$\fi
   \ifnum \the\catcode`&=4 \else
      \catcode`\noexpand &|=\the\catcode`&\fi
   \ifnum \the\catcode`\#=6 \else
      \catcode`\noexpand \#|=\the\catcode`\#\fi
   \catcode`\noexpand :|=\the\catcode`:%
   \catcode`\noexpand "|=\the\catcode`"%
   \catcode`\noexpand @|=\the\catcode`@%
   \catcode`\noexpand _|=\the\catcode`_%
   \catcode`\noexpand ^|=\the\catcode`^%
   \catcode`\noexpand |||=\the\catcode`||%
   \csname no:restore\endcsname 
   |<sp and sb for catcode 13|>%
   \let\expandafter\noexpand\csname :RestoreCatcodes\endcsname|=
                                   \noexpand\UnDefcS}
\catcode`~|=13  \catcode`$|=3   \catcode`&|=4  \catcode`\#|=6
\catcode`\:|=11 \catcode`\@|=11 \catcode`;|=12 \catcode`\ |=10
\catcode`\<|=12 \catcode`\>|=12 \catcode`+|=12 \catcode`*|=12
\catcode`\?|=12
|<record external sub-sup|>
\catcode`\^|=7 \catcode`\||=12  \catcode`"|=12
>>>






\Section{Ifs}


\<ifs for TeX4ht\><<<
    \def\:temp{\csname newif\endcsname}
    \def\:tempa#1{%
       \expandafter\ifx \csname #1\endcsname\relax
          \expandafter\:temp   \csname #1\endcsname
       \fi}
|<new ifs|>
    \def\:tempa#1{%
       \expandafter\ifx \csname #1\endcsname\relax
          \expandafter\:temp   \csname #1\endcsname
          \expandafter\expandafter\expandafter\expandafter\expandafter
             \def\expandafter\expandafter\expandafter
             \rmv:ifs\expandafter{\rmv:ifs
             \expandafter\let \csname #1\endcsname |= \:UnDef}
       \fi}
    \let\rmv:ifs|=\empty
|<temp tex ifs|>
>>>


The temporary ifs are needed only for loading time to allow
TeX to scan material that will not be loaded.



\<new ifs\><<<
\:tempa{if:latex}
>>>

\Section{User File Requests}

\<TeXivht = user file requests\><<<
\def\:usersty#1,#2|<par del|>{\def\:temp{#1}%
   \ifx \:temp\empty \else
      \expandafter\ifx \csname #1\endcsname\relax
         \expandafter\let \csname #1\endcsname=\empty
         \input #1
      \fi
      \def\:temp{#2}\expandafter\:temp
   \fi}
\edef\TeXivht{\expandafter\ifx \csname TeXivht\endcsname\relax
  \else \noexpand\:usersty\TeXivht,|<par del|>\fi
  \let\noexpand\TeXivht|=\noexpand\:UnDef
  \let\noexpand\:usersty|=\noexpand\:UnDef  }
>>>




\Section{Usepackage Interface for LaTeX}


\<usepackage for latex\><<<
\ifx \@currname\empty    
   |<requires /Preamble.../EndPreamble|>
\else
   |<TeX4ht loaded with /usepackage|>
\fi
>>>

Three ways for loading TeX4ht in LaTeX

\List{a}
\item With \`'\usepackage{tex4ht}'.

\Verbatim
\usepackage{tex4ht}
\begin{document}
\EndVerbatim

It assumes a configuration file named \`latex4ht.cfg'.  If none
is offered, the following code is available.


\Verbatim
\Preamble{html}
   \begin{document}
\EndPreamble
\EndVerbatim


\item With \`'\usepackage[file-name]{tex4ht}'.  As before, but with a
  configuration file \`'file-name', instead of in \`'latex4ht.cfg'.
  The extension \`'.cfg' is assumed, if none is provided.

\item  With inline (instead of off-line) configurartion file, e.g.,
like \`'\input tex4ht.sty \Preamble{html}
   \begin{document}
\EndPreamble'

\EndList

The indirection below on \''\enddocument' is needed for AmsTeX; there
the command is defined as outer.



\<TeX4ht loaded with /usepackage\><<<
\ProvidesPackage{tex4ht}     
\let\config:file|=\empty
|<options from /usepackage|>
\DeclareOption*{\load:cfg}
\ProcessOptions
\let\o:document|=\document
\def\document{%
   |<check irregularities|>%
   \ifdefined\AddToHook%
      \def\document{\endgroup\o:document}%
      % use new LaTeX hook system to execute \Configure{AtBeginDocument}
      \AddToHook{begindocument/before}[tex4ht]{\csname a:AtBeginDocument\endcsname}
      \AddToHook{begindocument/end}[tex4ht]{\csname b:AtBeginDocument\endcsname}
   \else%
      %\expandafter\let\csname enddocument\endcsname|=\empty
      %\end{document}%
      %\let\document|=\o:document
      |<protect AtBeginDocument|>%
      \let\document\o:document%
   \fi%
   \let\:latex@error|=\@latex@error
   \def\@latex@error##1{\:latex@error{##1 in `\config:file'}}%
   |<load latex /Preample|>%
   \let\@latex@error|=\:latex@error
}
>>>

\<check irregularities\><<<
\let\ht:empty|=\:UnDef
\def\:temp{}\ifx \:temp\empty \else
  \gdef\:temp{}\ifx \:temp\empty \else
     \:warning{Redefined \string\empty?}
     \global\let\ht:empty|=\empty \gdef\empty{}%
\fi\fi
>>>




\<load latex /Preample\><<<
|</document recall sub/sup|>%
\ifx \config:file\empty 
   \def\:temp{|<default latex cfg file|>}%
\else 
   \def\:temp{|<user config file|>}%
\fi \:temp 
>>>






\<early Configure\><<<
|<concat config|>
\NewConfigure{AtBeginDocument}[2]{%
   \def\:temp{#1#2}\ifx \:temp\empty
     \concat:config\a:AtBeginDocument{}
     \concat:config\b:AtBeginDocument{}%
   \else
     \concat:config\a:AtBeginDocument{#1\relax}%
     \concat:config\b:AtBeginDocument{#2\relax}%
   \fi
   \global\let\a:AtBeginDocument=\a:AtBeginDocument
   \global\let\b:AtBeginDocument=\b:AtBeginDocument
}
\Configure{AtBeginDocument}{}{}
>>>

\<protect AtBeginDocument\><<<
\let\:begindocumenthook|=\@begindocumenthook
\def\@begindocumenthook{\csname a:AtBeginDocument\endcsname
\:begindocumenthook \csname b:AtBeginDocument\endcsname }%
>>>




In optional parameters, the first one is assumed to be a
file name.  A fake file name should be inserted, when we
want none.

\<default latex cfg file\><<<
\ifx \config:opt\:UnDef 
   \edef\config:opt{\ifx \config:file\empty html\fi}\fi
\expandafter\Preamble\expandafter{\config:opt
   }\csname begin\endcsname{document}\EndPreamble
>>>

\''\begin' is defined as outer in texi, hence thr \''\csname'.

\<default tex cfg file\><<<
\ifx \config:opt\:UnDef 
   \edef\config:opt{\ifx \config:file\empty html\fi}\fi
\expandafter\Preamble\expandafter{\config:opt
   }\EndPreamble
>>>


\<user config file\><<<      
\input \config:file\relax
>>>

\<config options for /usepackage and httex\><<<
\ifx \config:opt\:UnDef 
   \let\:temp|=\Preamble
\else
   \expandafter\expandafter\expandafter\def
   \expandafter\expandafter\expandafter\:temp
   \expandafter\expandafter\expandafter{%
   \expandafter\config:opt\expandafter,\Preamble}%
\fi
\let\Preamble|=\empty 
\expandafter\set:Preamble\:temp,|<par del|>%
>>>


The following removes duplications in \''\Preamble'. Important, in
particular, when 4ht configuration files are included in the
list of options.

\<define for /Preamble\><<<
\def\set:Preamble#1,#2|<par del|>{%
   \def\:temp{#1}\ifx \:temp\empty \else 
      \:CheckOption{#1}\if:Option \else 
          \ifx \Preamble\empty \def\Preamble{#1}%
          \else                \append:def\Preamble{,#1}%
   \fi \fi \fi
   \def\:temp{#2}\ifx \:temp\empty \let\set:Preamble|=\:UnDef 
   \else  \expand:after{\set:Preamble#2|<par del|>}\fi
}
>>>


\''\ProcessOptions' calls \''\cfg:fl' repeatedly for each option.

\List{}
\item{Empty, or Cfg File}

\<options from /usepackage\><<<
\def\load:cfg{|<2nd option|>%
   \def\:temp{\expandafter\cfg:fl\CurrentOption.|<par del|>}%
   \def\:tempa{html}\ifx \:tempa\CurrentOption \let\:temp|=\load:cfg \fi
   \def\:tempa{xhtml}\ifx \:tempa\CurrentOption \let\:temp|=\load:cfg \fi
   \def\:tempa{htm}\ifx \:tempa\CurrentOption \let\:temp|=\load:cfg \fi
   \def\:tempa{htm3}\ifx \:tempa\CurrentOption \let\:temp|=\load:cfg \fi
   \def\:tempa{htm4}\ifx \:tempa\CurrentOption \let\:temp|=\load:cfg \fi
   \def\:tempa{htm5}\ifx \:tempa\CurrentOption \let\:temp|=\load:cfg \fi
   \:temp
}
\def\cfg:fl#1.#2|<par del|>{\edef\:tempa{#2}\edef\config:file{%
   \CurrentOption \ifx \:tempa\empty  .cfg\fi}}
>>>

\<options from /tex4ht\><<<
\def\:temp#1,#2|<par del|>{%
   \def\:temp{\:tempc{#1}#1.|<par del|>}%
   \def\:tempb{#1}\ifx   \:tempb\empty  \let\:temp|=\relax \fi
   \def\:tempa{html}\ifx \:tempa\:tempb \let\:temp|=\relax \fi
   \def\:tempa{xhtml}\ifx\:tempa\:tempb \let\:temp|=\relax \fi
   \def\:tempa{htm}\ifx  \:tempa\:tempb \let\:temp|=\relax \fi
   \def\:tempa{htm3}\ifx \:tempa\:tempb \let\:temp|=\relax \fi
   \def\:tempa{htm4}\ifx \:tempa\:tempb \let\:temp|=\relax \fi
   \def\:tempa{htm5}\ifx \:tempa\:tempb \let\:temp|=\relax \fi
   |<extract tex4ht options|>%
}
>>>


\item{First Option for /Preamble}

\<2nd option\><<<
\def\load:cfg{\let\config:opt|=\CurrentOption  
   |<options 3...|>}%
>>>

\item{Non-First Option for /Preamble}

\<options 3...\><<<
\def\load:cfg{\edef\config:opt{\config:opt,\CurrentOption}}%
>>>

\EndList



\def\gt:laopt#1,#2|<par del|>{\def\:temp{#1}\ifx \:temp\empty
   \else \cfg:fl#1.|<par del|>\fi
   \def\:temp{#2}\ifx \:temp\empty \else \let\config:opt|=\:temp \fi}




The following case arises for loading the
file with the \`'\input tex4ht.sty' command.

\<requires /Preamble.../EndPreamble\><<<
\def\:temp{\ifx \HCode\:UnDef
   \:warning{Missing \string\Preamble...\string\EndPreamble?}\fi}
\edef\:tempa{%
  \noexpand\expandafter
  \noexpand\expandafter
  \noexpand\expandafter
  \noexpand            \def
  \noexpand\expandafter
  \noexpand\expandafter
  \noexpand\expandafter
  \expandafter\noexpand\csname enddocument\endcsname
  \noexpand\expandafter
  \noexpand\expandafter
  \noexpand\expandafter
                      {\noexpand        \expandafter
                       \noexpand        \:temp
           \expandafter\noexpand \csname enddocument\endcsname
                      }%
}  \:tempa
>>>

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Utilities} 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\<html utilities\><<<
\csname newskip\endcsname\tmp:dim
>>>


\<early utilities\><<<
|<def Configure|>
|<early Configure|>
>>>




\<utilities\><<<
          |<general utilities|>  
\ifHtml |<html utilities|> \fi
>>>

There are files, like mathml.4ht, that need to be loaded piecewise
because the configuration commands might vary during the loading time.
For instance, the \`'\Configure{cases}' uses two parameters in plain
tex, and the go up into four parameters in amstex.

\<first pass\><<<
\let\:Hincl|=\empty
\def\Hinclude[#1]#2{\xdef\:Hincl{\:Hincl{#1}{#2}}}
>>>



The following extracts \''\Hinclude' frm preamble. For instance,
\''\Preamble{mathml.4ht,foo.4ht,...}' is the same as
\''\Hinclude[*]{mathml.4ht}\Hinclude{foo.4ht}\Preamble{...}'. The
file extensions must be \''.4ht'.

\<extract Hinclude\><<<
\def\:temp####1.4ht####2|<par del|>{\def\:temp{####2}%
  \ifx \:temp\empty 
    \def\:temp{th4}\ifx \:temp\Preamble \else
      \ht:special{t4ht@[}%
      \input tex4ht.4ht   \ht:special{t4ht@]}%
  \fi \fi}%
\expandafter\:temp\Preamble.4ht|<par del|>%
\expandafter\xtrct:hin\Preamble,,|<par del|>%
|<redefine Hinclud|>%
>>>



\<define for /Preamble\><<<
\def\xtrct:hin#1,{\def\:temp{#1}\ifx \:temp\empty
   \def\xtrct:hin##1|<par del|>{\let\xtrct:hin|=\:UnDef}\else
      \def\:tempa##1.4ht##2|<par del|>{%
         \def\:temp{\Hinclude[*]{##1.4ht}}\def\:tempa{##2}}%
      \expandafter\:tempa\:temp .4ht|<par del|>%
      \ifx \:tempa\empty \else \:temp   \fi
   \fi  \xtrct:hin}
>>>


Until \''\Preamble' is encountered, \''\Hinclude' requrests
`vertiv=cal' 4ht files (html4,html0, mathml, unicode,...), during
\''\Preamble' if requests `horizontal' files (latex, plain,etc), and
after the \''\Preamble' it is undefined.



\<redefine Hinclud\><<<
\:Hinclude
>>>

\<define for /Preamble\><<<
\def\Use:N{0}
\let\:USE|=\empty
\def\:Use#1{\:USe #1,,\HAdvance\Use:N |by 1 }
\def\:USe#1,{\def\:temp{#1}\ifx\:temp\empty
     \edef\:temp{\noexpand\append:def\noexpand\:USE{\let\expandafter
      \noexpand\csname Use:\Use:N\endcsname\noexpand\:UnDef}}\:temp
   \else
     \edef\:temp{\noexpand\append:def\noexpand\:USE{\expandafter
      \noexpand\csname Use:\Use:N\endcsname}}\:temp
   \append:def\:USE{{#1}}%
   \expandafter\:USe\fi}
\def\:Hinclude{%
   \def\Hinclude{\afterassignment\:Use
      \expandafter\def\csname Use:\Use:N\endcsname ####1}%
   \def\:Hinclude{\ifx \:USE \empty 
       \let\Hinclude|=\:UnDef
       \let\:Hinclude|=\:UnDef
       \let\:Use|=\:UnDef
       \let\:USe|=\:UnDef
       \let\:USE|=\:UnDef
     \else
      \pend:def\:USE{\let\:USE|=\empty}%
      \expand:after{\:USE \:Hinclude}\fi}%
}
>>>




Do we want the push/pop below?


\<Hinput Configs\><<<
\let\:Hin|=\empty
\def\Hinput#1{\PushStack\:Hinputs\:Hin \def\:Hin{#1}%
   \expandafter\:Hinput\:Hincl{}{}\PopStack\:Hinputs\:Hin}
\def\:Hinput#1#2{\def\:temp{#2}\ifx \:temp\empty \else
     \let\:temp|=\empty   \def\:tempa{*}\def\:tempb{#1}%
     \ifx \:tempa\:tempb \def\:temp{\input #2}%
     \else \ifx \:Hin\:tempb  \def\:temp{\input #2}%
     \else \def\:tempb{#1.4ht}\ifx \:Hin\:tempb \def\:temp{\input #2}%
     \fi\fi\fi
   \expand:after{\:temp
     |<system NewConfigure|>\:Hinput}\fi}
>>>





\<html utilities\><<<
\def\exit:ifnot#1{%
   \edef\:temp{\def\noexpand\:temp####1,\:Hin,####2..//{%
      \noexpand\if !####2!\noexpand\else
      \noexpand\expandafter\noexpand\:gobble\noexpand\fi
      }\noexpand\:temp,#1,\:Hin,..//}\:temp\endinput }
>>>

\<html utilities\><<<
   \catcode`\@|=0
   \catcode`\\|=12
@def@ConfigureHinput{%
   @def@:temp##1{%
      @def@:temp{##1}@ifx@:temp@:Hin @else @:tempb @fi }%
   @def@:tempb{@fi@bgroup @no:catcodes0{255}{12}%
      @no:catcodes{101}{101}{11}%
      @no:catcodes{109}{109}{11}%
      @no:catcodes{112}{112}{11}%
      @no:catcodes{116}{116}{11}%
      @no:catcodes{121}{121}{11}%
      @:tempa}
   @def@:tempa##1\empty\empty\empty\empty\empty\empty{@egroup}%
   @:temp
}
   @catcode`@\=0
   \catcode`\@=11
>>>





\<early utilities\><<<
\catcode`\#=12   \def\#{#}   \catcode`\#=6
>>>

The starred command is for immediate expansion

Can we avoid the following file?

\<general utilities\><<<
\immediate\openout15=\jobname.tmp
\bgroup \escapechar=`\\
   \immediate\write15{\def\string\Jobname{\jobname}}
\egroup
\immediate\closeout15
\input \jobname.tmp

\def\get:input#1{%
   \openin15=#1
   \ifeof15  \closein15  \:warning{No file #1}%
   \else     \closein15  \expand:after{\input #1 }%
   \fi}
>>>


\<general utilities\><<<
\def\if:notempty#1#2{%
   \def\:temp{#1}\ifx \:temp\empty \else \expand:after{#2}\fi }
>>>


\Chapter{Configurations}


\Section{Contributes}


\<early utilitiesNO\><<<
\long\def\Contribute#1#2{%
   \expandafter\ifx \csname :#1:\endcsname\relax 
      \:warning{\string\Contribute{#1}?}\fi  
   \long\expandafter\def\csname :#1:\endcsname{#2}}
>>>

\<utilitiesNO\><<<
\long\def\Contribute#1#2{%
   \expandafter\ifx \csname :#1:\endcsname\relax 
      \:warning{\string\Contribute{#1}?}\else
   \long\expandafter\def\csname :#1:\endcsname{#2}\fi }
>>>


\Section{Configurations}


\SubSection{Configure}



The following assumes a definition \`'\Odef\c:#2:[#1]...'

\<def Configure\><<<
\def\Configure#1{%
  \expandafter\ifx \csname c:#1:\endcsname\relax
     \:warning{\string\Configure{#1}?}
  \fi
  \csname c:#1:\endcsname}
\let\c:def|=\def
\let\d:def|=\def
>>>










\SubSection{NewConfigure}







\<def Configure\><<<
\def\NewConfigure#1{\def\:tempa{#1}\futurelet\:temp\Nw:cnf}
\def\Nw:cnf{\ifx [\:temp \edef\:tempa{\noexpand\N:wCnfga{\:tempa}}\else
   \edef\:tempa{\noexpand\N:wCnfgb{\:tempa}}\fi \:tempa}
\def\N:wCnfga#1[#2]{%
  \edef\:temp{|</long/def/c:...:|>}\:temp }
\def\N:wCnfgb#1#2{%
  \edef\:temp{|</long/def/c:...:|>{\New:Conf{\aNew:Conf#1}{####1}%
      \ifnum #2>1 \New:Conf{\bNew:Conf#1}{####2}\fi
      \ifnum #2>2 \New:Conf{\cNew:Conf#1}{####3}\fi
      \ifnum #2>3 \New:Conf{\dNew:Conf#1}{####4}\fi
      \ifnum #2>4 \New:Conf{\eNew:Conf#1}{####5}\fi
      \ifnum #2>5 \New:Conf{\fNew:Conf#1}{####6}\fi
      \ifnum #2>6 \New:Conf{\gNew:Conf#1}{####7}\fi
      \ifnum #2>7 \New:Conf{\hNew:Conf#1}{####8}\fi
      \ifnum #2>8 \New:Conf{\iNew:Conf#1}{####9}\fi
     }}\:temp}
>>>

\</long/def/c:...:\><<<
\long\def\expandafter
    \noexpand\csname c:#1:\endcsname####1%
    \ifnum #2>1 ####2\fi    \ifnum #2>2 ####3\fi
    \ifnum #2>3 ####4\fi    \ifnum #2>4 ####5\fi
    \ifnum #2>5 ####6\fi    \ifnum #2>6 ####7\fi
    \ifnum #2>7 ####8\fi    \ifnum #2>8 ####9\fi
>>>





\<def Configure\><<<
\def\New:Conf#1{\noexpand\c:def
   \expandafter\noexpand\csname#1\endcsname}%
\def\c:NewConfigure:#1#2#3#4#5#6#7#8#9{%
   \def\aNew:Conf{#1}\def\bNew:Conf{#2}\def\cNew:Conf{#3}%
   \def\dNew:Conf{#4}\def\eNew:Conf{#5}\def\fNew:Conf{#6}%
   \def\gNew:Conf{#7}\def\hNew:Conf{#8}\def\iNew:Conf{#9}}  
|<system NewConfigure|>
>>>


After each loading of the vertical 4ht files, the coefficients
of newconfigure assume their initial definitions.

\<system NewConfigure\><<<
\Configure{NewConfigure}{a:}{b:}{c:}{d:}{e:}{f:}{g:}{h:}{i:}%
>>>



\Section{Tracing Configurations}



See also LaTeX part


\<trace configurations\><<<
\:CheckOption{hooks++} \if:Option
   |<trace+ comamnds|>
   \def\edit:p#1#2{\let#2|=\empty \:gobble}%
\else \:CheckOption{hooks+}  \if:Option
       \def\trc:wrt{\writesixteen}
    \else \:CheckOption{hooks}  \if:Option
       \let\trc:wrt|=\:gobble
    \fi\fi
 \if:Option
   |<trace commands|>
   \let\edit:p|=\empty
\fi \fi
\if:Option
   |<trace and trace+|>
   \NewConfigure{hooks}[4]{\def\a:trc{#1}\def\b:trc{#2}%
      \def\c:trc{#3}\def\d:trc{#4}%
      \ifx \a:trc\empty \def\a:trc##1\b:trc{\b:trc}\fi
      \ifx \c:trc\empty \def\c:trc##1\d:trc{\d:trc}\fi
   }
   \def\d:def{\advance\tmp:cnt |by1\def}
   \Configure{hooks}{}{}{}{}
\else
   \let\c:hooks:|=\:gobbleIV
   |<no trace and trace+|>
\fi
>>>

\<trace+ comamnds\><<<
   \pend:defI\Configure{\tmp:cnt|=0
      \long\def\c:def####1####2{\advance\tmp:cnt |by1
        |<tempb = number of parameters|>
        \def####1{####2}%
        \edef\:temp{\noexpand\pend:def\noexpand####1{\noexpand\ifx
           \noexpand\EndPicture\noexpand\:UnDef \hbox{\noexpand\a:trc
           ##1\the\tmp:cnt :\:tempb\noexpand\b:trc}\noexpand\fi}}\:temp
        \edef\:temp{\noexpand\append:def\noexpand####1{\noexpand\ifx
           \noexpand\EndPicture\noexpand\:UnDef\hbox{\noexpand\c:trc
           ##1\the\tmp:cnt :\:tempb\noexpand\d:trc}\noexpand\fi}}\:temp
   }}
>>>


\<trace commands\><<<
\pend:defI\Configure{\tmp:cnt|=0
   \long\def\c:def####1####2{\advance\tmp:cnt |by1
     |<tempb = number of parameters|>
     \def####1{####2}%
     \ifx ####1\empty
        \edef\:temp{\noexpand\pend:def\noexpand####1{\hbox{\noexpand
          \a:trc ##1\the\tmp:cnt :\:tempb\noexpand\b:trc}}}\:temp
        \edef\:temp{\noexpand\append:def\noexpand####1{\hbox{\noexpand
          \c:trc ##1\the\tmp:cnt :\:tempb\noexpand\d:trc}}}\:temp
     \else
        \trc:wrt{...##1\the\tmp:cnt....\meaning####1}%
     \fi
}}
>>>

\<trace and trace+\><<<
\edef\:tempb{\def\noexpand
   \par:N##1\string :##2->##3////{\noexpand\par:NN?##2//}}
\:tempb
\def\par:NN#1#2//{\def\:tempb{#2}\ifx\:tempb\empty
   \def\:tempb{#1}\else \def\:tempb{\par:NN#2//}\expandafter\:tempb\fi}
>>>

\<tempb = number of parameters\><<<
\edef\:tempb{\expandafter \meaning\csname c:##1:\endcsname}%
\expandafter\par:N  \:tempb////%
>>>





\Section{Editing and Xml}





Note that \`'edit' is not the option \`'tty'!



\<trace configurations\><<<
\def\Tg<#1>{%
   \expandafter\ifx
      \csname\try:tagend <#1</|<par del|>\endcsname\is:empty
      \:tagend#1|<par del|>\else
   \expandafter\ifx 
      \csname\try:tagempty #1>/>|<par del|>\endcsname\is:empty
      \:tag{#1}\else  \:tagempty #1>\fi\fi}
\def\try:tagend#1</#2|<par del|>{#1is:empty}
\def\try:tagempty#1/>#2|<par del|>{#2is:empty}
\def\is:empty{\empty\empty}
\:CheckOption{edit} \if:Option 
  |<tg and TG|>
  |<edit* option|>
\else
  |<no-edit tg and TG|>
  \:CheckOption{verify}\if:Option\else \:CheckOption{verify+}\fi
  \if:Option
     |<edit- code|>
  \else
     |<no-edit option|>
  \fi
\fi
>>>

The \''\tg' is also part of mex.

\<tg and TG\><<<
% \def\tg<#1>{\c:edit#1\d:edit}
\def\TG<#1>{\a:edit#1\b:edit}
>>>

\<no-edit tg and TG\><<<
% \def\tg<#1>{<#1>}
\def\TG<#1>{\HCode{<#1>}}
>>>



The \`'edit+' is a pseudo-browser mode showing a possible
view of the code.

\<no-edit option\><<<
\def\:tag#1{\hbox{\HCode{<#1>}}}
\def\:tagend#1#2|<par del|>{\hbox{\HCode{</#2>}}}
\def\:tagempty#1/>{\hbox{\HCode{<#1/>}}}
\expandafter\def\csname c:<:\endcsname#1>{\:gobbleII}
>>>


The \`'\hbox' above is to avoid creating extra paragraphs with
extra tags, which can also introduce extra paragraph ends.

The definiions of \''\c:<...>:' are broken into two parts
to avoid the spaces after the closing angular bracket \''>'.

\<edit+ option\><<<
\def\tag:of#1 #2|<par del|>{#1}
\def\pl:s{+}
\def\:tag#1{\VerifyOpen{#1}\expandafter\ifx
   \csname A:\tag:of#1 |<par del|>\endcsname\pl:s\else
     \hbox{\a:edit\HCode{#1}\b:edit}%
   \fi \csname B:\tag:of#1 |<par del|>\endcsname
  }
\def\:tagend#1#2|<par del|>{\VerifyClose{#2}\expandafter\ifx
   \csname A:/\tag:of#2 |<par del|>\endcsname\pl:s\else
     \hbox{\a:edit\HCode{/#2}\b:edit}%
   \fi \csname B:/\tag:of#2 |<par del|>\endcsname
  }
\def\:tagempty#1/>{\VerifyEmpty{#1}\expandafter\ifx
   \csname A:\tag:of#1 |<par del|>/\endcsname\pl:s\else
     \hbox{\a:edit\HCode{#1/}\b:edit}%
   \fi \csname B:\tag:of#1 |<par del|>/\endcsname
  }
\expandafter\def\csname c:<:\endcsname#1>{\edef\:temp{#1}\:gat}
\long\def\:gat#1#2{\expandafter
   \def\csname A:\:temp\endcsname{#1}%
   \expandafter\def\csname B:\:temp\endcsname{#2}}
\NewConfigure{edit}{4}  
\Configure{edit}{\HCode{<strong class="edit">&lt;}}
                {\HCode{&gt;</strong>}}
>>>   


\<edit option\><<<
\def\tag:of#1 #2|<par del|>{#1}
\def\:tag#1{\csname A:\tag:of#1 |<par del|>\endcsname
   \VerifyOpen{#1}\a:edit\HCode{#1}\b:edit
   \csname B:\tag:of#1 |<par del|>\endcsname
  }
\def\:tagend#1#2|<par del|>{\csname A:/\tag:of#2 |<par del|>\endcsname
   \VerifyClose{#2}\a:edit\HCode{/#2}\b:edit
   \csname B:/\tag:of#2 |<par del|>\endcsname
  }
\def\:tagempty#1/>{\csname A:\tag:of#1 |<par del|>/\endcsname
   \VerifyEmpty{#1}\a:edit\HCode{#1/}\b:edit
   \csname B:\tag:of#1 |<par del|>/\endcsname
  }
\expandafter\def\csname c:<:\endcsname#1>{\edef\:temp{#1}\:gat}
\long\def\:gat#1#2{\expandafter
   \def\csname A:\:temp\endcsname{#1}%
   \expandafter\def\csname B:\:temp\endcsname{#2}}
\NewConfigure{edit}{4}  
\Configure{edit}{\HCode{<strong>&lt;}}{\HCode{&gt;</strong>}}
                {<strong>&lt;}{&gt;</strong>}
>>>   

\<edit- code\><<<
\def\:tag#1{\VerifyOpen{#1}\hbox{\HCode{<#1>}}}
\def\:tagend#1#2|<par del|>{\VerifyClose{#2}\hbox{\HCode{</#2>}}}
\def\:tagempty#1/>{\VerifyEmpty{#1}\hbox{\HCode{<#1/>}}}
\expandafter\def\csname c:<:\endcsname#1>{\:gobbleII}
>>>


The \`'\hbox' above is to avoid creating extra paragraphs with
extra tags, which can also introduce extra paragraph ends.




\<edit* option\><<<
\def\tag:of#1 #2|<par del|>{#1}
\def\mn:s{-}
\def\:tag#1{\VerifyOpen{#1}\expandafter\ifx
   \csname A:\tag:of#1 |<par del|>\endcsname\mn:s\else
     \csname A:\tag:of#1 |<par del|>\endcsname
     \hbox{\a:edit\HCode{#1}\b:edit}%
   \fi \csname B:\tag:of#1 |<par del|>\endcsname
  }
\def\:tagend#1#2|<par del|>{\VerifyClose{#2}\expandafter\ifx
   \csname A:/\tag:of#2 |<par del|>\endcsname\mn:s\else
     \csname A:/\tag:of#2 |<par del|>\endcsname
     \hbox{\a:edit\HCode{/#2}\b:edit}%
   \fi \csname B:/\tag:of#2 |<par del|>\endcsname
  }
\def\:tagempty#1/>{\VerifyEmpty{#1}\expandafter\ifx
   \csname A:\tag:of#1 |<par del|>/\endcsname\mn:s\else
     \csname A:\tag:of#1 |<par del|>/\endcsname
     \hbox{\a:edit\HCode{#1/}\b:edit}%
   \fi \csname B:\tag:of#1 |<par del|>/\endcsname
  }
\expandafter\def\csname c:<:\endcsname#1>{\edef\:temp{#1}\:gat}
\long\def\:gat#1#2{\expandafter
   \def\csname A:\:temp\endcsname{#1}%
   \expandafter\def\csname B:\:temp\endcsname{#2}}
\NewConfigure{edit}{4}  
>>>   


\Section{Logical commands}

\<html Configure's\><<<
\def\InsertTagStart#1#2{%
  \edef\local:properties{\ifx\relax#2\relax\else\space#2\fi}
  \HCode{<\get:tag{#1}\get:block:properties{#1}\local:properties>}%
}
\def\InsertTagEnd#1{\HCode{</\get:tag{#1}>}}

\long\def\InlineElementStart#1#2{\InsertTagStart{#1}{#2}}
\long\def\InlineElementEnd#1{\InsertTagEnd{#1}}

\long\def\BlockElementStart#1#2{\ifvmode\IgnorePar\fi\EndP\InsertTagStart{#1}{#2}}
\long\def\BlockElementEnd#1{\ifvmode\IgnorePar\fi\EndP\InsertTagEnd{#1}}

% define default values for a new logical block
\def\NewLogicalBlock#1{%
  \SetTag{#1}{span}%
  \expandafter\def\csname #1:properties\endcsname{}
}

\def\SetTag#1#2{\expandafter\xdef\csname #1:tagname\endcsname{#2}}
\def\get:tag#1{\expandafter\expandafter\csname #1:tagname\endcsname}

\def\SetBlockProperty#1#2#3{%
  \expandafter\ifcsname #1:property:#2\endcsname\else%
  \expandafter\edef\csname #1:properties\endcsname{\csname #1:properties\endcsname\space\csname #1:property:#2\endcsname }
  \fi%
  \expandafter\def\csname #1:property:#2\endcsname{#2="#3"}
}

\def\get:block:properties#1{%
\expandafter\csname #1:properties\endcsname%
}

>>>

\Section{Verify Elements}

\<html Configure's\><<<
\:CheckOption{verify} \if:Option 
   |<chk no trace|>
\else  \:CheckOption{verify+} \if:Option 
   |<chk trace|>
\fi \fi
\if:Option
    |<check utilities|>
\else
   \let\VerifyOpen|=\:gobble
   \let\VerifyClose|=\:gobble
   \let\VerifyEmpty|=\:gobble
   \long\def\Verify#1\EndVerify{}
   \def\trace:chk#1 #2|<par del|>{}
\fi
>>>

\<chk no trace\><<<
\let\:chk:trc|=\:gobble
>>>

\<chk trace\><<<
\def\:chk:trc#1{%
   \writesixteen{\the\inputlineno\space(\:ChkLevel) #1}}
>>>

The \`'\PushStack\:CHK\empty' is needed because whenever a pop occurs,
we temporarily take one more pop to check who was the old parent.

\<check utilities\><<<
\HAssign\:ChkLevel|=0
\let\:CurrentChk|=\empty
\PushStack\:CHK\empty
\def\VerifyOpen#1{\Protect\trace:chk#1 |<par del|>}
\def\trace:chk#1 #2|<par del|>{%
   \gHAdvance\:ChkLevel |by 1 \:chk:trc{Open......#1}%
   \expandafter\ifx \csname #1Level:\endcsname\relax
      \expandafter\gHAssign\csname #1Level:\endcsname|=0      
   \fi
   \expandafter\gHAdvance\csname #1Level:\endcsname |by 1
   \PushStack\:CHK{#1}%
   \expandafter\ifx \csname \:CurrentChk +#1\endcsname\relax
      \expandafter\gdef  \csname \:CurrentChk +#1\endcsname{}%
         \writesixteen{\the\inputlineno. 
            --- warning --- \:CurrentChk\space --> #1 ?}%
   \fi
   \xdef\:CurrentChk{#1}%
}
\def\VerifyClose#1{\Protect\trace:endchk#1 |<par del|>}
\def\trace:endchk#1 #2|<par del|>{%
   \:chk:trc{Close......#1}%
   \expandafter\ifx \csname #1Level:\endcsname\relax
      \writesixteen{\the\inputlineno. 
         --- warning --- </#1> witout <#1>}%
      \expandafter\gHAssign\csname #1Level:\endcsname|=0
   \else
      \expandafter\gHAdvance\csname #1Level:\endcsname |by -1
      \gHAdvance\:ChkLevel |by -1
      \PopStack\:CHK\:temp
      \edef\:tempa{#1}% 
      \ifx \:temp\:tempa
         \PopStack\:CHK\:CurrentChk
         \PushStack\:CHK\:CurrentChk
     \else  
         \writesixteen{\the\inputlineno. 
            --- warning --- </\:temp> instead of </#1>}%
      \fi
   \fi
}
\def\VerifyEmpty#1{\Protect\trace:emptychk#1 |<par del|>}
\def\trace:emptychk#1 #2|<par del|>{%
   \:chk:trc{Empty......#1}%
   \expandafter \ifx \csname \:CurrentChk +#1\endcsname\relax
      \expandafter\gdef  \csname \:CurrentChk +#1\endcsname{}%
         \writesixteen{\the\inputlineno. 
         --- warning --- \:CurrentChk\space --> #1 ?}%
   \fi
}
\begingroup
   \catcode`\^|=7
   \gdef\Verify{\bgroup \catcode`\ |=9 \catcode`\^^M|=9 \:dtd}
\endgroup
\def\:dtd#1\EndVerify{\egroup\dtd:rule#1,-->,}
\def\dtd:rule#1-->#2,{\def\:temp{#1#2}\ifx \:temp\empty\else
     \expandafter\gdef  \csname #1+#2\endcsname{}%
  \expandafter\dtd:rule
  \fi}
>>>


\Chapter{Html Environment}

\Section{Initiating}


The \`'\special{t4ht.\:html}' gives the extension to the root file. To
be recognized, Must appear before the openning of any file, and
outputing of any content.

\<html option\><<<
\def\:tempa#1#2#3#4|<par del|>{#1#2#3} 
\:CheckOption{htm}     \if:Option
   \edef\:html{\expandafter\:tempa\:html\empty\empty|<par del|>}
   |<base 2 names for htm|>
\else \:CheckOption{htm5}     \if:Option
   \edef\:html{\expandafter\:tempa\:html\empty\empty|<par del|>}
   |<base 5 names for htm|>
\else \:CheckOption{htm4}     \if:Option
   \edef\:html{\expandafter\:tempa\:html\empty\empty|<par del|>}
   |<base 4 names for htm|>
\else \:CheckOption{htm3}     \if:Option
   \edef\:html{\expandafter\:tempa\:html\empty\empty|<par del|>}
   |<base 3 names for htm|>
\else   \:CheckOption{xhtml} \if:Option 
   \let\j:bname|=\jobname 
\else   \:CheckOption{html}
   \if:Option  \let\j:bname|=\jobname \fi
\fi \fi \fi \fi \fi
\if:Option 
   |%   \ht:special{t4ht.\:html} |%
   |<default html env|>
   |<disregard html:par from protex|>
   |<html TeX4ht protex|>
\fi
>>>



\<first pass\><<<
\NewConfigure{ext}[1]{%
   \def\:temp##1ext=##2,##3|<par del|>{%
      \if !##2!\edef\:html{#1}%
      \else \edef\:html{##2}\fi}%
   \expandafter\:temp\Preamble ,ext=,|<par del|>
}
\Configure{ext}{html}
>>>

\<base 2 names for htm\><<<
\def\:temp#1#2#3|<par del|>{\def\j:bname{#1\ifx ?#2\else #2\fi}}
\expandafter\:temp \jobname ?|<par del|>
>>>

\<base 3 names for htm\><<<
\def\:temp#1#2#3#4|<par del|>{\def\j:bname{#1\ifx ?#2\else
   #2\ifx ?#3\else #3\fi\fi}}
\expandafter\:temp \jobname ??|<par del|>
>>>

\<base 4 names for htm\><<<
\def\:temp#1#2#3#4#5|<par del|>{\def\j:bname{#1\ifx ?#2\else 
   #2\ifx ?#3\else #3\ifx ?#4\else #4\fi\fi\fi}}
\expandafter\:temp \jobname ???|<par del|>
>>>


\<base 5 names for htm\><<<
\def\:temp#1#2#3#4#5#6|<par del|>{\def\j:bname{#1\ifx ?#2\else 
   #2\ifx ?#3\else #3\ifx ?#4\else #4\ifx ?#5\else #5\fi\fi\fi\fi}}
\expandafter\:temp \jobname ????|<par del|>
>>>





%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{\TeX{} Parameters}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\`'\html:rightskip' is already defined in AlProTex, but we need it early here.

\<def /HtmlEnv\><<<
\def\html:rightskip{\rightskip|=\z@ plus 0.5\hsize  minus0.5\hsize }
\def\HtmlEnv{%
   \html:rightskip  |<html penalties|>%
   \def\magnification{%
      \def\:temp{\:warning{Insert \string\magnification
                           =\the\tmp:cnt\space before tex4ht}}%
      \afterassignment\:temp\tmp:cnt}%
   \ht:everypar{\HtmlPar}}
\let\HtmlPar|=\empty
>>>



The \''\output' variable might hold a script
with
a \''\par', as is the case in LaTeX.

\<def /HtmlEnv\><<<
\edef\:temp{%
   \output={\noexpand\SaveEverypar \noexpand\ht:everypar{}\the\output
         \noexpand\RecallEverypar}}
\:temp
>>>>




% \let\HtmlENV|=\:gobble

Inhibit streching and shrinking of spaces between words to help tex4ht,
and let flexibility in line length to compensate for fixed spaces and
discouraged word breaks.

\<html penalties\><<<
\frenchspacing        |%no extra space after punctuation marks|%
\let\nonfrenchspacing|=\relax
\spaceskip|=\z@        |%override inter word glue|%
\xspaceskip|=\z@       |%same but for words ending with punctuation marks|%
\linepenalty|=0        |%charged on each line break|%
\adjdemerits|=0        |%charged on adj lines of diff length|%
\pretolerance|=10000   |%max penalty pts per line without hyphenation|%
\hyphenpenalty|=10000  |%for line break within word|%
\exhyphenpenalty|=10000|%for line break after hyphen|%
\clubpenalty|=0        |%for page break after first line of parag|%
\widowpenalty|=0       |%for page break before last line of parag|%
\interlinepenalty|=50  |%for page break within a paragraph|%
\displaywidowpenalty|=0
\predisplaypenalty|=-10
\postdisplaypenalty|=1000
\abovedisplayskip|=30pt plus 10pt
\belowdisplayskip|=\abovedisplayskip
\abovedisplayshortskip|=\abovedisplayskip
\belowdisplayshortskip|=\abovedisplayskip
>>>

We don't want a page break after a display, because the
\''\aftergroup' material for the equation may be detached from the
equation. A possible prolem for math into figures.


\<default html env\><<<
|<def /HtmlEnv|>
\edef\:temp{\meaning\everypar}
\edef\:tempa{\string\everypar}
\ifx \:temp\:tempa   
   \let\ht:everypar|=\everypar
\else
   % LaTeX kernel will patch \everypar in future releases,
   % so this test will always fail. We should define \ht:everypar
   % anyway, paragraph handling would fail otherwise
   \let\ht:everypar|=\everypar
   \:warning{nonprimitive \string\everypar}
\fi
\edef\NoHtmlEnv{%
   \sfcode `\noexpand\noexpand\noexpand\.3000  |%nonfrenchspacing|%
   \sfcode `\noexpand\noexpand\noexpand\?3000
   \sfcode `\noexpand\noexpand\noexpand\!3000
   \sfcode `\noexpand\noexpand\noexpand\:2000
   \sfcode `\noexpand\noexpand\noexpand\;1500
   \sfcode `\noexpand\noexpand\noexpand\,1250 
   \rightskip|=\the\rightskip  
   \spaceskip|=\the\spaceskip
   \xspaceskip|=\the\xspaceskip
   \linepenalty|=\the\linepenalty
   \adjdemerits|=\the\adjdemerits
   \pretolerance|=\the\pretolerance
   \hyphenpenalty|=\the\hyphenpenalty
   \exhyphenpenalty|=\the\exhyphenpenalty
   \clubpenalty|=\the\clubpenalty
   \widowpenalty|=\the\widowpenalty
   \interlinepenalty|=\the\interlinepenalty
   \displaywidowpenalty|=\the\displaywidowpenalty
   \predisplaypenalty|=\the\predisplaypenalty
   \postdisplaypenalty|=\the\postdisplaypenalty
   \abovedisplayskip|=\the\abovedisplayskip
   \belowdisplayskip|=\the\belowdisplayskip
   \abovedisplayshortskip|=\the\abovedisplayshortskip
   \belowdisplayshortskip|=\the\belowdisplayshortskip
   \noexpand\ht:everypar{\noexpand\the\noexpand\ht:everypar}}
>>>


\<activate html env\><<<
\edef\NoHtmlEnv{\NoHtmlEnv}%
\append:def\NoHtmlEnv{\SUBOff \SUPOff}\HtmlEnv
>>>

\<html utilities\><<<
\let\:noindent|=\noindent
\def\noindent{\ifx \EndPicture\:UnDef
     \ifvmode  \IgnoreIndent\leavevmode\fi
   \else \:noindent \fi}
>>>

\Section{Paragraphs}

We want to push specials at start of lines, and merge the space before
and after specials.

\<html utilities\><<<
\let\skip:Par|=\empty
>>>




\<html paragraph breaks at entry to file\><<<
\def\HtmlPar{\HtmlPar:Off{%
   \if:nopar \ShowPar \ShowIndent
      \ifx \skip:Par\empty\else \hskip -\parindent \skip:Par\fi
   \else 
     \if:removeindent \ShowIndent \hskip -\parindent \a:Par
     \else 
        \ifdim \parindent>\z@ \hskip -\parindent \fi 
        \html:par
        \ifdim \parindent>\z@ \hskip  \parindent \fi
   \fi\fi \relax
}}%
>>>


\<general utilities\><<<
\def\IgnorePar{\ifx \EndPicture\:UnDef \Protect\gl:nopartrue \fi}
\def\ShowPar{\ifx \EndPicture\:UnDef \Protect\gl:noparfalse \fi}
\def\IgnoreIndent{\ifx \EndPicture\:UnDef 
   \Protect\gl:removeindenttrue \fi}
\def\ShowIndent{\ifx \EndPicture\:UnDef 
   \Protect\gl:removeindentfalse \fi}
\def\gl:nopartrue{\global\:nopartrue}
\def\gl:noparfalse{\global\:noparfalse}
\def\gl:removeindenttrue{\global\:removeindenttrue}
\def\gl:removeindentfalse{\global\:removeindentfalse}
\def\HtmlParOff{\global\let\HtmlPar:Off|=\:gobble}
\def\HtmlParOn{\gdef\HtmlPar:Off##1{##1}}
\HtmlParOn
>>>





\<new ifs\><<<
\:tempa{if:removeindent}
\:tempa{if:nopar}
>>>




\<first pass\><<<
\def\c:HtmlPar:#1#2#3#4{%
   \def\:temp{#3}\ifx \:temp\empty \c:def\a:Par{#1}\else
     \c:def\a:Par{#1\Next:EndP{#3}}\fi
   \def\:temp{#4}\ifx \:temp\empty \c:def\html:par{#2}\else
     \c:def\html:par{#2\Next:EndP{#4}}\fi
}
\def\EndP{\Protect\par:end}
\let\par:end|=\empty
\def\Next:EndP{\Protect\next:endp}
\def\next:endp#1{\gdef\par:end{#1\global\let\par:end|=\empty}}
\def\SaveHtmlPar{\PushMacro\a:Par \PushMacro\html:par}
\def\RecallHtmlPar{\PopMacro\a:Par \PopMacro\html:par}
>>>


The following is neded for debugging, to detect skipped paragraps.
Delete it, or just make it active for debugging mode!!!!!


\<shared config\><<<
\NewConfigure{HtmlPar*}[2]{%
   \def\:temp{#2}\ifx \:temp\empty \c:def\skip:Par{#1}\else
     \c:def\skip:Par{#1\Next:EndP{#2}}\fi}
>>>

\<first pass\><<<
\def\gl:let{\global\let}
\def\EndP:cnt{0}
\def\SaveEndP{%
   \expandafter\gl:let\csname \EndP:cnt :sv\endcsname |=\par:end
   \gl:let\par:end|=\empty
   \gHAdvance \EndP:cnt |by 1 }
\def\RecallEndP{%
   \ifnum \EndP:cnt>0
     \gHAdvance \EndP:cnt |by -1
     \expand:after{\gl:let\par:end|=}\csname\EndP:cnt :sv\endcsname
   \else 
     \:warning{extra \string\RecallEndP}
   \fi}
>>>

\<disregard html:par from protex\><<<
\ifx \html:par\:UnDef \let\html:par|=\empty \fi
>>>

User's input, and the following in case of no such input,
determine how files will initially treat paragraphs.






Display math formulas can be in-line or between paragraph.
The ``.nopar''  is for forced paragraph starts after the
end of in-line display paragraphs.  HTML 4.0  requires opening
of such paragraphs.



\<html paragraph breaks at entry to fileNO\><<<
\Configure{HtmlPar}{\sva:Par}{\svhtml:par} {}{}
>>>




\<empty html paragraph breaks\><<<
\Configure{HtmlPar}{}{}{}{}%
>>>





\<general utilities\><<<
\def\SaveEverypar{%
   \expandafter\ifx\csname ht:everypar\endcsname\relax
      \expand:after{\expandafter\gdef\csname \n:list L\endcsname }%
           \expandafter{\expandafter\everypar
                        \expandafter{\the\everypar}}%
   \else
      \expand:after{\expandafter\gdef\csname \n:list L\endcsname }%
           \expandafter{\expandafter\ht:everypar
                        \expandafter{\the\ht:everypar}}%
   \fi
   \expandafter\xdef\csname \n:list X\endcsname{%
      \if:removeindent  \global\noexpand\:removeindenttrue
      \else             \global\noexpand\:removeindentfalse \fi
      \if:nopar         \global\noexpand\:nopartrue
      \else             \global\noexpand\:noparfalse \fi}%
   \HtmlEnv     \csname \n:list X\endcsname
                \csname \n:list L\endcsname
   \gHAdvance\n:list |by  1 
}
\def\RecallEverypar{\ifnum \n:list<1
      \:warning{\noexpand\RecallEverypar without \noexpand\SaveEverypar}%
   \else
      \HtmlEnv
      \gHAdvance\n:list |by -1
      \csname \n:list X\endcsname
      \csname \n:list L\endcsname
   \fi
}
\def\n:list{0}
>>>




 
\Chapter{Cross References}


Should be  consistent with the corresponding features in ProTeX.


\<cross references\><<<
|<common cross references|>
\ifHtml  |<html cross references|>
\fi
>>>

\Section{The Commands}

\SubSection{Ref}

The implementations of \''\Ref' and \''\Tag' view the crosswords $\alpha$ as 
pointers to macros that carry  the names `\''\cw:'$\alpha$'. 

\<common cross references\><<<
\def\Ref#1{\expandafter\ifx
                 \csname |<tag of Tag|>#1\endcsname \relax \:NoTag{#1}%
           \else \csname |<tag of Tag|>#1\endcsname    \fi}
>>>


\<general utilities\><<<
\def\ifTag#1#2#3{\expandafter\ifx
   \csname |<tag of Tag|>#1\endcsname \relax #3\else #2\fi}
>>>







\SubSection{LikeRef}

The \`'\:LikeRef' command is a stripped down version of
\`'\Ref'; it doesn't check whether the tag is defined.

The space in \`'\space' is needed for carrying MAME tags
in (mosaic) html files.

\<common cross references\><<<
\def\LikeRef#1{\expandafter\ifx
                 \csname |<tag of Tag|>#1\endcsname \relax \space%
          \else  \csname |<tag of Tag|>#1\endcsname    \fi}
\def\:LikeRef#1{\csname  |<tag of Tag|>#1\endcsname}
>>>


Read file from previous compilation.




\SubSection{Tag}

A command \''\Tag{'$\alpha$\''}{'$\beta$\''}' introduces into the
reference file a record
 of the form
\''\:CrossWord{'$\alpha$\''}{'$\hat\beta$\''}{'$i$\''}'.


\<common cross references\><<<
\let\:SUPOff|=\empty \let\:SUBOff|=\empty
\def\Tag#1#2{\begingroup   \:SUPOff  \:SUBOff \a:xref \escapechar=`\\%
   \edef\:head{\string\:CrossWord{#1}{#2}}%
   \expandafter \expandafter \expandafter
   \:writeref\expandafter{\:head{\folio}\prcnt:ch}%
\endgroup}
\NewConfigure{xref}{1}
>>>

The \''\:SUBSUPOff' will be redefined latter with subscripts and
superscripts.   The current definition is sufficient for the
tags that in the meantime are created by the system.


\<common cross references\><<<
\def\:writeref{\write\:refout}%
>>>

\<general utilities\><<<
\catcode`\%|=12 \def\prcnt:ch{%} \catcode`\%|=14
>>>

\<html utilities\><<<
\catcode`\%|=12 \def\%{%} \catcode`\%|=14
>>>

\Section{Internal References}



\SubSection{Loading}

\<common cross references\><<<
\def\load:ref#1{%
   |<set catcodes for info in ref file|>%
   \get:input{#1}%
   \re:call   \let\:CrossWord|=\sv:crs  }
|<interpretation for entries in ref file|>  
\ifx \:refout\:UnDef
   |<check the existence of jobname.xref|>
   \load:ref{\jobname.xref}
   \csname newwrite\endcsname\:refout
   |<if latex then latex/write sol|>\openout\:refout=\jobname.xref 
\fi
>>>

\<check the existence of jobname.xref\><<<
\openin15=\jobname.xref 
\ifeof15  \def\:NoTag#1{\hbox{$???$}}
\else     \def\:NoTag#1{\hbox{$???$}
              \:warning{\string\Ref\string{\string#1\string}?}}
  |<warnings for missing /Link|>
\fi
\closein15
>>>






\<set catcodes for info in ref file\><<<
\edef\re:call{\catcode`\noexpand\:|=\the\catcode`\: }%
\catcode`\:|=11
\let\sv:crs|=\:CrossWord
\def\:CrossWord{\bgroup
   \no:catcodes{128}{255}{12}%
   \catcode`\:|=12  \catcode`\@|=11 
   \catcode`\^^M|=11    \:CrsWrd}%
\def\:CrsWrd##1##2##3{\egroup \sv:crs{##1}{##2}{##3}}%
>>>

Aborted compilations tend to leave incimplete \`':CrossWord' commands
in the xref file, missing the last page-number parameter. The
\`'\catcode`\^^M=11' allows such commands to be loaded without
terminating the compilation.

\Section{External References}

References to information in other files can be achieved with
the following file-loading command
\`'\LoadRef-[prefix]+{filename.ext}{...}'.



The \`'.ext', \`'+', \`'-', and \`'[...]' components are
optional. A missing \`'.ext' stands for \`'.xref'. When \`'-[prefix]+'
is empty the component \`'{...}' should also be omitted (and the
comamnd assume the form \`'\LoadRef{filename.ext}').

A \`'+' asks that \`'\Ref' and \`'LikeRef' commands will refer to
expanded tags of the form \`'filename::tag' instead of just \`'tag'.
A \`'[prefix]' asks that only tags which start with the given prefix
will be loaded. When \`'[prefix]' is omitted, an empty prefix is
assumed and all the tags are loaded. A \`'-' asks that \`'\Ref' and
\`'LikeRef' commands will refer to truncated tags in which the
specified prefixes are omitted.

Intuitively, a tag can be viewed as a triplet \`'<from>:<to><tag>'
which encodes information together with source and destination
addresses. The \`'{...}' specifies how the information should be
included, where \`'#1' represents the information being loaded.

\SubSection{Scanning the Preamble}



\<common cross references\><<<
\def\LoadRef{\futurelet|<-?|>\:LoadRef}
\def\:LoadRef{{%
   \if \bgroup|<-?|> 
      \aftergroup\loadr:ef
   \else
      \aftergroup\Load:Ref    \if -|<-?|> \else
                                  \aftergroup-\fi
   \fi
}}
\def\Load:Ref#1{\futurelet|<[?|>\LoadRef:}   
\def\LoadRef:{{%
   \aftergroup\:loadref    \ifx [|<[?|> \else
                              \aftergroup[\aftergroup]\fi}}
>>>


%%%%%%%%%%%%% WAS if[

\<common cross references\><<<
\def\:loadref[#1]{%
   \let\sv:cros|=\:CrossWord
   \edef|<prefix|>{#1}\ifx |<prefix|>\empty \let|<[?|>|= N\fi
   \futurelet|<+?|>\l:oadref }
\def\l:oadref{%
   {\aftergroup\lo:adref \if +|<+?|> \else \aftergroup+\fi  }}
\def\lo:adref#1#2#3{%
   \def\cw:format##1{#3}%
   \edef\:temp{#2}\expandafter \get:ext\:temp .|<par del|>%
   \ifx \:temp\empty  
         \set:CrossWord#2.|<par del|>{|<prefix|>}\load:ref{#2.xref}%
   \else \set:CrossWord#2|<par del|>{|<prefix|>}\load:ref{#2}\fi
   \let\:CrossWord|=\sv:cros }
\def\get:ext#1.#2|<par del|>{\def\:temp{#2}}
\def\loadr:ef#1{\let|<+?|>=x \let|<prefix|>|=\empty \lo:adref{}{#1}{##1}}
>>>



\<cs?\><<<
\:tempa>>>

\<-?\><<<
\:tempa>>>

\<[?\><<<
\:tempb>>>

\<+?\><<<
\:tempc>>>

\<prefix\><<<
\:tempd>>>

\SubSection{Incorporating the Preamble}

\<common cross references\><<<
\def\set:CrossWord#1|<par del|>#2{%
   \edef\:temp{\noexpand\:setCrossWord#1|<par del|>{#2}}\:temp}
\def\:setCrossWord|<ref filename par|>.#2|<par del|>|<substr par|>{%
   \ifx [|<[?|>
      \def\:CrossWord##1##2##3{%
         \cond:CrossWord##1|<substr par|>|<par del|>{##1}{##2}{##3}}%
      \def\:tail|<substr par|>##1|<substr par|>{##1}%
      \if +|<+?|>   |<:CrossWord := extend selected words|>%
      \else         |<:CrossWord := selected words|>\fi
   \else
      \if +|<+?|>   |<:CrossWord := extend all words|>\fi
   \fi              |%else :CrossWord := all words|%
}
>>>

%%%%%%%%%%%%% WAS if[


\<:CrossWord := extend all words\><<<
\def\:CrossWord{\Cross:Word{|<ref filename par|>::}}%
>>>

\<:CrossWord := extend selected words\><<<
\if -|<-?|>
   \def\cond:CrossWord##1|<substr par|>##2|<par del|>##3##4##5{%
      \def\:temp{##1}\ifx \:temp\empty
         \Cross:Word{|<ref filename par|>::}%
                    {\:tail##3|<substr par|>}{##4}{##5}\fi   }%
\else
   \def\cond:CrossWord##1|<substr par|>##2|<par del|>##3##4##5{%
      \def\:temp{##1}\ifx \:temp\empty
         \Cross:Word{|<ref filename par|>::}{##3}{##4}{##5}\fi   }%
\fi
>>>

\<:CrossWord := selected words\><<<
\if -|<-?|>
   \def\cond:CrossWord##1|<substr par|>##2|<par del|>##3##4##5{%
      \def\:temp{##1}\ifx \:temp\empty
         \Cross:Word{}{\:tail##3|<substr par|>}{##4}{##5}\fi  }%
\else
   \def\cond:CrossWord##1|<substr par|>##2|<par del|>##3##4##5{%
      \def\:temp{##1}\ifx \:temp\empty
         \Cross:Word{}{##3}{##4}{##5}\fi  }%
\fi
>>>





\Section{Interpretation for Entries}



For each crossword $\alpha$ the imported file contains a record of the
form \''\:CrossWord{'$\alpha$\''}{'$\hat{\beta}$\''}{'$i$\''}'.
In such a record, $\hat\beta$ and $i$ stand for the expanded token
list and HPage number that correspond to $\alpha$, respectively.

A command
\''\:CrossWord{'$\alpha$\''}{'$\hat{\beta}$\''}{'$i$\''}'   
introduces  the macro
\''\def\cw:'$\alpha$\''{'$\hat\beta$\''}', if the label is not empty.
Otherwise, it introduces  the macro \''\def\cw:'$\alpha$\''{'$i$\''}'
that holds the page number.


\<interpretation for entries in ref file\><<<
\def\:CrossWord#1#2#3{\Cross:Word{}{#1}{#2}{#3}}
\def\Cross:Word#1#2#3#4{%
   \def\:temp{#3}\tmp:toks{#3}%
   \expandafter\edef\csname |<tag of Tag|>\cw:format{#1#2}\endcsname{%
      \expandafter\ifx\csname |<tag of Tag|>\cw:format{#1#2}\endcsname\relax
      \else \csname |<tag of Tag|>\cw:format{#1#2}\endcsname ,  \fi
      \ifx \:temp\empty #4\else  \the\tmp:toks\fi}}
\def\cw:format#1{#1}%
>>>




\<par del\><<<
!*?: >>>

\<substr par\><<<
#3>>>

\<ref filename par\><<<
#1>>>

%%%%%%%%%%%%%%%%%%%
\Section{Link}
%%%%%%%%%%%%%%%%%%

Good for \''\Link{...}{...}' across files when we have 
\''\LoadRef+{...}{#1}'.

\<html cross references\><<<
\catcode`\:=12

\def\get@hfile#1{\get@hfil@ #1:::://}

\def\get@hfil@#1::#2::#3//{%
   \expandafter\ifx \csname
      |<tag of Tag|>#1::|<HTag tag|>#2\endcsname \relax \else
      \expandafter\expandafter\expandafter\get@@hfile
          \csname |<tag of Tag|>#1::|<HTag tag|>#2\endcsname,//{#1}%
   \fi}
\def\get@@hfile#1,#2//#3{%
    \expandafter\ifx
       \csname |<tag of Tag|>#3::|<auto file tag|>#1%
               |<Tag/Ref: file-id -> file-name|>\endcsname \relax
    \else
       \csname |<tag of Tag|>#3::|<auto file tag|>#1%
               |<Tag/Ref: file-id -> file-name|>\endcsname
       \expandafter  \expandafter  \expandafter  \expandafter
       \expandafter  \expandafter  \expandafter  \remove@fn
    \fi }

\def\remove@fn#1#2::{#1}

\catcode`\:=11
>>>





%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Utilities}
%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%
\SubSection{Empty Anchors}
%%%%%%%%%%%%%%%%%%%%%%%%%%

Change the following to standard space character when microsoft
explorer will let it.  Currently it wiil go only for ubreakable
space. The last null anchor is obviously the most desirable one.

\<html utilities\><<<
\def\hidden:anchor{}    
>>>

%%%%%%%%%%%%%%%%%%%%%%%%%%
\SubSection{Latex Anomalies}
%%%%%%%%%%%%%%%%%%%%%%%%%%

\<if latex then latex/write sol\><<<
\if:latex \expandafter\immediate\fi
>>>


Try to understand betetr what goes here, because I got
the following not workin in latex. It pushed the output
to the log file instead of the toc file.

\Verbatim
\<latex/write sol\><<<
\immediate
>>>
\EndVerbatim

Inserted for the differences in the output routines between TeX and
LaTeX.

\Verbatim
 -------ok----------------faulty------------------ok-----------------
|                 |                      |                           |
|                 | \documentstyle{book} | \documentstyle{book}      | 
|                 | \begin{document}     | \begin{document}          | 
| \newwrite\y     | \newwrite\y          | \newwrite\y               | 
| \openout\y=f.xx | \openout\y=f.xx      | \immediate\openout\y=f.xx |
| \write\y{....}  | \write\y{....}       | \immediate\write\y{....}  | 
| \closeout\y     | \closeout\y          | \immediate\closeout\y     | 
| \end            | \end{document}       | \end{document}            | 
 --------------------------------------------------------------------
\EndVerbatim

La\TeX has a \''\clearpage' and \''\cleardoublepage'.

\<latex /special sol\><<<
\ifx \clearpage\:UnDef  \def\:clearpage{\vfil\penalty-20000}
\else     
  \let\real:par|=\par  \def\eq:par{\par\real:par}
  \def\:clearpage{\expandafter\ifx\eq:par\clearpage\fi}
\fi
>>>

In LaTeX, \''\clearpage' embeds a \''\newpage', which in turns
embeds a \''\par'.  The \''\EndPage', in turn, embeddes a
\''\:clearpage' which may cause a problem in places that
\''\par' might be a problem.  Such is the case, for instance,
within \''\halign', where \''\par' has a different meaning
and may cause an infinite loop.  The \''\footnote' produces
this bad situation.


\<general utilities\><<<
|<latex /special sol|>
>>>

\Verbatim
 ---------ok------------------faulty--------------------ok-----------
|                      |                      |                      |   
|                      | \documentstyle{book} | \documentstyle{book} |
|                      | \begin{document}     | \begin{document}     |
| aaaaa                | aaaaa                | aaaaa                |
| \special{t4ht>bbbbb} | \special{t4ht>bbbbb} | \special{t4ht>bbbbb} |
| ccccc                | ccccc                | ccccc                |
| \vfil\penalty-20000  | \vfil\penalty-20000  | \vfil\penalty-10000  |
| ddddd                | ddddd                | ddddd                |
| \end                 | \end{document}       | \end{document}       |
|                      |                      |                      |
 -------------------------------------------------------------------- 
\EndVerbatim



\Verbatim
 --------------------ok-------------------------------faulty------------------
|                                      |\documentstyle{book}                  |
|                                      |\begin{document}                      |
|\leavevmode x\vfil   \penalty-10000   |\leavevmode x\vfil   \penalty-10000   |
|\leavevmode y\mark{\gdef\noexpand\z{}}|\leavevmode y\mark{\gdef\noexpand\z{}}|
|\end                                  |\end{document}                        |
 -----------------------------------------------------------------------------

 -------------ok-----------------------faulty--------------
|                            |  \documentstyle{book}       |   
|                            |  \begin{document}           |   
| y                          |  y                          |   
| \mark{\gdef\noexpand\zz{}} |  \mark{\gdef\noexpand\zz{}} |   
| \end                       |  \end{document}             |   
 ----------------------------------------------------------
\EndVerbatim

\SubSection{Other}

\<general utilities\><<<
\ifx \folio\:UnDef
   \def\folio{\ifx \pageno\:UnDef \z@ \else 
      \ifnum \pageno <0 \romannumeral -\pageno 
      \else             \the           \pageno \fi\fi}
\fi
>>>



%%%%%%%%%%%%%%%%%%%%%%%%%%
\Chapter{Html Files}
%%%%%%%%%%%%%%%%%%%%%%%%%%

\''\HP:file' was before \''\:tempa', and it got screwed when
\''\PauseHFont' and \''\EndPauseHFont' have been defined 
and introdued to \''\Configure{HtmlPar}'.  The name is probably misused 
at some of its occurences.


\<files\><<<
|<elements for file|>  
\ifHtml |<html file commands|>  \fi
>>>

\Section{Open Files}

The first optional parameter of \`'\FileStream'  goes to the title of
the html file.  For a second parabeter, one should be careful
of not providing an undefined \`'\csname...\endcsname' file name. An
empty second parameter refers to the root file.

\<elements for file\><<<
\ifx \FileStream\:UnDef \else 
   \errmessage{--- TeX4ht error ---
       \noexpand\FileStream is defined outside of TeX4ht}\endinput
\fi
\def\FileStream{\IgnorePar
   \let|<needs preamble|>|=-\futurelet\:temp\F:le}
\def\F:le{\if +\:temp \let|<needs preamble|>|=+\expandafter\Fl:e
   \else \expand:after{\Fl:e-}\fi}
\def\Fl:e#1{\futurelet\:temp\::File}
\def\::File{\ifx [\:temp \expandafter\:File
            \else  \expand:after{\:File[]}\fi }
\def\:File[#1]#2{}
>>>

%%%%%%%%%%%%% WAS if[

\<html file commands\><<<
\def\:File[#1]#2{%
   \no:pic\edef\file:name{#2}\yes:pic
   \expandafter\ifx\csname 
          |<csname: file name -> file id|>\file:name\endcsname\relax
                |<open html file name|>%
   \else        |<reopen html file|>%
   \fi}
\HAssign\bs:fileid |= 1
>>>

The definition \`'\edef\file:name{#2}' is needed just in case the
parameter \`'#2' depends on \`'\file:id', because the latter is being
changed within the course of the code.




\<reopen html file\><<<
\xdef\file:id{\csname 
            |<csname: file name -> file id|>\file:name\endcsname}%
\ht:special{t4ht>\ifnum \file:id>\bs:fileid\space \file:name\fi }%
>>>




\<open html file name\><<<
\ht:special{t4ht>\file:name}%            
\immediate\write-1{--- file \file:name\space ---}%
|<round ids before file|>%
\gHAdvance\maxfile:id |by 1
\global\let\file:id|=\maxfile:id 
\Tag{|<auto file tag|>\file:id
   |<Tag/Ref: file-id -> file-name|>}{\file:name}%
\expandafter\xdef\csname 
   |<csname: file name -> file id|>\file:name\endcsname{\file:id}%
|<HPage TITLE|>%
|<remove par skip space|>%
\a:PROLOG \a:HTML \a:HEAD
\ifx +|<needs preamble|>%
   |<initiate frames|>%
   \xdef:cs{|<live|>\file:id}{\noexpand\a:TITLE
      |<noexpanded configured title|>%
      \noexpand\b:TITLE\noexpand\a:@HEAD\noexpand\b:HEAD}%
\else
   \xdef:cs{|<live|>\file:id}{}% 
      \a:TITLE|<configured title|>\b:TITLE \a:@HEAD\b:HEAD\B:DY 
\fi
>>>

\<configured title\><<<
\bgroup \:TITLE: \c:TITLE \egroup
>>>



\<noexpanded configured title\><<<
\bgroup \noexpand\:TITLE: \noexpand\c:TITLE \egroup
>>>


\<remove par skip space\><<<
\ht:special{t4ht@[}{\ht:everypar{}\leavevmode}\ht:special{t4ht@]}%      
>>>




Titles need to be evaluated immediately to capture meanings that come
from sectioning commands, where the latter may include macro names
taht can change in time.


The following should appear before \''\Preamble'.

\<first pass\><<<
\NewConfigure{HTML}[2]{\c:def\a:HTML{#1}\c:def\b:HTML{#2}}
\NewConfigure{HEAD}[2]{\c:def\a:HEAD{#1}\c:def\b:HEAD{#2}}
\NewConfigure{BODY}[2]{\c:def\a:BODY{#1}%
   \c:def\b:BODY{\csname a:@/BODY\endcsname#2}}
\NewConfigure{TITLE}[2]{\c:def\a:TITLE{#1}\c:def\b:TITLE{#2}}
\NewConfigure{TITLE+}[1]{\c:def\c:TITLE{#1}}
\NewConfigure{@TITLE}[1]{\concat:config\:TITLE:{#1}}
\NewConfigure{@HEAD}[1]{\concat:config\a:@HEAD{#1}}
\let\a:@HEAD|=\relax
>>>

\<concat config\><<<
\long\def\concat:config#1#2{\def\:temp{#2}%
   \ifx \:temp\empty  \let#1|=\empty
   \else \ifx #1\relax  \let#1|=\empty\fi
       \append:def#1{#2}\fi
}
>>>

\''\Configure{@HEAD}{}' empties the content.
\''\Configure{@HEAD}{...}'  appends the content.

Same for the following

\<first pass\><<<
\NewConfigure{@BODY}[1]{\concat:config\a:@BODY{#1}}
\let\a:@BODY\relax
\NewConfigure{@/BODY}[1]{\expandafter
   \concat:config\csname a:@/BODY\endcsname{#1}}
\expandafter\let\csname a:@/BODY\endcsname\relax
>>>

Why the \''\noexpand' above. Put a \`'\special' instead.

\<utilities\><<<
\:CheckOption{hshow} \if:Option 
   \def\hshow#1{\writesixteen
     {..#1.......\expandafter\meaning\csname #1\endcsname}}
   |<Show Configure|>
\fi
>>>

\<Show Configure\><<<
\def\ShowConfigure#1{%
   \edef\:tempb{\expandafter \meaning\csname c:#1:\endcsname}%
   \expandafter\par:N  \:tempb////%
   \writesixteen{\string\Configure{#1}}%
   {\show:Arg{1}{a:#1}%
   \show:Arg{2}{b:#1}%
   \show:Arg{3}{c:#1}%
   \show:Arg{4}{d:#1}%
   \show:Arg{5}{e:#1}%
   \show:Arg{6}{f:#1}%
   \show:Arg{7}{g:#1}%
   \show:Arg{8}{h:#1}%
   \show:Arg{9}{i:#1}}%
}
\edef\:temp{\def\noexpand
  \par:N##1\string :##2->##3////{\noexpand\par:NN?##2//}}
\:temp
\def\par:NN#1#2//{\def\:tempb{#2}\ifx\:tempb\empty
  \def\:tempb{#1}\else \def\:tempb{\par:NN#2//}\expandafter\:tempb\fi}
\def\show:Arg#1#2{%
   \ifnum \:tempb=#1 \let\show:Arg=\:gobbleII \fi
   \expandafter\let\expandafter\:temp \csname #2\endcsname
   \writesixteen{ {\ifx \:temp\relax ???\else
      \expandafter\:gobbleM \meaning \:temp\fi}}}
\def\:gobbleM#1->{}
>>>






The following tag is for recording files that are still alive, and for
keeping a status location for HEAD/FRAMESET/BODY  entity types.

\<live\><<<
Lv >>>



\Section{Close Files}

\<html file commands\><<<
\def\EndFileStream#1{%
   \expandafter\ifx
            \csname |<csname: file name -> file id|>#1\endcsname\relax
      \:warning{\string\EndFileStream{#1}?}%
   \else
      \ifnum\csname |<csname: file name -> file id|>#1\endcsname=\bs:fileid
         \:warning{\string\EndFileStream{\jobname .\:html}?}%
      \else \expandafter\ifnum  |<file not overided by /ChildOf|>%
         |<close html file name|>%
   \fi\fi\fi }
>>>

Note thta \`'\EndFileStream' might get fake calls due to end of HPages. Hence,
\`'\RecallEverypar' should be invoked only when real HPageas are closed.
Well, we can't put          \''\SaveEverypar' and
         \''\RecallEverypar' in \''\FileStream' and \''\EndFileStream'
because they are not structured.  We can reopen and close files randomly.


 An extra empty line at end of file (for some reason,  some settings
of emacs prompt the user for such a line). 

\<close html file name\><<<
{\let\inputlineno|=\tmp:cnt \tmp:cnt|=1   \root:next }% 
|<end body and frames|>%
\ht:special{t4ht<#1}%
\g:delete{\empty |<csname: file name -> file id|>#1}%
|<round ids after file|>%
>>>

Why the \''\edef' above


Upon closing a file with \`\special{t4ht<#1}', the program
\`'tex4ht.c' moves to the youngest file that is still openned.

\<close html file name\><<<
\expandafter\expandafter\expandafter\global \expandafter
                     \let\csname  |<live|>\file:id\endcsname|=\:UnDef
\global\let\file:id|=\maxfile:id 
\find:fileid
>>>

\<html file commands\><<<
\def\find:fileid{%
  \expandafter\ifx \csname  |<live|>\file:id\endcsname \relax
      \gHAdvance\file:id |by -1  \expandafter\find:fileid
  \fi
}
>>>



\Section{Cross References}




The commands referencing files are defined for use also within
restricted  environments (\`'\edef', \`'\write').  

\<html file commands\><<<
\def\TagFile#1{%
   \expandafter\ifx \csname
         |<tag of Tag|>|<file name for TagFile|>\endcsname \relax \else
      \Tag{#1|<File tag|>}{\LikeRef{|<file name for TagFile|>}}%
   \fi
}
\def\RefFile#1{\LikeRef{#1|<File tag|>}}
\def\FileName{\LikeRef
   {|<auto file tag|>\file:id |<Tag/Ref: file-id -> file-name|>}}
>>>





\<file name for TagFile\><<<
|<auto file tag|>\file:id |<Tag/Ref: file-id -> file-name|>%
>>>


\`'\def\RefFile#1{\Ref{#1|<File tag|>}}
\def\LikeRefFile#1{\LikeRef{#1|<File tag|>}}'

\<html file commands\><<<
\def\RefFileNumber#1{%
   \expandafter\ifx  \csname
         |<tag of Tag|>|<auto file tag|>#1%
                  |<Tag/Ref: file-id -> file-name|>\endcsname\relax 
   \else
      \:LikeRef{|<auto file tag|>#1|<Tag/Ref: file-id -> file-name|>}%
   \fi  }
>>>


\Verbatim

 > Why is it that during the first run, \file:name returns the correct 
 > filename, but \FileName returns a blank? 

\file:name doesn't always return the correct 

    \documentclass{article}
    \begin{document}
    
    \writesixteen
       {\csname file:name\endcsname...\csname FileName\endcsname}
    
    \end{document}

 > Is this a bug or a feature?

\FileName gets its information through the xref file from the previous
compilation, in a similar manner that \ref gets its information from
\name in latex. The indirection is needed to allow communication
between different files that are to be compiled into a joint html
output. It was introduced at a time that I and others had no access to
large latex compilers, forcing the break up of large source (eg,
books) into smaller files. 
\EndVerbatim



\Section{Root File}

\<html file commands\><<<
\xdef:cs{\empty |<csname: file name -> file id|>\jobname .\:html}{\file:id}
\xdef:cs{\empty |<csname: file name -> file id|>}{\file:id}
\Tag{|<auto file tag|>\file:id 
                |<Tag/Ref: file-id -> file-name|>}{\jobname .\:html}
\bgroup
  |<protect from /special redef|>%
  \xdef:cs{|<live|>\file:id}{\noexpand\a:TITLE
     |<noexpanded configured title|>%     
     \noexpand\b:TITLE \noexpand\a:@HEAD\noexpand\b:HEAD}%
\egroup
>>>




\Section{Document Head}

\<start html doc\><<<
\:startdoc  
>>>



\<at doc start\><<<
\def\at:startdoc{%
    \let\:startdoc|=\:UnDef    \let\at:startdoc|=\:UnDef
    |<activate html env|>%
    \a:Preamble
    |<start html file|>}
\def\:startdoc{%
    \at:startdoc
    \edef\:temp{\pageno|=\the\pageno}%
    {\let\HCode|=\:gobble \par\newpage}\:temp}
>>>

The \''\let\HCode=\:gobble' is to prevent \`'<BR>' from 
\''\line' activated by \'sty' and called upon from
a user-designed \''\output' routines taht have not been 
adjusted yet for haeders and footers.




> The following is to ensure that no shipout of content is done before
> the header is out.

Update 2020: patching of shipout is discouraged in LaTeX. I don't know what
use case the following code has, but it seems that TeX4ht can safelly work 
without it. We can introduce it back in the case of problems. -- Michal

\<start html doc\><<<
%\let\:shipout|=\shipout
%\def\shipout{\vfil\break\let\shipout|=\:shipout \shipout}
>>>



\<start html file\><<<
\a:PROLOG \a:HTML \a:HEAD
|<initiate frames|>%
>>>

The following empty line is to avoid lines that are too long 
in the style file.

The following is for the root file, and it can be overriden
by definitions before  \''\EndPreamble'.



\<concat config\><<<
\def\:prolog#1#2,#3|<par del|>{%
   \if ,#2,\else
      \edef\:tempc{\if*#2\fi}%
      \ifx \:tempc\empty
         \expandafter\append:def
            \csname a:#1\endcsname{\csname a:#2\endcsname}%
         \expandafter\ifx \csname c:#2:\endcsname\relax
            \NewConfigure{#2}{1}%
         \fi
      \else
         \expand:after{\pro:log{#1}}\expandafter{\:tempc}%         
   \fi\fi
   \if ,#3,\else \expand:after{\:prolog{#1}#3|<par del|>}\fi
}
\def\pro:log#1#2{%
   \expandafter\append:def
       \csname a:#1\endcsname{\csname a:#2\endcsname}%
   \expandafter\ifx \csname c:#2:\endcsname\relax
       \NewConfigure{#2}[1]{\expandafter
            \concat:config\csname a:#2\endcsname{##1}}%
       \expandafter\let\csname a:#2\endcsname\relax
   \fi
}
\def\seq:config#1#2{%
   \expandafter\let\csname a:#1\endcsname=\empty
   \:prolog {#1}#2,|<par del|>}
>>>

The \''\seq:config' is for introducing a sequence of hooks,
where a star `*' before the hook name indicates it is to be 
of accumulative kind.

\<define /Preamble\><<<
\NewConfigure{PROLOG}[1]{\seq:config{PROLOG}{#1}}
>>>


\<html Configure's\><<<
\def\Goto:Configure{\long\def
   \Goto:Configure##1\:Configure{\let\Goto:Configure
              |=\:UnDef}\expandafter\Goto:Configure}
|<trace configurations|>
|<html config util|>
|<shared config|>
|<font config util|>
|<accents|>
|<math config util|>
>>>











\Section{Document Tail}



\<TeX4ht hook on end\><<<
\expand:after{\let\o:end|=}\csname end\endcsname
\expandafter\def\csname end\endcsname{%
   \csname export:hook\endcsname  \csname o:end\endcsname}
>>>

This is not used, enddocument hook for LaTeX is defined in latex.4ht.

\<latex hook on end\><<<
\let\o:enddocumenthook|=\@enddocumenthook
\def\@enddocumenthook{%
   \o:enddocumenthook   \csname export:hook\endcsname  }
>>>





\<hook on end\><<<
\def\at:docend{|<close html doc|>\global\let\at:docend=\empty}
\expand:after{\let\o:end|=}\csname end\endcsname
\expandafter\def\csname end\endcsname{\HtmlEnv
   \at:docend
   \csname export:hook\endcsname   \csname o:end\endcsname}
>>>


\<close html doc\><<<
|<close HPages in @end|>% 
\HAssign\op:fl|=\maxfile:id\space  \close:files  
|<buttons at end of child|>% 
|<end body and frames|>%
>>>



\<end body and frames\><<<
{\b:BODY \b:HTML}%
>>>


\<html file commands\><<<
\def\close:files{%
   \ifnum \op:fl<\bs:fileid \else
      \def\:warning##1{}%
      \EndFileStream{\RefFileNumber\op:fl}%
      \Advance:\op:fl |by -1
      \expandafter\close:files
   \fi}
>>>


\Chapter{HPages and Cut Points}



\<cut points\><<<
|<elements for cut points|>
\ifHtml  |<html cut points|>
       |<tex html cut points|>
\fi
>>>

\Section{HPages}


\`'\HPage<block name>[tag]{title} ... \EndHPage{block name}'

\List{$\button$}

\item The \`'block name' is optional in \''\EndHPage', and it serves
for balancing delimiters of blocks.   

If included, it is compared against \`'block name' and \`'tag'
in the given order until a non-empty entity is encountered. 
All the compared entities must be fully-expandable (i.e., edef).
(Note that for \`'[]', title is the tag.)

\item The \`'[tag]' is used for \`'\RefFile', and it is optional. 
An empty tag asks that the title will serve as a tag.

\item The \`'{title}' is used for a HPage. If empty, the HPage is omitted.

\EndList

\`'\HPage<block name>-[tag]title\ContHPage ... \EndHPage{block
name}'

A variant of the above in which tag must be non-empty if \`'[tag]' is
present, and \`'title' need not be expandable. Also, either \`'block
name' or \`'tag' must be present, if \`'\EndHPage{...}' has a
non-empty parameter.


\<html cut points\><<<
\def\HPage{\strt:bt\ch:HPage}
\def\ch:HPage{%
   \ifx -\:temp \expandafter\m:HPage
   \else \expand:after{\ifx [\:temp \expandafter\op:HPage 
                       \else        \expandafter\:HPage   \fi}%
   \fi}
>>>

\<html cut points\><<<
\def\strt:bt#1{%
   \def\:bgtr<##1>{|<page-name is a file name?|>%
      |<push name if not HPageButton|>%
      \futurelet\:temp#1}%
   \futurelet\:temp\ch:btgr}
\def\ch:btgr{\ifx  <\:temp  \expandafter\:bgtr
             \else          \expand:after{\:bgtr<>}\fi}%
>>>


\<push name if not HPageButton\><<<
\ifx #1\ch:bbtf \else \PushStack\:btid{##1}\fi
>>>

\<html cut points\><<<
\def\HP:Link{\Link[\HP:file
   \a:LinkHPage]{}{\HP:file}\global\let\a:LinkHPage|=\empty}
\NewConfigure{LinkHPage}[1]{\def\a:LinkHPage{ #1}}
\let\a:LinkHPage=\empty
\def\op:HPage[#1]#2{%
   |<entring file of hpage|>%
   \:hookI{BeforeHPageButton}{}{#2}%
   \hpg:wrn{#1}{#2}\HPage    \TagFile{|<fr bt fl|>\:temp}%
                             \Save:HPageTag\:temp
                             \Save:HPage{#2}%
   \NewFileName\HP:file   \Save:Link\HP:file  
   \if:notempty{#2}{\HP:Link#2\EndLink}%
   \:hookI{AfterHPageButton}{}{#2}%
   \:btfile{#2}%
   \:buttrc\HPage{[#1]{#2}}%
   \PushStack\:afterbt{x}%
   |<:temp = but name|>%
   \TagFile{\:temp}}
\def\:HPage#1{%
   |<entring file of hpage|>%
  \:hookI{BeforeHPageButton}{}{#1}%
   \NewFileName\HP:file   \Save:Link\HP:file  \Save:Temp\HP:file
                      \TagFile{|<fr bt fl|>\HP:file}%
                             \Save:HPageTag\HP:file
                             \Save:HPage{#1}%
   \def\:temp{#1}\ifx \:temp\empty
   \else \HP:Link#1\EndLink 
   \fi
   \:hookI{AfterHPageButton}{}{#1}%
   \:btfile{#1}%
   \:buttrc\HPage{{#1}}%
   \PushStack\:afterbt{x}%
   \Recall:Temp\:tempa    \TagFile{\:tempa}}
>>>


\<html cut points\><<<
\def\hpg:wrn#1#2#3{%
   |<:temp = but name|>%
   \ifx \:temp\empty \:warning{\string#3[]{}?}\fi}
>>>


\<:temp = but name\><<<
\edef\:temp{#1}\ifx \:temp\empty \no:pic
       \edef\:temp{\noexpand\yes:pic
           \def\noexpand\:temp{#2}}\:temp \fi
>>>


\<html cut points\><<<
\def\Save:Temp{\PushStack\sv:Temp}
\def\Recall:Temp{\PopStack\sv:Temp}
>>>

Can't go for \`' \def\:temp{#1}' because \`'#1' is just a title and
not a tag.


\<html cut points\><<<
\def\m:HPage#1{\futurelet\:temp\ch:mbut}
\def\ch:mbut{\ifx [\:temp \expandafter\op:mbut
             \else        \expandafter\:mbut   \fi}
\def\op:mbut[#1]{%
   |<entring file of hpage|>%
  \:hookI{BeforeHPageButton}{}{}%
   \edef\:temp{#1}%
   \ifx \:temp\empty \:warning{\string\HPage-[]?}\fi
                      \TagFile{|<fr bt fl|>\:temp}%
                             \Save:HPageTag\:temp
                             \Save:HPage{}%
   \NewFileName\HP:file   \Save:Link\HP:file  
   \HP:Link%
   \def\ContHPage{\:ContHPage{x}{#1}}}
\def\:mbut{%
   |<entring file of hpage|>%
    \:hookI{BeforeHPageButton}{}{}%
   \NewFileName\HP:file   \Save:Link\HP:file  
                      \TagFile{|<fr bt fl|>\HP:file}%
                             \Save:HPageTag\HP:file
                             \Save:HPage{}%
   \HP:Link%
   \def\ContHPage{\:ContHPage{x}{\HP:file}}}
\def\:ContHPage#1#2{\EndLink  
   \Recall:Link\HP:file  \Save:Link\HP:file
   \:hookI{AfterHPageButton}{}{}%
   \:btfile{}%
   \:buttrc\HPage{...\string\ContHPage}%
   \PushStack\:afterbt{#1}%
   \TagFile{#2}}
>>>


\<html cut points\><<<
\def\:hookI#1#2#3{%
   \expandafter\ifx \csname #1\endcsname\relax  #2\else
      \csname #1\endcsname{#3}\fi
}
>>>

\<html cut points\><<<
\def\NewFileName#1{%
   \HAssign#1|=\maxfile:id
   \Advance:#1 |by 1
   \ifx \:NxtNwFN\:Undef
      \edef#1{\j:bname \ifx \big:fn\:UnDef|<tail for file name|>#1%
                    \else \big:fn\fi  .\:html}%
   \else  \let#1|=\:NxtNwFN  \global\let\:NxtNwFN|=\:UnDef  \fi
   \global\let\big:fn|=\:UnDef
}
\def\NextFile#1{\xdef\:NxtNwFN{#1}}
>>>




\<html cut points\><<<
\def\:btfile#1{%
   \SaveEverypar \FileStream[#1]{\HP:file}  \IgnorePar
   \gHAdvance\HPageDepth |by 1
   \AtEndHPage{\csname HPageFooter\endcsname}%
   \:hookI{HPageHeader}{}{#1}%
}
>>>





\SubSection{Specification Separated from Realization}

Split HPages must appear with reference keys (brackets).




\<html cut points\><<<
\def\HPageButton{\strt:bt\ch:bbtf}
\def\ch:bbtf{\ifx -\:temp \expandafter\op:bbft
             \else \expandafter\:bbtf \fi}
\def\:bbtf[#1]#2{%
   \:hookI{BeforeHPageButton}{}{#2}%
   \hpg:wrn{#1}{#2}\HPageButton
   \TagFile{|<fr bt fl|>\:temp}%
   \edef\HP:file{\RefFile\:temp}%
   \def\:temp{#2}\ifx \:temp\empty 
   \else  \HP:Link#2\EndLink  \fi
   \:hookI{AfterHPageButton}{}{#2}%
   \csname AfterHPage\endcsname  }

\def\op:bbft#1[#2]{%
   \:hookI{BeforeHPageButton}{}{}%
   \edef\:temp{#2}%
   \ifx \:temp\empty \:warning{\string\HPageButton-[]?}\fi
   \TagFile{|<fr bt fl|>\:temp}%
   \edef\HP:file{\RefFile\:temp}%
   \HP:Link%
   \def\ContHPage{\EndLink
      \:hookI{AfterHPageButton}{}{}%
      \csname AfterHPage\endcsname  }}
>>>


\<html cut points\><<<
\def\BeginHPage{\futurelet\:temp\ch:bbbt}
\def\ch:bbbt{%
   |<entring file of hpage|>%
   \NewFileName\HP:file   \Save:Link\HP:file 
   \ifx -\:temp  \expandafter\op:bbbt
   \else         \expandafter\:bbbt   \fi}
\def\:bbbt[#1]#2{%
   \PushStack\:btid{#1}%                      |%aug 2003|%
   \:btfile{#2}%
   \:buttrc\BeginHPage{[#1]{#2}}%
   \PushStack\:afterbt\empty 
   \hpg:wrn{#1}{#2}\BeginHPage    \Save:HPageTag\:temp
   \Save:HPage{#2}%
   \TagFile{\:temp}}
\def\op:bbbt#1[#2]{%
   \PushStack\:btid{#2}%                     |%aug 2003|%
   \:hookI{AfterHPageButton}{}{}%
   \:btfile{}%
   \:buttrc\BeginHPage{[#2]}%
   \PushStack\:afterbt\empty    \edef\:temp{#2}%
   \ifx \:temp\empty \:warning{\string\BeginHPage-[]?}\fi
   \Save:HPageTag\:temp   \Save:HPage{}%
   \TagFile{\:temp}}
>>>





\SubSection{End HPage}

\`'\EndHPage[level]{bloc name}'

\List{$\bullet$}

\item \`'[level]' is optional. If present, all HPages, up to the
specified level, are closed.

\item \`'block name'. If empty, a single HPage is closed. If
non-empty, all HPages up-and-including the one with the given name
are closed.

\EndList

\<html cut points\><<<
\def\EndHPage{\futurelet\:temp\chEnd:HPage}
\def\chEnd:HPage{\ifx  [\:temp  \expandafter\opEnd:HPage
              \else          \expandafter\End:HPage   \fi}
\def\opEnd:HPage[#1]{%
   \ifnum  #1>\HPageDepth\space
      \:warning{\string\EndHPage[#1]?}%
      \let\:temp|=\:gobble 
   \else \ifnum  #1<\HPageDepth\space
      \def\:temp{\:EndHPage\EndHPage[#1]{}}%
   \else \let\:temp|=\End:HPage \fi \fi
   \:temp }

\def\End:HPage#1{%
   \ifnum \HPageDepth<1 \:warning{\string\EndHPage{#1}?}\let\:temp|=\:gobble
   \else  \ifinner\else\:clearpage\fi   \PopStack\:btid\:tempa
      \def\:tempb{#1}\ifx  \:tempb\empty\let\:temp|=\:EndHPage
      \else  \ifx  \:tempb\:tempa       \let\:temp|=\:EndHPage
      \else  \Recall:HPageTag\:tempa
             \Save:HPageTag\:tempa
             \ifx  \:tempb\:tempa       \let\:temp|=\:EndHPage
      \else                    \def\:temp{\:EndHPage\End:HPage{#1}}%
   \fi\fi\fi\fi
   \:temp }

\def\:EndHPage{%
   \csname EndHPage\HPageDepth \endcsname
   \global\expandafter\let\csname EndHPage\HPageDepth\endcsname|=\:UnDef
   \Recall:Link\HP:file   \Recall:Link\:tempd   \Save:Link\:tempd
   \Recall:HPage\:tempb
   \Recall:HPageTag\:tempc
   \:buttrc\EndHPage{{\:tempb}}%
   \EndFileStream{\HP:file}%
   |<leaving actual file of hpage|>%
   \FileStream{\:tempd}%
   \RecallEverypar  \gHAdvance\HPageDepth |by -1
   \PopStack\:afterbt\:temp 
   \ifx \:temp\empty \else \csname AfterHPage\endcsname \fi }
>>>


Overrides earlier defs, including the default.


\<html cut points\><<<
\def\AtEndHPage{%
   \expandafter\gdef\csname EndHPage\HPageDepth\endcsname}     
>>>


\<html cut points\><<<
\HAssign\HPageDepth|=0 
\PushStack\:btid{}
>>>

%\NewStack\:btid

\<close HPages in @end\><<<
\ifnum \HPageDepth> 0 \EndHPage[1]{}\fi
|<document end for non-cut logical units|>%
>>>


\SubSection{Debugging}

\<html cut points\><<<
\def\Save:FileHPg{\PushStack\HPage:FlHg}
\def\Recall:FileHPg{\PopStack\HPage:FlHg}
>>>

The \''\Recall:FileHPg'  and \''Recall:Link' should give the
same file if HPages are not stored in files, and when the files are
not remote. CHECK!!! 


The following works with the actual files containing the
hpages, instead of assuming that the files are of their parent
hpages.


\<leaving actual file of hpage\><<<
%\Recall:FileHPg\:tempd
>>>

\''HPage''s are not natural children of \''\FileStream': 
\''\EndHPage' don't touches pages, \''\FileStream' 
has no button name, \''\ExitHPage' might not work, etc (Recall that
HPages must be consistent in seperated form of \''\HPageButton' with
\''\beginHPage' and unified form of \''\HPage'.)


\<entring file of hpage\><<<
%\chk:hpfl
>>>

\<html cut points\><<<
\def\chk:hpfl{\Save:FileHPg\FileName \:FlHpg}
\def\No:FlHpg{{\Recall:Link\HP:file  \Save:Link\HP:file
   \edef\HP:file{\HP:file}\edef\FileName{\FileName}%
   \edef\HP:file{\expandafter\string\csname \HP:file\endcsname}%
   \edef\FileName{\expandafter\string\csname \FileName\endcsname}%
   \ifx \HP:file\FileName \else 
      \:warning{HPage in a non-HPage file 
                          `\expandafter\:gobble\FileName'}%
   \fi}}
\def\HPageInFile{\global\let\:FlHpg|=\empty}
\def\NoHPageInFile{\global\let\:FlHpg|=\No:FlHpg}
\NoHPageInFile
>>>



Had \`'\yes:trc' and changed to \`'\yes:pic' without checking what  I'm doing.

\<html debug\><<<
\def\HTraceHPageOn{%
   \def\:buttrc##1##2{\no:pic  \writesixteen{%
       l.\the\inputlineno -[\HPageDepth]- \string##1##2}\yes:pic
   }}
\def\HTraceHPageOff{\def\:buttrc##1##2{}}
\HTraceHPageOn
>>>



\<no debug\><<<
\def\:buttrc#1#2{}
\let\HTraceHPageOn|=\empty
\let\HTraceHPageOff|=\empty
>>>

\SubSection{Utilities}



\<page-name is a file name?\><<<
\expand:after{\bt:fn##1.}\:html|<par del|>%
>>>

\<html cut points\><<<
\expand:after{\def\bt:fn##1.}\:html#2|<par del|>{%
   \def\:temp{#2}\ifx \:temp\empty 
   \else \NextFile{#1.\:html}\fi }
>>>


\`'\ExitHPage[mark]{title}'. The bracket mark is optional and
it is introduced for marking the HPage with an NAME.  If
\`'\HPageButton'-\`'\BeginHPage' combination wouldn't have existed we
could have used simpler code of the form \`'\Recall:Link\HP:file
   \Recall:Link\:tempb \Save:Link\:tempb \Save:Link\HP:file
   \Link[\:tempb]{\HP:file}{#1}#2\EndLink'.
An empty title creates a default \`'exit <file title>'. 


 Whenever we have cross-references in a html file (might be
also indirect through a child) we want an exit HPage to save an
annoying backtract through the visited path.

\<html cut points\><<<
\Odef\ExitHPage[#1]#2{%
   \Recall:HPageTag\HP:file  \Save:HPageTag\HP:file
   \Link[\RefFile{|<fr bt fl|>\HP:file}]{\RefFile{\HP:file}}{#1}%
      \def\:temp{#2}\ifx \:temp\empty 
         \Recall:HPage\:temp  \Save:HPage\:temp
         \ifx \:temp\empty \a:ExitHPage
         \else \b:ExitHPage \:temp \c:ExitHPage \fi
      \else #2\fi
   \EndLink 
}
>>>

\<shared config\><<<
\NewConfigure{ExitHPage}{3}
>>>




\<fr bt fl\><<<
)B>>>


\`'\RefHPage' can be used for the filename and HPage location.

\<html cut points\><<<
\def\RefHPage{\RefFile}
>>>

\<html cut points\><<<
\def\Save:Link{\PushStack\HPageFiles}
\def\Recall:Link{\PopStack\HPageFiles}
\Save:Link{\jobname.\:html}
\def\Save:HPage{\PushStack\HPageAnchors}
\def\Recall:HPage{\PopStack\HPageAnchors}
\def\Save:HPageTag{\PushStack\HPage:Tags}
\def\Recall:HPageTag{\PopStack\HPage:Tags}
>>>

%\NewStack\HPageFiles
%\NewStack\HPageAnchors
%\NewStack\HPage:Tags

%\NewStack\:afterbt


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Requests for Cutpoints}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Requests are made with commands of the form
\`'\CutAt{division,terminators,...}'.  A \`'division' that precedes
with a \`'+' asks that the HPage will be visible.

\<html cut points\><<<
\def\CutAt#1{%
  \if           +\:firstch#1 //\:CutAt#1,//\else 
  \if |<- TITLE|>\:firstch#1 //\:CutAt#1,//\else             
                               \:CutAt=#1,//\fi\fi
}
>>>


\<html cut points\><<<
\def\PauseCutAt#1{%
   \expandafter\ifx\csname Cut:#1\endcsname\relax\else
      \expandafter\ifx  \csname NoCut:#1\endcsname\relax
          \expand:after{\expandafter\let\csname NoCut:#1\endcsname=}%
             \csname Cut:#1\endcsname
      \fi
      |<paused cut at|>%
    \fi  }
\def\ContCutAt#1{%
   \expandafter\ifx  \csname NoCut:#1\endcsname\relax\else
       \expand:after{\expandafter\let\csname Cut:#1\endcsname=}%
          \csname NoCut:#1\endcsname
      \expandafter\let\csname Toc:#1\expandafter\endcsname\csname OToc:#1\endcsname
   \fi}
>>>

e.g., \''PauseCutAt{section}'

\<paused cut at\><<<
\expandafter\let\csname OToc:#1\expandafter\endcsname\csname Toc:#1\endcsname
\expandafter\let\csname Toc:#1\endcsname=\relax
\expandafter\let\csname Cut:#1\endcsname=\null 
\expandafter\def\csname Cut:#1\endcsname{%   
   \gHAdvance \TitleCount  1 
   \null \:gobble
}%
>>>


%   \expandafter\global \expandafter
%                   \let\csname #1:Count\endcsname\TitleCount




Intuitively, a conditional  command  \`'\UnCut:division' is prepended to
\`'\division' and  \`'\terminator'. When defined, it has the meaning 
of a EndHPage.  Hence, implicity we have also a terminator at the end
of the document.

The new commands are executed only if they are defined. The
\`'\Cut:division' is  defined by \`'\CutAt',
the \`'\UnCut:division' is defined by \`'\Cut:division', and
\`'\UnCut:division' undefines \`'\UnCut:division'. The hook for
\`'Cut:division' is introduced in 
\LinkPort\<button for cut at sect\>{\tt<button for cut at sect>}\EndLink.


\<html cut points\><<<
\def\:CutAt#1#2,#3//{%
   \csname ltx:like\endcsname 
   \expandafter\ifx  \csname #2\endcsname \relax
      \:warning{\string\CutAt\space at undefined
                    `\expandafter\string\csname#2\endcsname'}%
   \fi
   \csname ltx:nolike\endcsname 
   |<modify current command|>%
   |<notify current division to higher ones in the hierarchy|>%
   |<overide default: open new file for current division|>%
}
>>>

\<shared config\><<<
\NewConfigure{UndefinedSec}[1]{%
   \ifx \ltx:like\:UnDef  \let\ltx:like|=\empty \let\ltx:nolike|=\empty \fi
   \append:def\ltx:like{\expandafter\let\csname #1\endcsname|=\empty}%
   \append:def\ltx:nolike{\expandafter\let\csname #1\endcsname|=\:UnDef}%
}
>>>

\<modify current command\><<<
\expandafter\ifx \csname #2:\endcsname\relax
   \expand:after{\expandafter\let \csname #2:\endcsname |=}%
                                  \csname #2\endcsname
\else \:warning{Again \string\CutAt{#2}?}%
\fi
\expandafter\def \csname #2\endcsname{%
   \csname UnCut:#2\endcsname
   \csname #2:\endcsname}%
>>>

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\SubSection{Connection to Super Divisions}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\<notify current division to higher ones in the hierarchy\><<<
\:UnCutAt#2,#3,//%
>>>

\<html cut points\><<<
\def\:UnCutAt#1,#2,#3//{%
   \def\:temp{#2}\ifx \:temp\empty \else
      \def\:tempa{#1}\ifx \:tempa\:temp  \else
         \expandafter\ifx \csname#2:#1\endcsname\relax 
            |<uncut @1 at @2|>%
         \else \:warning{#2 already assumed in \string\CutAt{#1,...}}\fi 
      \fi
      \def\:temp{\:UnCutAt#1,#3//}%
      \expandafter\:temp
   \fi
}
>>>


\<uncut @1 at @2\><<<
\expand:after{\expandafter\let \csname #2:#1\endcsname |=}%
                                      \csname #2\endcsname
\expandafter\def \csname #2\endcsname{%
   \csname UnCut:#1\endcsname
   \csname #2:#1\endcsname}%
>>>

%%%%%%%%%%%%%%%%%%%%
\SubSection{HPages}
%%%%%%%%%%%%%%%%%%%%

\<overide default: open new file for current division\><<<
\expandafter\edef \csname Cut:#2\endcsname##1{%
     \noexpand\cut:at{#2}{##1}#1}%
>>>

\<html cut points\><<<
\def\cut:at#1#2#3{{%
   |<HPages for sec|>%
   |<large file name for @2|>%
   \if #3+\HPage<#1>{#2}%
   \else  
      |<CutAt TITLE|>%
      \HPage<#1>{}\fi
   \ifx \prevCutAt\empty  \else \TagFile{|<nxt but file|>\lastsec:id}\fi
   \AtEndHPage{|<prev/next at end of hpage|>\UnCut:{#1}}%
   \expandafter\xdef\csname UnCut:#1\endcsname{%
                                 \noexpand\EndHPage[\HPageDepth]{}}%
}}
\HAssign\lastsec:id|=0 
\def\cut:TTL#1{#1}
>>>




The following is for cut pages (typically, from sectioning commands).

\<CutAt TITLE\><<<
\if #3|<- TITLE|>\else
   \let\cut:TTL|=\:gobble 
   \begingroup
     \csname no:fonts\endcsname|<TITLE env|>\:CutAtTITLE:
     \xdef\:temp{\noexpand\Configure{TITLE+}{\a:CutAtTITLE{#2}}}%
   \endgroup \:temp
\fi
>>>

\<HPage TITLE\><<<
\no:pic
\edef\:temp{\noexpand\yes:pic \def\noexpand\:temp{#1}}\:temp
\begingroup
  |<TITLE env|>\:HPageTITLE:
  \no:pic
  \edef\:tempa{\noexpand\yes:pic \def\noexpand\:tempa{#1}}\:tempa
  \xdef\:temp{\cut:TTL{\noexpand\Configure{TITLE+}{\a:HPageTITLE{\ifx 
   \:temp\empty \file:name\else \:tempa\fi}}}}%
\endgroup \:temp
>>>

\<- TITLE\><<<
->>>

\<TITLE env\><<<
\def\gobble:font##1##2{##2}%
\:TITLE:
>>>

The \''\gobble:font' is to remove the primitive font definitions of latex.

\<html cut points\><<<
\let\:TITLE:|=\empty
\let\:CutAtTITLE:|=\empty
\let\:HPageTITLE:|=\empty
>>>

\<html config util\><<<
\NewConfigure{CutAtTITLE+}[1]{\def\a:CutAtTITLE{#1}}
\NewConfigure{HPageTITLE+}[1]{\def\a:HPageTITLE{#1}}
>>>



%%\NewStack\:head

\<nxt but file\><<<
)N >>>


\<html cut points\><<<
\def\UnCut:#1{%
   |<disable empty delayed toc|>%
   \global\expandafter\let\csname UnCut:#1\endcsname|=\:UnDef
   \xdef\lastsec:id{\file:id}%
   \PopStack\prv:fl\:temp
   \bgroup 
      \ifx\b:crsbt\empty
         \ifx\bb:crsbt\empty\else
            \:hookI{Back#1}{\default:bts{|<tail|>}{|<front|>}}{}%
         \fi
      \else
         \:hookI{Back#1}{\default:bts{|<tail|>}{|<front|>}}{}%
      \fi
      \csname b:CutAt#1\endcsname \let\after:endfl|=\EndFileStream
      \def\EndFileStream##1{\after:endfl{##1}\egroup
                      |<AfterHPage for CutAt|>%
                      |<pop btons|>%
   }}
>>>


We have here \`'\Configure{CutAt#1}{..}{..}' for any sectioning
part.  The sectioning commands of LaTeX have a
\`'\Configure{section-type} {before-section} {after-section}
{before-title}{after-title}' command that calls  
\`'\Configure{CutAt section-type} {before-section} {after-section}'
to insert code at the start and end of the hypertext pages.

On the other hand \`'\Configure{+CutAt}{section-type}{before}{after}'
offers delimiters for the buttons.  The
\`'\NewConfigure{CutAt}[1]{\Configure{CutAt#1}}' can be offered for
consistency. DO WE NEED IT?

\<tail\><<<
tail>>>


\<disable empty delayed toc\><<<
\global\expandafter\let\csname TocAt*\endcsname|=\empty
>>>


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Prev/Next Cut Buttons}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\<AfterHPage for CutAt\><<<
\PopStack\:afterbt\:temp
\ifx\:temp\empty\else\:hookI{After#1}{}{}\fi
\PushStack\:afterbt{}%
>>>

\<HPages for sec\><<<
\def\BeforeHPageButton{\if #3+%
   \def\:temp{\:hookI{Before#1Button}{\csname a:+CutAt#1\endcsname}}%
                              \expandafter\:temp\fi}%
\edef\prev:File{\ifnum \sec:lvl>\HPageDepth\space
                               \RefFileNumber\lastsec:id \fi}%
\def\AfterHPageButton{\if #3+%
   \def\:temp{\:hookI{After#1Button}{\csname b:+CutAt#1\endcsname}}%
                             \expandafter\:temp\fi}%
\def\HPageHeader##1{%
   |<prev/next at start of hpage|>%
   \xdef\nextCutAt{\RefFile{|<nxt but file|>\file:id}}%
   \global\let\prevCutAt|=\prev:File
   |<push HPages|>%
   \PushStack\prv:fl{#3}\csname a:CutAt#1\endcsname
   \ifx\a:crsbt\empty
      \ifx\aa:crsbt\empty\else
         \:hookI{Front#1}{\default:bts{|<front|>}{|<tail|>}}{##1}%
      \fi
   \else
      \:hookI{Front#1}{\default:bts{|<front|>}{|<tail|>}}{##1}%
   \fi
}%
>>>


\<shared config\><<<
\NewConfigure{+CutAt}[3]{%
  \expandafter\def\csname Before#1Button\endcsname##1{#2}%
  \expandafter\def\csname After#1Button\endcsname##1{#3}}
>>>


\<push HPages\><<<
\sv:btns\nextCutAt
\sv:btns\prevCutAt
>>>


\<html utilities\><<<
\def\sv:btns#1{\ifx #1\space\global\let#1|=\empty \fi  \PushStack\prv:fl#1}
>>>

\<pop btons\><<<
\PopStack\prv:fl\prevCutAt
\PopStack\prv:fl\nextCutAt  
\ifx \prv:fl\empty 
      \let\prevCutAt|=\:UndDef
      \let\nextCutAt|=\:UndDef
\else
      \PopStack\prv:fl\:tempb
      \PopStack\prv:fl\prevCutAt
      \PopStack\prv:fl\nextCutAt
   \PushStack\prv:fl\nextCutAt
   \PushStack\prv:fl\prevCutAt
   \PushStack\prv:fl\:tempb
\fi
>>>
   

\<html config util\><<<
\NewConfigure{crosslinks}[8]{%
   \def\default:bts##1##2{%
      |<record cond buttons|>%
      \def\:temp{##1}\ifx \:temp\empty 
         \ifx\a:crsbt\empty\ifx \aa:crsbt\empty |<remove buttons|>\fi\fi
         \a:crsbt
      \else
         \ifx\b:crsbt\empty\ifx \bb:crsbt\empty |<remove buttons|>\fi\fi
         \b:crsbt
      \fi
      \def\CLB:next{\expandafter\cond:bt\next:bt{}{#3}}%
      |<prev for leading node in option `next'|>%
      \def\CLB:prev{\expandafter\cond:bt\prev:bt{}{#4}}%
      \def\CLB:prevtail{\expandafter\cond:bt\prev:bt{|<tail|>\prev:bt}{#5}}%
      |<front/tail button|>%
      \def\:temp{#8}\ifx \:temp\empty \else 
         \ifx \cond:bt\:gobbleIII 
         \else \def\CLB:up{\def\:temp{#8}#1\ExitHPage{#8}#2}\fi\fi
      |<insert cross link buttons|>%
      |<restore cond buttons|>%
      \def\:temp{##1}\ifx \:temp\empty \aa:crsbt\else \bb:crsbt\fi
      |<tail target|>}%
   |<set linkless buttons|>%
}
\NewConfigure{crosslinks+}[4]{%
   \def\a:crsbt{#1}\def\aa:crsbt{#2}\def\b:crsbt{#3}\def\bb:crsbt{#4}}
\NewConfigure{crosslinks-}[2]{%
   \def\a:cond:bt{#1}\def\b:cond:bt{#2}}
>>>


\<set linkless buttons\><<<
\def\cond:bt##1##2##3{%
   \expandafter\ifx\csname a:cond:bt\endcsname \relax
      \ifx ##1\empty \else
         \def\:temp{##3}\ifx \:temp\empty \else
                #1\Link[##1]{##2}{}##3\EndLink #2%
      \fi \fi
   \else
      \ifx ##1\empty 
         |<set a linkless button|>%
      \else
         \def\:temp{##3}\ifx \:temp\empty \else
                #1\Link[##1]{##2}{}##3\EndLink #2%
      \fi \fi
   \fi
}%
>>>


\<set a linkless button\><<<
\def\:temp{next}\ifx \:temp\cur:bt \else
   \ifx \c:next:\:gobbleII \else \let\:temp=\empty \fi
\fi
\ifx \:temp\empty \else
   \ifx \a:cond:bt\empty  \ifx \b:cond:bt\empty  #1\else
                                         \a:cond:bt\fi
   \else                                 \a:cond:bt\fi
   ##3%
   \ifx \a:cond:bt\empty  \ifx \b:cond:bt\empty  #2\else
                                         \b:cond:bt\fi
   \else                                 \b:cond:bt\fi
\fi
>>>



\<insert cross link buttons\><<<
\CLB:menu
>>>

\<\><<<
\csname CLB:next\endcsname          %1
%
\csname CLB:prevup\endcsname        %2
\csname CLB:prev\endcsname          %5
%
\csname CLB:prevtailup\endcsname    %3
\csname CLB:prevtail\endcsname      %6
%
\csname CLB:tail\endcsname          %7
%
\csname CLB:front\endcsname         %8
%
\csname CLB:up\endcsname            %9
>>>


\<html config util\><<<
\expandafter\def\csname c:crosslinks*:\endcsname{%
   \let\CLB:menu\empty \CLB:menuitem }
\def\CLB:menuitem#1{%
   \def\:tempa{#1}\ifx \:tempa\empty \else
      \append:def\CLB:menu{\csname a:crosslinks:#1\endcsname
                     \def\cur:bt{#1}\csname CLB:#1\endcsname
      }%
      \def\:temp{prev}\ifx \:temp\:tempa
         \append:def\CLB:menu{\csname a:crosslinks:prev\endcsname
                              \csname CLB:prevup\endcsname
         }%
      \else 
         \def\:temp{prevtail}\ifx \:temp\:tempa
            \append:def\CLB:menu{%
               \csname a:crosslinks:prev\endcsname
               |<prevtail hook|>% 
               \csname CLB:prevtailup\endcsname
         }%
      \fi \fi
      \expandafter\CLB:menuitem
   \fi 
}
\Configure{crosslinks*} 
   {next}
   {prev}
   {prevtail}
   {tail} {front}
   {up}
   {}
\NewConfigure{crosslinks:next}{1}
\NewConfigure{crosslinks:prev}{1}
\NewConfigure{crosslinks:prevtail}{1}
\NewConfigure{crosslinks:tail}{1}
\NewConfigure{crosslinks:front}{1}
\NewConfigure{crosslinks:up}{1}
>>>



\<record cond buttons\><<<
\let\sv:cond:bt|=\cond:bt
>>>

\<restore cond buttons\><<<
\let\cond:bt|=\sv:cond:bt
>>>

\<remove buttons\><<<
\let\cond:bt|=\:gobbleIII
>>>




\`'\Configure{crosslinks+}
     {before-front-links}{after-front-link}
     {before-back-link}{after-back-link}'


\<front/tail button\><<<
\def\:temp{##2}%
\ifx \:temp\empty
   \def\:temp{#6}%
   \ifx \:temp\empty \else
       \def\CLB:tail{\def\:temp{#6}#1\Link[\RefFileNumber\file:id]{}{}#6\EndLink #2}\fi
\else
   \def\:temp{#7}%
   \ifx \:temp\empty \else
       \def\CLB:front{\def\:temp{#7}#1\Link{##2\RefFileNumber\file:id}{}#7\EndLink #2}\fi
\fi
>>>

Neds the \''\expandafter' above because \''\Link' modifies \''\:te:mp'. 

\<tail target\><<<
\def\:temp{##1}\ifx \:temp\empty  \else 
   \ifx\yes:tail\def
      \Link{}{##1\RefFileNumber\file:id}\EndLink
\fi \fi
>>>

\<prevtail hook\><<<
\ifx\a:crsbt\empty\else \let\yes:tail\def\fi
\ifx\aa:crsbt\empty\else \let\yes:tail\def\fi
\ifx\b:crsbt\empty\else \let\yes:tail\def\fi
\ifx\bb:crsbt\empty\else \let\yes:tail\def\fi
>>>

%\NewStack\prv:fl

\<html cut points\><<<
\let\prevCutAt|=\empty
>>>


\''french.sty' chages the definition of \''\special' and that creates 
problems for tex4ht. Hence, the following redefdinition. When
\''french.sty' and the likes are not around we can't just go for
\''\let\ht:special=\special' because when the special is written out
we don't \''\ht:special' there. Hence the configure.

\<early utilities\><<<
\NewConfigure{special}[1]{\def\ht:special{#1}}
\Configure{special}{|<default special|>}
>>>

\<default special\><<<
\special
>>>

%\let\real:special|=\special
%\NewConfigure{special}[1]{\def\ht:special{#1}}
%\Configure{special}
%   {\ifx \real:special\special \expandafter\special
%    \else \expandafter\real:special\fi}


\<html Configure's\><<<
\edef\:temp{\string\special}
\edef\:tempa{\meaning\special}
\ifx \:temp\:tempa \else
   \def\:temp{|<default special|>}
   \ifx \:temp\ht:special
     \:warning{Redefined \string\special. Might 
                need \string\Configure{special}{<system-special>}}
\fi\fi
>>>

\<protect from /special redef\><<<
\let\special|=\relax
>>>


\<early utilities\><<<
\long\def\expand:after#1{\def\e:tmp{#1}\expandafter\e:tmp}
>>>



\<tempa := new file; tempb := old file\><<<
\tmp:cnt|=\maxfile:id  \advance\tmp:cnt |by 1
\edef\HP:file{\j:bname |<tail for file name|>\tmp:cnt }%
\xdef:cs{in:fid:#1}{\file:id}%             
\edef\:tempb{\RefFileNumber{\file:id}}%
>>>



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\SubSection{The `next' Option}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%




\<html cut points\><<<
\:CheckOption{next}     \if:Option   
   \def\next:bt{\nextCut}
   \def\prev:bt{\prevCut}
\else
   \Log:Note{for linear crosslinks of pages, 
       use the command line option `next'}%
   \def\next:bt{\nextCutAt}
   \def\prev:bt{\prevCutAt}
\fi
>>>

\<early utilities\><<<
\def\Log:Note#1{%
   \immediate\write-1{--------------------------------------}%
   \immediate\write-1{--- Note --- #1}%
   \immediate\write-1{--------------------------------------}%
}
>>>

\<prev/next at end of hpage\><<<
\ct:btn
>>>

\<prev/next at start of hpage\><<<
\ct:btn
\gHAdvance\C:tAtN |by 1
\Tag{fileidcut \file:id}{\C:tAtN}%
\TagFile{cutfile \C:tAtN}%
>>>

\<html cut points\><<<
\HAssign\C:tAtN |= 0
\def\ct:btn{{%
  \HAssign\C:tAtN |= 0\LikeRef{fileidcut \file:id}%
  \Advance:\C:tAtN |by -1
  \xdef\prevCut{\RefFile{cutfile \C:tAtN}}%
  \ifx \prevCut\space \global\let\prevCut|=\empty \fi
  \Advance:\C:tAtN |by  2
  \xdef\nextCut{\RefFile{cutfile \C:tAtN}}%
  \ifx \nextCut\space \global\let\nextCut|=\empty \fi
}}
>>>

\<prev for leading node in option `next'\><<<
\ifx \prevCut\empty 
   \def\:temp{\prevCut}\ifx \:temp\prev:bt
      \Recall:HPageTag\HP:file  \Save:HPageTag\HP:file
      \def\:temp{#4}\ifx \:temp\empty \else 
         \def\CLB:prevup{%
            \def\:temp{#4}#1\Link[\RefFile{|<fr bt fl|>\HP:file}]{}{}#4\EndLink #2}%
      \fi
      \def\:temp{#5}\ifx \:temp\empty \else 
         \def\CLB:prevtailup{%
               \def\:temp{#5}#1\Link[\RefFile{|<fr bt fl|>\HP:file}]{tail\Jobname
                                                }{}#5\EndLink #2}%
      \fi
      |<next button in root of `next' option|>%
\fi \fi
>>>

% \expandafter\cond:bt\prev:bt{}{%... add march 25, 2005

\<next button in root of `next' option\><<<
\long\def\:tempb####1####2{\gdef\root:next{%
  \def\:temp{####2}\edef\HP:file{\RefFileNumber\file:id}%
  \ifx \:temp\HP:file
      \global\let\root:next|=\empty   
      \def\:temp{#3}\ifx \:temp\empty
         \Link{}{tail\Jobname}\EndLink
      \else    
         \expandafter\ifx \csname a:next+\endcsname\relax #1\else
            \csname a:next+\endcsname \fi 
         \expandafter\ifx \csname a:next\endcsname\relax
                \def\:next{#3}%
         \else  \let\:next\a:next \fi
         \ifx \:next\empty
            \Link{}{tail\Jobname}\EndLink
         \else
            \Link[####1]{}{tail\Jobname}\:next\EndLink
         \fi
         \expandafter\ifx \csname b:next+\endcsname\relax #2\else
         \csname b:next+\endcsname \fi 
   \fi \fi}}%
\edef\:temp{\noexpand\:tempb
   {\RefFileNumber\file:id}{\RefFile{|<fr bt fl|>\HP:file}}}%
\:temp
>>>

\<html cut points\><<<
\let\root:next|=\empty
>>>


\<html config util\><<<
\NewConfigure{next}[1]{\def\a:next{#1}}
\NewConfigure{next+}[2]{%
    \expandafter\def\csname a:next+\endcsname{#1}%
    \expandafter\def\csname b:next+\endcsname{#2}}
>>>







\<elements for cut points\><<<
\:CheckOption{next}     \if:Option   \else
   \let\c:next:|=\:gobbleII
\fi
>>>


%%%%%%%%%%%%%
\SubSection{File Naming}
%%%%%%%%%%%%%



\<HPages for sec\><<<
\csname a:CutAt-filename\endcsname{#1}{#2}%
>>>

\<early utilities\><<<
\NewConfigure{CutAt-filename}[1]{%
   \expandafter\def\csname a:CutAt-filename\endcsname##1##2{#1}}
\Configure{CutAt-filename}{}
>>>


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Grouping Mecahanism for CutAt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

A \`'\CutGroup{ChGroup,Chapter,LikeChapter,Appendix}' allows unified
requests of the form \`'\CutAt{ChGroup,Part}'.

\<html cut points\><<<
\def\CutGroup#1{\Cut:Group#1,,|<par del|>}
\def\Cut:Group#1,{%
   \expandafter\ifx \csname #1\endcsname\relax
      \expandafter\let\csname #1\endcsname|=\:gobble\fi
   \def\HP:file{#1}%
   \do:list \cut:gr,}
>>>




The \`'\CutGroup{group,division}' replaces \`'\division{#1}' 
with  \`'\group{#1}\division{#1}', and \`'\Cut:division{#1}' 
with  \`'\Cut:group{#1}\Cut:division{#1}'.

\<tex html cut points\><<<
\def\cut:gr#1{%
   \edef\:temp{%
      \let\:csname \HP:file :#1\endcsname |=\:csname #1\endcsname
      \let\:csname \HP:file :Cut:#1\endcsname |=\:csname Cut:#1\endcsname
      \def\:csname #1\endcsname####1{%
         \noexpand\cond:cs{\HP:file}{####1}%
         \:csname \HP:file :#1\endcsname{####1}}%
      \def\:csname Cut:#1\endcsname####1{%
         \noexpand\cond:cs{Cut:\HP:file}{####1}%
         \noexpand\cond:cs{\HP:file :Cut:#1}{####1}}%
   }\:temp }
>>>


\SubSection{Utilities}


\<general utilities\><<<
\def\cond:cs#1#2{%
   \expandafter\ifx  \csname #1\endcsname\relax  \else
      \csname #1\endcsname{#2}%
   \fi
}
\def\do:list#1,#2,{%
   \def\:temp{#2}\ifx \:temp\empty  \expandafter\stop:do
   \else   #1{#2}\fi
   \do:list#1,}
\def\stop:do#1|<par del|>{}
>>>















\Chapter{Coauthoring}



\<imports\><<<
|<import-export interface|>
\:CheckOption{family} \if:Option
   |<import-export commands|>
   |<imports utilities|>
\else
   |<no import-export|>
\fi
>>>







\<general utilities\><<<
\def\BI:gbl{\ifx [\:temp \expandafter\bi:gbl\else
                        \expand:after{\bi:gbl[]}\fi}
\def\bi:gbl[#1]#2{}
>>>


\<html utilities\><<<
\def\ro:nd#1#2{%
   \gHAdvance#1 |by #2
   \gHDivide#1 |by #2
   \gHMultiply#1 |by #2 }
>>>

\Section{The Commands}

The extension for the name should refer to the \`'xref' file,
and if omitted an \`'.xref' is aasumed.

\<import-export interface\><<<
\def\ParentOf{\gHAdvance\TitleCount  1 
   \global\let\mu:span|=\TitleCount \futurelet\:temp\:mprt}
>>>

\<no import-export\><<<
\let\:mprt|=\BI:gbl
>>>


\<import-export commands\><<<
\def\:mprt{\fm:call\:Imprt}

\def\:Imprt[#1]#2#3{%
   \def\:temp{#2}\ifx \:temp\Jobname 
                    \:warning{#2 \string\ParentOf\space#2?}\fi
   \Needs-{child `#2'}%
   \LoadRef[|<screen ref from child @2|>]{#3}{##1}%
   \imp:var{#2}fstf:id,#1|<par del|>%
   |<send links from parent to child|>%
   \the\:tokwrite{\string\doTocEntry
                          \string\tocParentOf{#2}{}{}\relax}}

\HAssign\fstf:id|=0
>>>




\<import-export interface\><<<
\def\ChildOf{\futurelet\:temp\:xprt}
>>>

\<no import-export\><<<
\Odef\ChildOf[#1]#2{\:warning{\string\ChildOf{#2}
   without \string\Preamble{...,family,...}}}
\let\:xprt|=\BI:gbl
>>>




\<import-export commands\><<<
\def\:xprt{\fm:call\:Exprt}

\def\:Exprt[#1]#2#3{%
   \ifnum \maxfile:id>1 
       \:warning{\string\ChildOf{#2} not at root file}\fi
   \Needs-{parent `#2'}%
   \ld:flxrf{#3}{|<toc tag|>}%
   \LoadRef[|<screen ref from parent @2|>]{#3}{##1}%
   \xp:var{#2}fstf:id,#1|<par del|>%
   |<adjust file ids info up|>%
   \def\export:hook{\exprt:tag{#2}fstf:id,#1|<par del|>}%
   |<send links from child to parent|>%
   \gdef\:Export[##1]##2{\:warning{\string\ChildOf
               \string{##2\string}\space ignored (not 1st)}}%
}
>>>





\<import-export commands\><<<
\def\rmv:ext#1.#2|<par del|>{#1}

\def\fm:call#1{\ifx [\:temp \expand:after{\fm:cll#1}\else
                            \expand:after{\fm:cll#1[]}\fi}
\def\fm:cll#1[#2]#3{\edef\:temp{\noexpand\noexpand\noexpand
   #1[#2]{\noexpand\rmv:ext#3.|<par del|>}{#3}}%
   \edef\:temp{\:temp}\:temp}
>>>



\SubSection{Links}


\<send links from parent to child\><<<
\Tag{|<screen tag to child @2|>-up}{\RefFileNumber\FileNumber}%
\Tag{|<screen tag to child @2|>-prev}{\childFile}%
\xdef\childFile{\LikeRef{|<screen ref from child @2|>-down}}%
\ifx \cld:n\:UnDef  \else  \Tag{\cld:n}{\childFile}\fi
\xdef\cld:n{|<screen tag to child @2|>-next}%
>>>



\<send links from child to parent\><<<
\Tag{|<screen tag to parent @2|>-down}{\RefFileNumber\FileNumber}%
\ch:lnk\parentFile{#2}{up}%
\ch:lnk\prevChildFile{#2}{prev}%
\ch:lnk\nextChildFile{#2}{next}%
\global\let\nsrt:chlnks|=\nsrt:cldnks
\nsrt:chlnks{|<front|>}{|<tail|>}{FrontChild}%
>>>

We need in \`'\childFile' initially a space and not empty, because
otherwise Ref will produce the page number.


\<import-export commands\><<<
\let\childFile|=\space
\def\ch:lnk#1#2#3{%
   \xdef#1{\LikeRef{|<screen ref from parent @2|>-#3}}%
   \ifx #1\space \let#1|=\empty\fi}
>>>

Note that the following might be a problem for when HPage 
is nested in regular file.

\<import-export commands\><<<
\def\nsrt:cldnks#1#2#3{{%
   \let\prevCutAt|=\prevChildFile
   \let\nextCutAt|=\nextChildFile
   \def\ExitHPage##1{\Link[\parentFile]{}{}##1\EndLink}
   \:hookI{#3}{\default:bts{#1}{#2}}{}}}
>>>

\<buttons at end of child\><<<
\root:next
\ifx \nsrt:chlnks\:UnDef 
\else \nsrt:chlnks{|<tail|>}{|<front|>}{BackChild}\fi
>>>

\Section{Values in Variables}

\<import-export commands\><<<
\def\imp:var#1#2,#3|<par del|>{%
   \gt:ops{#2}%
   \Tag{|<screen tag to child @1|>-#2}{|<the|>\csname #2\endcsname}%
   \edef|<temp|>{0\LikeRef{|<screen ref from child @1|>-#2}}%
   \expand:after{\expandafter|<advance|>\csname
                                       #2\endcsname |by }|<temp|>%
   \if:notempty{#3}{\imp:var{#1}#3,|<par del|>}}
>>>

A child transfers up the changes made to a counter, not an absolute
value. The entry value is recorded in \`'\csname :#2:\endcsname'. 

\<import-export commands\><<<
\def\xp:var#1#2,#3|<par del|>{%
   \gt:ops{#2}%
   \edef|<temp|>{0\LikeRef{|<screen ref from parent @1|>-#2}}%
   \expandafter|<assign|>\csname #2\endcsname|=|<temp|>
   \expandafter\HAssign\csname :#2:\endcsname|=|<temp|>
   \if:notempty{#3}{\xp:var{#1}#3,|<par del|>}}
>>>

\<import-export commands\><<<
\def\exprt:tag#1#2,#3|<par del|>{%
   \tmp:cnt |= \csname #2\endcsname
   \advance\tmp:cnt |by -\csname :#2:\endcsname
   \Tag{|<screen tag to parent @1|>-#2}{\the\tmp:cnt}%
   \if:notempty{#3}{\exprt:tag{#1}#3,|<par del|>}}
>>>

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\SubSection{Overide Previous Files}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


The \''\:clearpage' is needed below to clear the old tags and xref
files, before new ones start to come. The \''\Tag' few lines below can be lost.

\<adjust file ids info up\><<<
\closeout\:refout
\openout\:refout|=\jobname.xref     \:clearpage
|<fix point for file ids at child|>%
\gHAssign\maxfile:id |= \fstf:id
\gHAssign\bs:fileid |= \maxfile:id
\global\let\file:id|=\maxfile:id  
\Tag{|<auto file tag|>\file:id |<Tag/Ref: file-id -> file-name|>}%
                                                {\jobname.\:html}%
\expandafter\xdef\csname 
   |<csname: file name -> file id|>\jobname.\:html\endcsname{\file:id}%
\xdef:cs{|<live|>\file:id}{}%
>>>


\<file not overided by /ChildOf\><<<
\csname  FN #1\endcsname > \bs:fileid 
>>>


\SubSection{Contain Changes}


We want to reduce the number of compilations due to changes. We can't do
much with sectioning numbers, but we can do quite a lot with labels of
links. Note that the addresses are made up of file numbers + label numbers.

We make the children `fix-points' with respect to file numbers, by
allocating them addresses that are equal to `child-id * 10000'.  We
make here an assumption that a compilation will not generate more than
9999 files.


\<fix point for file ids at child\><<<
\gHAdvance\fstf:id |by 10000
>>>

It would be nice to have also fix-points for file ids within children,
but this will  cause holes.  The holes will result in fake names
\`'\csname filei-d\endcsname' which unneccesariliy consume ids and can
overflow the memory quite quickly. This names are inspected at points
that files are closed, and checking is performed for opened subfiles.


We can also ask that large files will provide fixed-points. We do so
with the following command, which so far is used only at cut
points. It requests distinguished automatically generated file names
for  the class that is identified by the two leading characters of the
given parameter (i.e., sectioning type in case of the cut points).
These are really not fixed point, because they don't fix unique file
names (e.g., by rounding up file ids).

\<large file name for @2\><<<
\fx:pt #1xxx|<par del|>%
>>>

Do we want \`'   \ro:nd\html:lbl{100000}%' below?

\<html utilities\><<<
\def\fx:pt#1#2#3|<par del|>{%
   \expandafter\ifx \csname big:#1:#2\endcsname\relax
         \expandafter\gHAssign\csname big:#1:#2\endcsname |= 0  \fi
   \expandafter\gHAdvance\csname big:#1:#2\endcsname |by 1
   \edef\big:fn{#1#2\csname big:#1:#2\endcsname}}
>>>



On the other hands,  we try to make sectioning commands fixed points
for labels.  Hence, we try to reduce sensitivity of tocs to changes.
See \`'\<round ids between sections\>'




The validity of the above fixed points carries on as far as the
specified points are really fixed. If they become fluid, then
everything becomes fluid.








To get evrything working, we need 4 compilations (in modifications
less might be sufficient).

\List{ord}

\item  A compilation   to create the starting file number for each node
(child/ parent). That is, fix file numbers for children.

\item A compilation for using the right file numbers, and to create
the correct tags within the tocs.
That is,   to collect moveable information like tables of
contents and relationships between files.

\item A compilation to use the right tags, and to create the right
xref for the tags in the tocs 
That is, to collect cross-references from moveable info.

\item A compilation to incorporate the cross refs

\EndList



\SubSection{Cross-Reference Screening}

\''\Jobname'  has been introduced for \''\LoadRef[..]'

\<screen ref from child @2\><<<
#2-\Jobname>>>

\<screen ref from child @1\><<<
#1-\Jobname>>>

\<screen ref from parent @2\><<<
#2-\Jobname>>>

\<screen ref from parent @1\><<<
#1-\Jobname>>>

\<screen tag to child @1\><<<
\Jobname-#1>>>

\<screen tag to child @2\><<<
\Jobname-#2>>>

\<screen tag to parent @1\><<<
\Jobname-#1>>>

\<screen tag to parent @2\><<<
\Jobname-#2>>>




\Section{Tables of Content}




The are needed because some variables are of TeX and others
are of TeX4ht. 



\<imports\><<<
\def\tocParentOf#1{{%
   \def\:temp{#1}\ifx \:temp\Jobname
      \:warning{#1 \string\ParentOf\space#1?}
   \else  \expand:after{\ld:flxrf{#1}{|<toc tag|>}\get:input{#1.4tc}}\fi}}
>>>


\Section{Load File and Link Xref of Relative}


\<imports\><<<
\def\ld:flxrf#1#2{%
   \let\:CrsWd|=\Cross:Word
   \def\Cross:Word##1##2{%
      \expandafter\let\csname |<tag of Tag|>##2\endcsname|=\:UnDef
      \:CrsWd{##1}{##2}}%
   \LoadRef[|<auto file tag|>]{#1}{##1}%
   \LoadRef[|<HTag tag|>#2]{#1}{##1}%
   \let\Cross:Word|=\:CrsWd
}
>>>







\SubSection{Local Utilities}

















The following are  needed because some variables are of TeX and others
are of TeX4ht. 

\<imports utilities\><<<
\def\gt:vi#1#2#3#4#5#6#7|<par del|>{#1#2#3#4#5#6}
\def\gt:vr#1#2{\edef#1{\expandafter
   \gt:vi\meaning#2 .......|<par del|>}}
\gt:vr\c:unt\tmp:cnt
\def\chk:vr#1#2{\expand:after{\gt:vr\:temp#2 #1\:temp\c:unt}}

\def\gt:ops#1{%
   \expand:after{\chk:vr\ifx}\csname#1\endcsname  \let|<the|>|=\the
            \let|<assign|>|=\empty   \let|<advance|>|=\advance
  \else                             \let|<the|>|=\empty
            \let|<assign|>|=\HAssign  \let|<advance|>|=\Advance:
  \fi }
>>>

\<assign\><<<
\:tempa>>>

\<advance\><<<
\:tempb>>>

\<temp\><<<
\:tempc>>>

\<the\><<<
\:tempd>>>






\Chapter{Subdivisions}


\<divisions\><<<
|<elements for divs|>
|<no trace sec config|>  
\ifHtml  |<html divs|>
   \:CheckOption{hooks+}  \if:Option
      \else \:CheckOption{hooks} \fi
   \if:Option  |<trace sec config|>\fi
\fi
|<tex divisions|>
>>>



\Section{Interface}

The first parameter of \`'\Def:Section' provides the command name, the
second gives a non-parametric code that produces the title number, and
the third gives a single-parameter code for producing the title
itself.



\<elements for divs\><<<
\long\def\NewSection#1#2{%
   \Def:Section#1{#2}{##1}%
   \edef\:temp{\expandafter\:gobble\string#1}%
   \Configure:Sec\:temp{}{}{}{}%
   \ConfigureToc{\expandafter\:gobble\string#1}{\empty}{\empty}{}{}}
>>>


\`'\NewSection\DocChapter {counter}'

The parameter \`'##1' holds the title head.


\<endsection config\><<<
\NewConfigure{end#1}[1]{\expandafter
   \def\csname a:end#1\endcsname{##1}}%
\Configure{end#1}{}
>>>


\<elements for divs\><<<
\def\Def:Section#1{%
   \edef\:tempc{{\expandafter\:gobble \string#1}}%
   |<Configure for sectioning command|>%
   \futurelet\:temp\ch:NewSec}
\def\ch:NewSec{\if *\:temp\let\if:toc|=\:gobble\expandafter\op:NewSec
               \else  \let\if:toc|=\empty  \expand:after{\op:NewSec+}\fi}
\def\op:NewSec#1{\expandafter\:NewSec\:tempc}
|<def /:Every|>%
\def\:NewSec#1#2{%
   |<endsection config|>%
   \expandafter\def\csname #1\endcsname{%
      \expand:after{\let\if:toc|=}\csname if:#1toc\endcsname
      \:StartSec{#1}{#2}}%
   |<c:TITLE: for Sec|>%
   \expandafter\let\csname if:#1toc\endcsname|=\if:toc
   |<initiate BeforeEvery/Every div|>%
   \expandafter\def\csname #1:ttl\endcsname##1}
>>>

\''\Def:Section' +  \''\Configure' = \''\NewSection' 


\SubSection{/Configure}


\<no trace sec config\><<<
\long\def\Configure:Sec#1#2#3#4#5{%
  \expandafter\ifx\csname c:#1\endcsname\relax \let\:tempa|=\relax \else
  \def\:tempa{#4#5}\fi  \ifx\:tempa\empty \else
     |<conf for sec boundaries|>\fi
  \expandafter\ifx\csname a:#1\endcsname\relax \let\:tempa|=\relax \else
  \def\:tempa{#2#3}\fi  \ifx\:tempa\empty \else
     \expandafter\def\csname a:#1\endcsname##1{#2}%
     \expandafter\def\csname b:#1\endcsname##1{#3}%
  \fi
}
>>>

Note that in \`'\Configure{Section}{before}{after}{before head}{after
head}' a change occures only when before-after pair is not empty.


\<trace sec config\><<<
\long\def\Configure:Sec#1#2#3#4#5{%
  \expandafter\ifx\csname c:#1\endcsname\relax \let\:tempa|=\relax \else
  \def\:tempa{#4#5}\fi  \ifx\:tempa\empty \else
     |<conf for sec boundaries|>\fi
  \expandafter\ifx\csname a:#1\endcsname\relax \let\:tempa|=\relax \else
  \def\:tempa{#2#3}\fi  \ifx\:tempa\empty \else
     |<conf for sec heads|>\fi
}
>>>


\<conf for sec heads\><<<
  \def\:tempa{#2}\ifx \:tempa\empty
     \expandafter\def\csname a:#1\endcsname
         ##1{\hbox{\a:trc #13:4\b:trc}#2\hbox{\c:trc #14:4\d:trc}}%
  \else
     \expandafter\def\csname a:#1\endcsname##1{#2}%
  \fi
  \def\:tempa{#3}\ifx \:tempa\empty
     \expandafter\def\csname b:#1\endcsname
         ##1{\hbox{\a:trc #13:4\b:trc}#3\hbox{\c:trc #14:4\d:trc}}%
  \else
     \expandafter\def\csname b:#1\endcsname##1{#3}%
\fi
>>>

\<conf for sec boundaries\><<<
\expandafter\c:def\csname c:#1\endcsname{#4}%
\expandafter\c:def\csname d:#1\endcsname{#5}%
>>>


\<Configure for sectioning command\><<<
\edef\:temp{\long\def\expandafter\noexpand \csname
    c:\expandafter\:gobble \string#1:\endcsname
      ####1####2####3####4{\noexpand 
      \Configure:Sec\:tempc{####3}{####4}{####1}{####2}}%
   \noexpand\NewConfigure{CutAt\expandafter\:gobble \string#1}2%
   \noexpand\NewConfigure{+CutAt\expandafter\:gobble \string#1}2%
   }\:temp  \expandafter\Configure\:tempc{\empty}{}{\empty}{}%
>>>



\Section{Insertions at Boundaries of Logical Units}

\SubSection{Non Cut Ends}

\<boundaries of non-cut sections\><<<
\def\:tempa{#1}\noct:Close:Until 
\ifx \:tempb \empty \else               
   \csname d:\ifx \found:\empty #1\else \found:\fi\endcsname \fi
|<advance TitleCount|>\csname c:#1\endcsname
>>>


Any need
for \`'\def\:tempa{#1}'?



\<document end for non-cut logical units\><<<
\Close:UntilEnd
>>>

The following \''\Do:Close''s deal with sectioning unit 
at levels deeper  than one we are openning.  The sectioning
unit at the latter level is closed with the code 
\`'\csname d:\ifx \found:\empty #1\else \found:\fi\endcsname'
we just proccessed.

\<html divs\><<<
\def\noct:Close:Until{%
   \let\:tempA|=\sec:typ  \let\found:|=\empty
   \let\:tempd|=\:Sections    \noct:Check:Until
   \ifx \:tempb\sec:typ \expandafter\Do:Close  \fi
   \let\sec:typ|=\:tempA
}
\def\noct:Check:Until{%
   \ifx \:tempd\empty  |<exit non-cut check-until|>\else
      \PopStack\:tempd\:tempb
      |<search non-cut end|>%
      \ifx \:tempb\sec:typ \else
         \expandafter\expandafter\expandafter\noct:Check:Until
   \fi\fi }
>>>

We are about to open a new section unit, and we go as down as possible
in the stack of already openned section units searching for the lowest
unit in the stack that should be closed.   The \''\found:'  variable 
holds the lowest oppened unit to be closed.


\<exit non-cut check-until\><<<
\ifx \found:\empty  \let\:tempb\empty 
\else  \let\:tempb|=\found: \let\sec:typ|=\found:\fi
>>>


\<search non-cut end\><<<
\edef\:tempe{\:tempb,%
   \expandafter\ifx \csname a:end\:tempb\endcsname\relax \else
     \csname a:end\:tempb\endcsname \fi,,}%
\expandafter\mod:typ\:tempe|<par del|>%
>>>


\<html divs\><<<
\def\mod:typ#1,#2|<par del|>{%
   \def\:temp{#1}\ifx \:temp\empty\else
      \edef\:temp{\expandafter\expandafter\expandafter
         \:gobble\expandafter\string \csname #1\endcsname}%
      \ifx \sec:typ\:temp 
           \let\found:|=\:tempb  \let\:temp|=\empty
      \else \def\:temp{\mod:typ#2|<par del|>}\fi
   \fi \:temp
}
>>>


\SubSection{Cut Ends}

\<boundaries of cut sections\><<<
\Configure{CutAt#1}{|<advance TitleCount|>\csname c:#1\endcsname
      }{\def\sec:typ{#1}\Close:Until \csname d:#1\endcsname}%
>>>

\<html divs\><<<
\def\Close:Until{%
   \let\:tempd|=\:Sections    \Check:Until
   \ifx \:tempb\sec:typ \expandafter\Do:Close  \fi
}
\def\Check:Until{
   \ifx \:tempd\empty  \let\:tempb|=\empty \else
        \PopStack\:tempd\:tempb
       \ifx \:tempb\sec:typ \else
      \expandafter\expandafter\expandafter\Check:Until
   \fi\fi }
>>>


\SubSection{Common Utilities}

\<record sections hierarchy\><<<
\PushStack\:Sections{#1}%
>>>


\<html divs\><<<
\PushStack\:Sections{}%
\PopStack\:Sections\:temp
\def\Do:Close{%
   \PopStack\:Sections\:tempb
   \ifx \sec:typ\:tempb \else  
      \csname d:\:tempb\endcsname
      \expandafter\Do:Close 
   \fi
}
>>>

The following is for closing logical units at the end of the file,
when they don't have hypertext pages of their own.

\<html divs\><<<
\def\Close:UntilEnd{%
   \ifx \:Sections\empty  \let\:tempb|=\empty
   \else  \PopStack\:Sections\:tempb  \fi
   \ifx \:tempb\empty \else
      \csname d:\:tempb\endcsname
      \expandafter\Close:UntilEnd
   \fi
}
>>>



\Section{Building Blocks}

The \''\ref', \''\Tag', \''\@currentlabel', and \''\cur:th' are for
latex.  Also note that \''label' and \''\ref' can appear within
titles, and there we nullify them except within the titles themselves
and tocs.
One problem with the \''\ref' is that
they may cause nested links. 


\<html divs\><<<
\def\:StartSec#1#2#3{%
   \def\title:chs##1##2{##2}%
   \def\sec:typ{#1}%
   |<delayed TocAt|>%
   \a:NoSection
   |<round ids between sections|>%
   |<button for cut at sect|>%
   |<BeforeEvery hook|>%
   \expandafter\ifx \csname a:#1\endcsname\relax  \else
      \csname a:#1\endcsname{#3}%
   \fi
   \b:NoSection \:Ttle{#1}{#2}{\csname #1:ttl\endcsname{#3}}%
   \a:NoSection
   \expandafter\ifx \csname b:#1\endcsname\relax   \else
      \csname b:#1\endcsname{#3}%
   \fi
   |<Every hook|>%
   \csname a:AfterTitle\endcsname   \b:NoSection
   \def\title:chs##1##2{##1}%
}
\def\title:chs#1#2{#1}
>>>

\<shared config\><<<
\NewConfigure{NoSection}{2}
>>>





The  \''\par' before \''|<Every hook|>' is to ensure the use of
\''\ShowPar'. Well, the \''\par' turned out to be a pain in cases we 
want no space at all.  Hence, we took it out.






On the other hands,  we try to make sectioning commands fixed points
for labels.  Hence, we try to reduce sensitivity of tocs to changes.

\<round ids between sections\><<<
\ro:nd\html:lbl{1000}%
>>>
















%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Title}
%%%%%%%%%%%%%%%%%%%%%%%%%

\<elements for divs\><<<
\def\:Ttle#1#2#3{%
   \html:addr
   |<hook for ref/label|>%
   {|<introduce `doTocEntry toc@1 (@2) (@3) (page no)' to toc|>}%
   {|<typeset @3 and link to toc entry|>}%
}
\gHAssign\TitleCount|=0   \global\let\mu:span|=\TitleCount
>>>

\<advance TitleCount\><<<
\gHAdvance
   \TitleCount |by 1 \global\let\mu:span|=\TitleCount
\expandafter\expandafter\expandafter\global \expandafter
                         \let\csname #1:Count\endcsname|=\TitleCount
>>>


For some reason (what it is?) we can't put the set TitleMark
together with the TitleConunt within CutAt--e.g., tex4ht-html32 screams at 
subsection about undefined TitleMark.

\<set TitleMark\><<<
\expandafter
   \let\expandafter\TitleMark\csname #1HMark\endcsname
>>>

\<tex divisions\><<<
\def\ConfigureMark#1#2{\long\expandafter
   \def\csname #1HMark\endcsname{#2}}
>>>



We nulify \''\Link', but this causes no problem because we are 
within a group.

well, \`' \let\Link|=\no:lnk ' is a problem for \`'\Configure{ref}',
so we introduced the latter comamnd.

\<typeset the html sec title\><<<
\csname a:InsertTitle\endcsname
\csname InsertTitle\endcsname{#1}%
>>>


Can't use \''\Title'. Already in maple2e.tex.





\<typeset @3 and link to toc entry\><<<
|<href on sec head?|>%
\no:lbl:idx \csname Modify#1Title\endcsname  
\html:sectoc{#3}%
>>>



\<tex divisions\><<<
\let\no:lbl:idx|=\empty
\let\toc:lbl:idx|=\empty
>>>

\Section{Table of Contents}

The \''\:writetoc' command outputs the expansion of its parameter, and
the page number, into the file.  The expanded definition \`'\edef'
provides records the parameter according to the conditions that exist
when the command is encountered.

\<introduce `doTocEntry toc@1 (@2) (@3) (page no)' to toc\><<<
\escapechar=`\\%
\protect:wrtoc
\csname Modify#1ToToc\endcsname
\edef\:writetoc{\csname if:toc\endcsname{\the\:tokwrite
   {\string\doTocEntry
    \string\toc \expandafter\ifx\csname toToc:#1\endcsname\relax #1\else
       \csname toToc:#1\endcsname\fi
       {#2}{\html:tocsec{\ifx \TocTitle\:UnDef #3\else
       \TocTitle\fi}}{\the\:tokpage}\relax}}}%
\:writetoc   \global\let\TocTitle|=\:UnDef
>>>

\<elements for divs\><<<
\NewConfigure{toToc}[2]{%
   \if !#2!\expandafter\let\csname toToc:#1\endcsname\:UnDef
   \else \if !#1!%
        \expandafter\let\csname IF:#2toc\expandafter\endcsname
             \csname if:#2toc\endcsname
        \expandafter\let\csname if:#2toc\endcsname\:gobble
   \else \edef\:temp{\string @}\edef\:tempa{\string#1}%
   \ifx \:temp\:tempa
         \expandafter\let\csname if:#2toc\endcsname\empty
   \else \edef\:temp{\string ?}%
   \ifx \:temp\:tempa
        \expandafter\let\csname if:#2toc\expandafter\endcsname
             \csname IF:#2toc\endcsname
   \else
     \expandafter\def\csname toToc:#1\endcsname{#2}%
   \fi\fi\fi\fi}
>>>

\<elements for divs\><<<
\ifx \:tokwrite\:UnDef
   \csname newtoks\endcsname\:tokwrite
\fi
\ifx \:tokpage\:UnDef
   \csname newtoks\endcsname\:tokpage
\fi
\:tokpage={\folio}
>>>

\<html latex divs\><<<

>>>

\<elements for divs\><<<
\:tokwrite|={\write\:tocout}   
>>>


\<html divs\><<<
\def\protect:wrtoc{%
   |<no Hnewline|>\PictureOff
   \def\%{\string\%}\a:writetoc}
>>>



\<html config util\><<<
\NewConfigure{writetoc}[1]{\concat:config\a:writetoc{#1}}
\let\a:writetoc|=\empty
>>>


The following might be solved with protect(?).


\`' \let\Link|=\no:lnk ' is a problem for \`'\Configure{ref}'.




\Section{Links}


\<html divs\><<<
\def\html:sectoc#1{\csname if:toc\endcsname{%
   \xdef\CurSecHaddr{|<section html addr|>}%
   \edef\:attr{\noexpand\scp:Link{%
     \ifTag{|<HTag tag|>|<toc-section html addr|>}%
            {|<toc-section html addr|>}%
            {|<section html addr|>}%
     }}%
   \:attr{|<section html addr|>}}%
   \ifx \EndTitle:Link\:gobble \if:toc{\scp:EndLink}\fi
   |<typeset the html sec title|>\EndTitle:Link{\if:toc{\scp:EndLink}}}
\def\html:tocsec#1{\string\csname\space a:TocLink\string\endcsname
   {\FileNumber
   }{|<section html addr|>}{|<toc-section html addr|>}{#1}}
\let\CurSecHaddr|=\empty
>>>

If option \`'sections+' is active, the full title is an anchor.
Might be a problem, in particular when the title contains
a footnote.  If the option is not active, the anchor for access from
the tocs is empty.

% [ CLASS="\sec:typ Head"]
% [ CLASS="\sec:typ Toc"]



The command \''\uppercase' is put outside the command \''\:toc' to
convert the lower case character tokens to uppercase characters before
they are inserted into the file. Within \''\:toc' the command \''\uppercase'
is written as is into the auxiliary file, and takes effect only when
the auxiliary file is imported.




\''\Get:SecAnchor' should provide an anchor in \''\:SecAnchor' for the
cross references.  If none is provided, tex4ht will offer one.  tex4ht
doesn't really need the address; the idea is to save on duplicated anchors.

\<section html addr\><<<
\ifx \:SecAnchor\:UnDef
   |<toc tag|>1-\file:id-\TitleCount 
\else \:SecAnchor \fi  >>>



\<toc-section html addr\><<<
|<toc tag|>2-\file:id-\TitleCount >>>


\<toc tag\><<<
Q>>>


\<hook for ref/label\><<<
\Get:SecAnchor{#1}{#2}{#3}%
>>>


\<elements for divs\><<<
\def\Get:SecAnchor#1#2#3{}
>>>







\Section{Control Links on Section Heads}



Option for univerally no links from titles of sections.

\<html divs\><<<
\:CheckOption{sections+}\if:Option 
     \def\Title:Link{\Link}
     \def\EndTitle:Link#1{#1}
\else
     \def\Title:Link#1{\Link{}}
     \let\EndTitle:Link|=\:gobble
   \Log:Note{for back links to toc, 
       use the command line option `sections+'}%
\fi
>>>

\<shared config\><<<
\NewConfigure{toTocLink}[2]{\def\scp:Link{#1}\def\scp:EndLink{#2}}
\Configure{toTocLink}{\Title:Link}{\EndLink}
>>>


The above gives global control. The following local one.
E.g., \`'\NoLink{section}' asks that sections of type `section'
will not act as hot buttons.

\<html divs\><<<
\def\NoLink#1{\expandafter
  \gdef\csname #1:Href-\endcsname{\let\EndTitle:Link|=\:gobble}}%
>>>


\<href on sec head?\><<<
\csname #1:Href-\endcsname
>>>


\Section{Cut-Offs}

The following makes a call to, e.g.,  \`'\cut:at{section}{title}-'



\<button for cut at sect\><<<
|<set TitleMark|>%
\expandafter\ifx  \csname Cut:#1\endcsname\relax  
  |<boundaries of non-cut sections|>%
\else
   |<boundaries of cut sections|>%
   |<TITLE for Sec|>%
   \csname Cut:#1\endcsname{#3}%
\fi
\global\let\sec:lvl|=\HPageDepth
|<record sections hierarchy|>%
>>>


%   \Configure{CutAtTITLE+}      {|<TITLE for Sec|>}%


The \`'\let\sec:lvl|=\HPageDepth' is used to determine whether we have
prev-next links with next HPage. As we out from hypertext pages,
the value of \''\HPageDepth' decreases, and  the values of
\''\sec:lvl' are kept one value behind.   If just before entering 
a hypertext page we have \`'\sec:lvl>\HPageDepth', it means 
that the last HPage and the next one are at the same depth.  Hence,
we allow for prev-next links.   We want the \''\global' because
section titles can be within groups as is the case, for instance, 
for tables of contents of tables or figures in LaTeX. Without
the global, will need to fix locally the values of \''\sec:lvl' for titles
that are nested in groups.


\<TITLE for Sec\><<<
\expandafter\ifx \csname a:\sec:typ TITLE\endcsname\relax\else
   \expandafter\let\expandafter\a:CutAtTITLE 
             \csname a:\sec:typ TITLE\endcsname\fi
>>>

\<TITLE for SecNO\><<<
\expandafter\ifx \csname a:\sec:typ TITLE\endcsname\relax
   \expandafter\HCode \else
\expandafter\expandafter\csname a:\sec:typ TITLE\endcsname\fi
>>>




\<c:TITLE: for Sec\><<<
\expandafter\def\csname c:#1TITLE+:\endcsname{%
   \expandafter\def\csname a:#1TITLE\endcsname####1}%
>>>

\<html divs\><<<
\HAssign\sec:lvl|=0 
>>>

\Section{Hooks}

BeforEvery and Every are single-parameter macros.

\<def /:Every\><<<
\def\:Every#1{%
   \expandafter\edef\csname Every#1\endcsname{%
      \def\expandafter\noexpand \csname :Every#1\endcsname####1}%
   \expandafter\edef\csname BeforeEvery#1\endcsname{%
      \def\expandafter\noexpand\csname :BeforeEvery#1\endcsname####1}%
}
>>>

\''\Every...' and not \''\AfterEvery...', because we are not yet after the section, we are only after the title.


Default hooks are set to tables of contents.  

\<initiate BeforeEvery/Every div\><<<
\:Every{#1}%
\csname Every#1\endcsname{%
   \expandafter\ifx\csname Toc:#1\endcsname \relax\else
       \a:TocAt  \csname Toc:#1\endcsname \b:TocAt
   \fi
   \ignorespaces}%
>>>

\<delayed TocAt\><<<
\a:dTocAt  \csname TocAt*\endcsname   \b:dTocAt
\expand:after{\global\let}\csname TocAt*\endcsname|=\empty
>>>


\<html config util\><<<
\NewConfigure{TocAt*}[2]{%
    \c:def\a:dTocAt{#1}\c:def\b:dTocAt{#2}}
\NewConfigure{TocAt}[2]{%
    \c:def\a:TocAt{#1}\c:def\b:TocAt{#2}}
\Configure{TocAt*}{}{}
\Configure{TocAt}{}{}
>>>






The following occurs for sectioning commands without
subdivisions.


\<BeforeEvery hook\><<<
\expandafter\ifx \csname :BeforeEvery#1\endcsname\relax \else
   \csname :BeforeEvery#1\endcsname{#3}%
\fi
>>>


\<Every hook\><<<
\expandafter\ifx \csname :Every#1\endcsname\relax \else
   \csname :Every#1\endcsname{#3}%
\fi
>>>


\Section{Utilities}


Normally, the leading paragraphs in chapters and sections start with
no indentation, whereas the other paragraphs start with indentations. 
To achieve this effect, we can allow a contribution of an indentation to
all the paragraphs,  with provisions for removing the indentations from
selected paragraphs.



Without the \''\immediate' we can get problems on boundary between pages.



\Section{Configurations for CutAt}




The \`'\par\ShowPar' is to ensure that buttons at
end of a page will not get into the last entry of the table in case
of a cut-off situation.

 






\Chapter{Tables of Contents}










\Section{Archiving the Table}

For a source document that is stored in file named \''abc.xyz' the
table is assumed to be stored in a file that carries the name
\''abc.4tc'.  It is archived into \''abc.4ct'.

\<blocs for tocs\><<<
\openin15=\jobname.4tc
\ifeof15  \closein15
   \def\:TableOfContents[#1]{\writesixteen{No file \jobname.4tc}}
   |<undef /TableOfContents|>
\else  
   \ifHtml  |<def html /TableOfContents|>
   \fi
   |<copy toc|>  
\fi
>>>


\<copy toc\><<<
\begingroup
  \catcode`^|=7  
  |<define /:copytoc|>   \ifHtml \catcode`\#|=12\relax \fi
  \def\:next{\catcode\tmp:cnt|=12
    \ifnum \tmp:cnt=0
       \def\:next{%
          \catcode`\^^M|=5
          \immediate\openout15=\jobname.4ct     \:copytoc
          \immediate\closeout15
          \endgroup \closein15
       }%
    \fi
    \advance\tmp:cnt |by -1 \:next
  }
  \tmp:cnt|=255   \:next 
>>>


\<define /:copytoc\><<<
\def\:copytoc{%
   \ifeof15   \else
      \read15 to \:temp
      {\escapechar=`\\\immediate\write15{\:temp}}%
      \expandafter\:copytoc
   \fi}
>>>

\Section{Invoked Tables of Contents}


\SubSection{Listing the Entries}




The following pair of definitions are a degenerated case of the `sty' option
in which the parameters are required for a table to appear.

\<undef /TableOfContents\><<<
\ifx \TableOfContents\:UnDef
   \def\TableOfContents{\futurelet\:temp\:TOC}
   \def\:TOC{\ifx [\:temp \expandafter\:TableOfContents\fi}
\fi
>>>



\<def html /TableOfContents\><<<
|<undef /TableOfContents|>
\def\:TableOfContents[#1]{\SaveEverypar{%
   \def\TocCount{0}%
   |<interpretation for entries|>%
   \def\InsertTitle##1##2##3{}%
   \hsize|=4.5in  \rightskip |= \z@ minus 1in  \linepenalty|=1000
   \catcode`\#|=12  \catcode`\@|=11   \catcode`\:|=11  
   |<Configure HtmlPar for TOC|>\everypar{\HtmlPar}%
   |<before toc|>\input \jobname.4ct
   {\ht:everypar{}\leavevmode}|<bottom toc|>%
   \par  }\RecallEverypar |<after toc|>} 
>>>

\<after toc\><<<
\ifx \c:tableofcontents\:UnDef 
   \csname c:TableOfContents\endcsname
\else \c:tableofcontents \fi
>>>

\<before toc\><<<
\ifx \a:tableofcontents\:UnDef \csname a:TableOfContents\endcsname
\else \a:tableofcontents \fi
>>>



\<bottom toc\><<<
\ifx \b:tableofcontents\:UnDef
      \csname b:TableOfContents\endcsname
\else \b:tableofcontents \fi
>>>




\<par toc\><<<
\ifx \d:tableofcontents\:UnDef \csname d:TableOfContents\endcsname
\else \d:tableofcontents \fi
>>>

\<noindent toc par\><<<
\ifx \e:tableofcontents\:UnDef
      \csname e:TableOfContents\endcsname
\else \e:tableofcontents \fi
>>>










The following might be a problem LaTeX, in particular 
with \''\IgnoreIndent/\ShowIndent' cases. A partial solution 
to the problem used the code
\`'\if:latex \if:nopar \else
   \Configure{HtmlPar}{}{\Configure
      {HtmlPar}{|<noindent toc par|>}{|<par toc|>}{}{}}{}{}%
\fi\fi', but then we got problems elsewhere.

\<Configure HtmlPar for TOC\><<<
\Configure{HtmlPar}{|<noindent toc par|>}{|<par toc|>}{}{}%
>>>





\SubSection{Loading the Entries}


\<interpretation for entries\><<<
\:tocPreamble#1,,%
\let\doTocEntry|=\:doTocEntry
\def\contentsline##1##2##3{##2}%
\no:lbl:idx
>>>




\<blocs for tocs\><<<
\def\:doTocEntry#1#2#3#4{%
   \Advance:\TocCount |by 1
   \expandafter\ifx \csname \string#1 \endcsname \relax \else
     #1{#2}{#3}{#4}\fi
}
>>>

\<shared config\><<<
\NewConfigure{TocLink}[1]{\def\a:TocLink##1##2##3##4{#1}}
>>>

A field \`'[\ifnum \FileNumber=#1 
   \else \RefFileNumber{#1}\fi]' buys nothing as far as memory
is concerned.

\<def Configure\><<<
\long\def\ConfigureToc#1#2#3#4#5{%
   \expandafter\def\csname toc#1\endcsname##1##2##3{#5}%
   |<cond toc config|>%
}
>>>


\<trace commands\><<<
\long\def\ConfigureToc#1#2#3#4#5{%
   \expandafter\def\csname toc#1\endcsname##1##2##3{#5}%
   \edit:p\def\:temp{#2#3#4#5}\ifx \:temp\empty
      \expandafter\pend:defIII\csname toc#1\endcsname{\hbox
        {\a:trc Toc(#1)1\b:trc}####1\hbox{\a:trc Toc(#1)2\b:trc}####2\hbox
        {\a:trc Toc(#1)3\b:trc}####3\hbox{\a:trc Toc(#1)4\b:trc}}%
   \else
     |<cond toc config|>%
   \fi
}
>>>



\<cond toc config\><<<
\def\:temp{#4}\ifx \:temp\empty \else
   \expandafter\pend:defIII\csname toc#1\endcsname{#4####3}%
\fi
\def\:temp{#3}\ifx \:temp\empty \else
   \expandafter\pend:defIII\csname toc#1\endcsname{#3####2}%
\fi
\def\:temp{#2}\ifx \:temp\empty \else
   \expandafter\pend:defIII\csname toc#1\endcsname{#2####1}%
\fi
>>>

\<blocs for tocs\><<<
\def\:tocPreamble#1,{%
  \def\:temp{#1}\ifx \:temp\empty     \else
     \edef\:temp{\expandafter\string\csname toc#1 \endcsname}%
     \expandafter\expandafter\expandafter\let
        \expandafter\csname\:temp\endcsname|=\empty
     \expandafter\:tocPreamble\fi}
>>>














\SubSection{Collecting the Entries}

After producing the table of contents from the previous compilation,
a file is opened for collecting the entries of the table from the
current compilation. 

\<blocs for tocs\><<<
\ifx \:tocout\:UnDef
   \csname newwrite\endcsname\:tocout    
\fi
\def\:temp{%
|<if latex then latex/write sol|>\openout\:tocout|=\jobname.4tc
   |<doTocEntry for dvi|>}
\:temp
>>>

In case we switch from html to dvi mode, without the presence of
TeX4ht,  we want to hide the \''\doTocEntry'..
The \`'\escapechar' decides what is written out for escape character,
no matter what the actual symbol is. texinfo changes that symbol to 
{\tt \string\escapechar=`\string\@}.

\<doTocEntry for dvi\><<<
{\escapechar=`\\|<if latex then latex/write sol|>\write
   \:tocout{\string\expandafter\string\ifx 
   \noexpand\csname doTocEntry\string\endcsname\relax
      \string\expandafter\string\endinput
   \string\fi}%
}%
>>>




\Section{Triggered Tables of Contents}

The \`'\TocAt-{...}' command asks for no TOC, the \`'TocAt*{...}'
command asks for a TOC delayed until the next section, \`'\TocAt{...}'
asks for TOC in place, and a list of size one asks for no more local
TOC's for the given logical unit.

\<blocs for tocs\><<<
\def\TocAt#1{%
   \def\:next##1{\:TocAt##1,//}%
   \def\:tempa{#1}\def\:temp{-}\ifx \:tempa\:temp  \let\:temp|=-%
   \else \def\:temp{*}\ifx \:tempa\:temp           \let\:temp|=*%
   \else    \def\:next{\:TocAt#1,//}%
   \fi \fi  \:next }
>>>





\<Toc:At>\><<<
\expandafter\edef\csname Toc:#1\endcsname{%
   \gdef\expandafter\noexpand\csname TocAt*\endcsname{%
      \noexpand \csname Toc#1\noexpand\endcsname }}%
>>>

\<Toc:At\><<<
\expandafter\edef\csname Toc:#1\endcsname{%
    \noexpand\csname Toc#1\noexpand\endcsname }%
>>>

\<blocs for tocs\><<<
\def\:TocAt#1,#2//{%
   \ifx -\:temp \else \ifx *\:temp
           |<Toc:At>|>%
   \else   |<Toc:At|>\fi \fi 
   \def\:temp{#2}\ifx  \:temp\empty
      \expandafter\let\csname Toc#1\endcsname|=\:UnDef
   \else |<extract the entries|>\fi }
>>>

\SubSection{Process the Request}

For \`'\TocAt{X,...,Y,...}'  we define a \''\TocX' that includes the
interpretations for the different \''\tocY' w of Xithin commands of
the form \`'X::tocY'.



\<extract the entries\><<<
\let\:include|=\empty
\::TocAt#1,/#1,#2,,//%
\edef\:include{\expandafter\:removecomma\:include}%
\expandafter\edef\csname Toc#1\endcsname{{%
   \let\noexpand\TitleCount|=\expandafter\noexpand
                                \csname #1:Count\endcsname
   \noexpand\:assgtoc\:include,//{#1}%
   \:tocs[\:include]}}%
>>>



\SubSection{Process the Request}

\<blocs for tocs\><<<
\def\:tocs{\noexpand\TableOfContents}
>>>




\<blocs for tocs\><<<
\def\:removecomma#1{}
\def\:assgtoc#1,#2//#3{%
   \expand:after{\expandafter\let\csname toc#1\endcsname |=}%
                                 \csname #3::toc#1\endcsname
   \if:notempty{#2}{\:assgtoc#2//{#3}}}
>>>

\<blocs for tocs\><<<
\def\::TocAt#1,#2,#3//{\def\:temp{#2}%
   \ifx  \:temp\empty \else
      \if /\:firstch#2 //%
               |<stop toc for @1 at @2|>%
      \else    |<include @2 in toc for @1|>\fi
      \expand:after{\::TocAt#1,#3//}%
   \fi
}
>>>

\SubSection{Interpretation for Included Entry}

Also for \`'\TocAt{X,....,Y,...}'  the interpretation is
defined in  \`'X::tocY'.


\<include @2 in toc for @1\><<<
\edef\:include{\:include,#2}%
\expand:after{\expandafter\let\csname svtoc::#2\endcsname|=}%
                                     \csname toc#2\endcsname
\expandafter\edef\csname #1::toc#2\endcsname##1##2##3{%
   \noexpand\ifnum  \noexpand\TitleCount<\noexpand\TocCount
                                                        \noexpand\space
      \expandafter\noexpand \csname svtoc::#2\endcsname{##1}{##2}{##3}%
   \noexpand\fi}%
>>>


Tex4ht relies on two counters \`'\TitleCount' and \`'\TocCount' to
decide which entries of the global TOC should go to the local TOC.
The first counter is increased when sectioning commands are
encountered. The second counter is increased when the global TOC is
traversed.

A discrepancy will occur when the contributions of the sectioning
commands to the global TOC are not synchronized with the increments of
the first counter.  That will normally be the case when sectioning
commands are introduced without tex4h being informed about their
designation as sectioning commands.


\SubSection{End Points}


Also for \`'\TocAt{X,....,/Y,...}'  the termination point that we get is
defined in  \`'X::tocY'.

\<blocs for tocs\><<<
\def\:firstch#1#2 //{#1\def\:temp{#2}}
>>>


\<stop toc for @1 at @2\><<<
\edef\:include{\:include,\:temp}%
\expandafter\def\csname #1::toc\:temp\endcsname##1##2##3{%
   \ifnum \TitleCount<\TocCount 
       \Advance:\TocCount |by -100000   \endinput
   \fi}%
>>>

The \''\endinput' is not required but it desired because it cuts off
the reading of the toc file.  The \''-100000' is needed
forhierarchical toc's due to parent-child relashions.





%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Chapter{halign-based tables}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\<halign-based tables\><<<
|<all halign-based tables|>
|<html blocks for halign tables|>
|<html halign|>
\def\:temp{\let\:shrp|=##} \:temp
>>>

The \''\:shrp' should be defined at the end so as not
to bother other definitions that will regard it as improper
\`'#' parameter.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Taming of halign}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

The \''\halign' comamnds not defined within  TeX4ht  environment
can be problematic, and the same may be true to some within such
environnt. Specifically, comamnds of the form \`'\halign...{...}'
are translated well in TeX4ht, but cause a problem if defined
before TeX4ht was activated.  Commands of the form
\`'\halign...\bgroup...' cause no problem in either mode, but they
also introduce no html code.  Commands of the form
\''\halign...{...\egroup' cause problems in either way.

TeX4ht takes care of the \''\halign' commands in TeX and LaTeX,
but not of those that are loaded earlier from other libraries.


The following tree shows the direct and indirect use of \''\halign' in
TeX and LaTeX.

\Draw
\TreeAlign(H,1,0)(0,0,0)
\TreeSpace(D,10,10)
\Tree()(
5,halign//
12,ialign{(T,L)} & 0,displaylines{(T,L)} &
   0,eqalignno{(T)} & 0,leqalignno{(T)} &
   0,eqnarray{(L)}//
0,m@ketabbox{(T)} & 0,oalign{(T,L)} & 0,angle{(T,L)} &
   0,overrightarrow{(T,L)}~~\hfill overleftarrow{(T,L)}~~
   \hfill overbrace{(T,L)}~~\hfill underbrace{(T,L)} &
   0,@vereq{(T,L)} & 0,cases{(T,L)} & 0,matrix{(T)} & 0,bordermatrix{(T,L)} &
   0,eqalign{(T)} & 0,@array{(L)} & 0,@ishortstack{(L)} &
   0,table{(L)}//
)

\EndDraw


The \`'\iffalse{\fi...\iffalse}\fi' is to hide the \`'\cr' from 
\''\halign' when it scans for that command.


\<all halign-based tables\><<<
\let\TeXhalign|=\halign
\def\RecallTeXcr{\iffalse{\fi
   \expand:after{\let\cr|=}\csname 0cr\endcsname
   \expand:after{\let\crcr|=}\csname 0crcr\endcsname
   \iffalse}\fi}
\expandafter\let\csname 0cr\endcsname|=\cr
\expandafter\let\csname 0crcr\endcsname|=\crcr
\def\TeXhalign:cr{%
   \ifx \EndPicture\:UnDef \else \iffalse{\fi
      \expandafter\let\expandafter\cr\csname \MkHalign:d cr\endcsname
      \expandafter\let\expandafter\crcr\csname \MkHalign:d crcr\endcsname
   \iffalse}\fi \fi  \TeXhalign}
>>>


 Save/recover \''\crcr' and \''\cr' causes problems, e.g., in nested arrays.
It seems also we don't really need such a feature.




\<tex4ht halign and cr/crcr\><<<
\let\halign|=\sv:halign
>>>




%\edef\TeXhalign:cr{%
%   \noexpand\ifx \noexpand\EndPicture\noexpand\:UnDef \noexpand\else
%      \let\cr|=\expandafter\noexpand\csname 0cr\endcsname 
%      \let\crcr|=\expandafter\noexpand\csname 0crcr\endcsname 
%   \noexpand\fi  \noexpand\TeXhalign}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Building Blocks for Accessing Halign Tables}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


The next comamnd can be in use when the parameters \`'#' (i.e.,
the first parameter \''#1') are in cat code 13.


We hade \''\:relax' instead of \''\relax' below. Where did it come
from?


The \''\MkHalign' takes the form
\`'\MkHalign#{...pattern...}...body...\EndHalign' and seeds the end
tags \''\a:halign' and \''\b:halign' around the construct, and
\''\c:halign' and \`'d:halign' in the pattern. The outcome is a seeded
\`'\halign{...}'.  The \`'\Configure{MkHalign}...'  places
\''a:MkHalign', \''b:MkHalign', \''c:MkHalign', \''d:MkHalign',
\''e:MkHalign', and \''\f:MkHalign' within  \''\a:halign',
\''\b:halign', \''\c:halign', and \`'d:halign'. The \`'#' in the
pattern can be any character of category code 13. The \`'&' charaters
shouldn't be within braces. The \''\RecallTeXcr' should appear 
before \''\MkHalign'; if it appears within the pattern, we loose
the row breaks.



\<html blocks for halign tables\><<<
\def\MkHalign#1#2{%
  \iffalse{\fi   \let\sv:new:row|=\new:row   
  \def\relax:shrp{\let#1|=\relax}%
  \def\new:halign{\TeXhalign \bgroup}%
  \add:halign#2&|<par del|>\cr
  \let#1|=\:shrp  |<before TeXhalign|>%
  \iffalse}\fi      |<protection for $$|>%
  \a:PauseMkHalign \new:halign\ext:cr}
\def\EndMkHalign{\egroup
   \d:PauseMkHalign |<end protection for $$|>%
   \iffalse{\fi |<after TeXhalign|>\relax:shrp \iffalse}\fi }
\def\PauseMkHalign#1{\cr\egroup
   \hbox{\r:halign \global\let\new:row|=\R:halign}\b:PauseMkHalign
   #1\c:PauseMkHalign\new:halign\ext:cr}
>>>

\<shared config\><<<
\NewConfigure{PauseMkHalign}{4}
>>>


The PauseMkHalign provides a vehicle to decompose a
\''\halign\bgroup...0......1...\egroup' and recompose it in arbitrary order and
choise of components, as is the case in longtable:
\`'\setbox0=\hbox{\halign\bgroup...0...\egroup}
\setbox1=\hbox{\halign\bgroup...1...\egroup}\box0\box1'. In some
occasions, and may be all, the parameter of \''\PauseMkHalign' must be
just boxes.

The \`'\iffalse ...\fi'  above are for hiding \''\cr' in
nested cases (e.g., of \''\tabular' in LaTeX).

Spans over N columns require many compilations to
realize them.  

The following is an application of \''\MkHalign'.
it allows for tables of the form \`'\MiniHalign...\EndMiniHalign'
instead of \`'\halign{...}'.

\<html blocks for halign tables\><<<
                            \catcode`\#|=13 \catcode`\@|=6
\def\MiniHalign{\begingroup  \catcode`\#|=13 \let#|=\relax
   \:MHalign}
\def\:MHalign@1\cr{\endgroup  \SaveMkHalignConfig
   \Configure{MkHalign}{\a:MiniHalign}{\b:MiniHalign}\c:MiniHalign
   \d:MiniHalign{\e:MiniHalign\RecallMkHalignConfig}\f:MiniHalign
   \MkHalign#{@1}}
                             \catcode`\#|=6 \catcode`\@|=11
\def\EndMiniHalign{\EndMkHalign  \RecallMkHalignConfig }
>>>

\<shared config\><<<
\NewConfigure{MiniHalign}{6}
>>>



\ifHtml[\HPage{test data}\Verbatim

   \documentclass{article}
 
   \input tex4ht.sty   \Preamble{html}
   \begin{document}
   \EndPreamble

\begin{tabular}{c|}
before
    \begin{tabular}{c|}          center    \end{tabular}
after
\end{tabular}

\end{document}
\EndVerbatim\EndHPage{}]\fi


\<protection for $$\><<<
\begingroup  
\ifmmode  \def\end:m{$$\egroup}\vtop\bgroup$$\else
\let \end:m|=\empty\fi
>>>


\<end protection for $$\><<<
\end:m\endgroup
>>>


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\SubSection{Build Expanded Pattern}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Break the pattern at \`'&'s and enclose with calls for html
code.

\<html blocks for halign tables\><<<
\def\add:halign#1&#2\cr{%
   \def\:temp{#2}\def\:tempb{|<par del|>}%
   \ifx \:temp\:tempb 
      \append:def\new:halign{\b:halign#1\c:halign}%
   \else
      \def\:temp{#1}\ifx\:temp\empty \append:def\new:halign{&}%
      \else  \append:def\new:halign{\b:halign#1\c:halign&}\fi
      \add:halign#2\cr
   \fi}
>>>


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\SubSection{Html Insertions}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



\<before TeXhalign\><<<    
\global\let\new:row|=\R:halign   
\Advance:\MkHalign:d |by 1
\expandafter\let\csname \MkHalign:d cr\endcsname|=\cr  
\expandafter\let\csname \MkHalign:d crcr\endcsname|=\crcr
\edef\cr{\noexpand\rR:halign 
   \expandafter\noexpand \csname \MkHalign:d cr\endcsname}%
\edef\crcr{\noexpand\rR:halign 
   \expandafter\noexpand \csname \MkHalign:d crcr\endcsname}%
\let\omit|=\om:t \def\TT:halign{\T:halign \global\let\TT:halign|=\empty}%
>>>

Inserting \''\T:halign' here causes infinite loop in \''\@array'
of latex.  Hence, we delay it to the stat of the first element.

\<after TeXhalign\><<<
\expand:after{\let\cr|=}\csname \MkHalign:d cr\endcsname
\expand:after{\let\crcr|=}\csname \MkHalign:d crcr\endcsname
\let\omit|=\:omit
{\ht:everypar{}\r:halign}\t:halign 
\Advance:\MkHalign:d |by -1
>>>

\<html blocks for halign tables\><<<
\def\rR:halign{\gdef\new:row{\r:halign \R:halign}}
\HAssign\MkHalign:d |= 0
>>>





\<html blocks for halign tables\><<<
\def\b:halign{\BB:halign \bgroup}
\def\c:halign{\egroup\d:halign}
\def\BB:halign{\expand:after{\global\let\new:row|=\empty }\new:row 
   \D:halign}
>>>

The \''\Configure' may use the values of \''\:MULTISPAN', \''\halignTD', 
\''\HRow'' and \''\HCol'.  The \''\halignTD' gets its value from
\''\Configure{TD}{...}'.


\<html config util\><<<
\def\halignTD{\ifx \:mALIGN\empty \hT:D \else \:mALIGN \fi}
\def\halignTB#1{
   \expandafter\ifx \csname :#1:\endcsname\relax
      \:warning{Missing \string\Configure{halignTB<>}{#1}}%
   \else
      \global\expandafter\let\expandafter\:MkHalign:
      \csname :#1:\endcsname \a:halignTB \expandafter\expandafter
      \expandafter\halign:TB \csname :#1:\endcsname|<par del|>\b:halignTB
   \fi }
\NewConfigure{halignTB}{2}  
\NewConfigure{halignTB<>}[2]{%
   \expandafter\def\csname :#1:\endcsname{#2}}  
|<init :MkHalign:|>
>>>

\<html config util\><<<
\NewConfigure{MkHalign}[6]{%
   \def\T:halign{\PushMacro\:MkHalign:|<init :MkHalign:|>#1}%
   \def\t:halign{#2\PopMacro\:MkHalign:
                 \global\let\:MkHalign:|=\:MkHalign:}%
   \def\R:halign{\TT:halign \gHAdvance\HRow |by 1 \gHAssign\HCol|=1
      #3}%
   \def\r:halign{\end:omit#4}%
   \def\D:halign{\:nopartrue
      |<save dH|>%
      |<cond TD for multispan|>%
      \ifnum\MS:count=\ifx \:MULTISPAN\:UnDef \MS:count
                      \else                  \:MULTISPAN\fi
         \expandafter\gdef\csname dH\MkHalign:d\endcsname
            {|<cond /TD for multispan|>}\fi}%
   \def\d:halign{\csname dH\ifnum \MkHalign:d<1 1\else \MkHalign:d\fi
                 \endcsname |<recall dH|>}}
\Configure{MkHalign}{}{}{}{}{}{}
\HAssign\dH:cnt|=0
>>>

\<save dH\><<<
\gHAdvance\dH:cnt by 1
\edef\:tempa{\global\let\expandafter\noexpand\csname xc\dH:cnt\endcsname
       \expandafter\noexpand\csname dH\MkHalign:d\endcsname}%
\:tempa
\expandafter\xdef\csname \dH:cnt :tempa\endcsname{%
   \global\let \expandafter\noexpand\csname dH\MkHalign:d\endcsname
       \expandafter\noexpand\csname xc\dH:cnt\endcsname}%
>>>

\<recall dH\><<<
\csname \dH:cnt :tempa\endcsname 
\gHAdvance\dH:cnt by -1 
>>>

Nonleading \`'\csname dH\MkHalign:d\endcsname' produce improper closing
delimiters in \`'\multispan' of index $>$ 1.  In such cases, only the
outcome of the first \`'\D:halign' contribute for the openning
delimiter---occuring in the iteration in which
\`'\MS:count=\:MULTISPAN'.

The \`'\ifnum \MkHalign:d<1 1\else \MkHalign:d\fi' is needed because we
can get down to 0 if the last entry is a \''\multispan'.




\<math config util\><<<

>>>

\<init :MkHalign:\><<<
\Configure{halignTB<>}{MkHalign}{<>}%
>>>



The saving \`'\csname dH\MkHalign:d\endcsname' and loading is to
protect from changes that may occur inside the entity in the meaning
of \''\d:halign'. Don't we need the same for \''\r:halign'?

The following is for tracing users definitions to be used in extensions
that need to do reverse eng of the users input.


\<shared configNO\><<<
\NewConfigure{TraceTables}[8]{\def\trc:T{#1}\def\trc:eT{#2}%
   \def\trc:t{#3}\def\trc:et{#4}\def\trc:R{#5}\def\trc:eR{#6}%
   \def\trc:r{#7}\def\trc:er{#8}\d:TrcHlgn}
\def\d:TrcHlgn#1#2#3#4{\def\trc:D{#1}\def\trc:eD{#2}%
   \def\trc:d{#3}\def\trc:ed{#4}}
>>>


The \''\:removeindenttrue' is important, for instance, in case of
a \''\noalign{...}'.

When we meet \`'&&', which signals a loop. 


We place \''#' under catcode 13.  \''\noalign' is ignored.



\<html blocks for halign tables\><<<
\def\SaveMkHalignConfig{\let\sT:halign|=\T:halign
   \let\st:halign|=\t:halign
   \let\sR:halign|=\R:halign
   \let\sr:halign|=\r:halign
   \let\sD:halign|=\D:halign
   \let\sd:halign|=\d:halign}
\def\RecallMkHalignConfig{\let\T:halign|=\sT:halign
   \let\t:halign|=\st:halign
   \let\R:halign|=\sR:halign
   \let\r:halign|=\sr:halign
   \let\D:halign|=\sD:halign
   \let\d:halign|=\sd:halign}
>>>



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\SubSection{/omit and /span}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\<html blocks for halign tables\><<<
\let\:omit|=\omit
\def\om:t{\:omit \BB:halign 
   \gdef\end:omit{\gdef\end:omit{}\d:halign}}
\let\end:omit|=\empty
>>>


A \''\multispa' is a sequence of \''\span''s.  Each \''\span' 
puts \`'\HRow.\HCol;' in \''\new:span;'. Next compilation
retrieves this info to compute \''\:MULTISPAN'.


\<cond TD for multispan\><<<
\gHAdvance\MS:count |by -1
\ifnum \MS:count > 0  \else 
   \end:omit  \relax:shrp     \derive:TD 
   \HAssign\:MULTISPAN|=1  \let\:mALIGN|=\empty
   \expandafter\add:span\old:span \gHAssign\MS:count|=\:MULTISPAN 
   \relax #5%
\fi
\xdef\Step:Col{\ifx \HMultispan\:UnDef 1 \else \HMultispan\fi}%
>>>

\<cond /TD for multispan\><<<
\ifnum \MS:count<2 #6\relax 
 \gHAdvance\HCol  \Step:Col\relax \fi
>>>






% \ifnum \MS:count<2 #6 \gHAdvance\HCol |by 1 \fi


For some reason \`'\if:latex\@multicnt\else\mscount\fi'
didn't work for \''\MS:count>0' on

\Verbatim
\halign{#\qquad& \$# each\cr
\omit\span\omit\hfil 
   Shipping Charges\hfil\cr
1--10&1.30\cr11--100&1.00\cr
111--&0.70\cr}
\EndVerbatim


Tried to put \`'\iffalse{\fi \let\cr|=\ext:cr \let\crcr|=\ext:crcr
 \iffalse}\fi ' at start of cell.  It didn't work, because I couldn't
 restore the \''\cr' and \''\crcr' before the \''\cr' is read at end
 of line.  This doesn't look like an important because
 the redefined version just has a \''\gdef' in it and produces no code
 of itself. However, it is important because problems sometimes
arise if a nonnative instance is present, for instance, in
\`'\openup10pt \halign{
 $2^{#}$\quad&
 $\overbrace{2\cdots 2}^{#
     \rm times}$\quad& #\cr
 2&2&4\cr 3&3&8\cr }
'.


See Knuth 386 for the
 hiding
\`'\iffalse{\fi\let\cr|=\ext:cr\iffalse}\fi ' of \''\cr'.

\<html blocks for halign tables\><<<
\let\ext:cr|=\cr  \let\ext:crcr|=\crcr
>>>

\<html blocks for halign tables\><<<
\let\:span|=\span 
\def\add:span#1;{\def\:tempa{#1}\edef\:temp{\HRow .\HCol}%
   \ifx \:temp\:tempa \Advance:\:MULTISPAN |by 1 \fi
   \ifx \:tempa\empty \let\HMultispan|=\:MULTISPAN
   \else
      |<align for multispan in latex|>%
      \expandafter\add:span
   \fi }
>>>







\<align for multispan in latex\><<<
\let\:temp|=\relax
\def\:temp##1.{\def\:temp####1|<par del|>{\def\:temp{####1}}%
   \afterassignment\:temp\tmp:cnt}%
\expandafter\expandafter\expandafter\:temp\expandafter\:tempa|<par del|>%
\edef\:tempb{\HRow.\HCol\:temp}\ifx\:tempa\:tempb
   \expandafter\ifx \csname \expandafter\string\:temp :T:D\endcsname\relax
   \else \edef\:mALIGN{\expandafter\noexpand
          \csname \expandafter\string\:temp :T:D\endcsname}%
\fi\fi
>>>

\<NO\><<<
\edef\:temp{\HRow .\HCol<}%
\ifx \:temp\:tempa \def\:mALIGN{\l:TD}\fi
\edef\:temp{\HRow .\HCol-}%
\ifx \:temp\:tempa \def\:mALIGN{\c:TD}\fi
\edef\:temp{\HRow .\HCol>}%
\ifx \:temp\:tempa \def\:mALIGN{\r:TD}\fi  
>>>



\<before TeXhalign\><<<    
\let\sv:end:omit|=\end:omit  \let\end:omit|=\empty
\let\ms:count|=\MS:count \HAssign\MS:count|=0
\let\lgn:r|=\HRow \let\lgn:c|=\HCol  \HAssign\HRow|=0 
\def\span{\xdef\new:span{\new:span\HRow.\HCol;}\:span}%
\let\sv:new:span|=\new:span  \let\new:span|=\empty 
\gHAdvance\Halgn:cnt |by 1 \edef\halign:id{\Halgn:cnt}%
\edef\old:span{\LikeRef{|<halign tag|>}}%
\ifx \old:span\space \def\old:span{;}\fi
>>>

The \`'\ifx \old:span\space \def\old:span{;}\fi' is needed for first
runs when no info is yet available.

\<after TeXhalign\><<<    
\Tag{|<halign tag|>}{\new:span;}%
\global\let\new:span|=\sv:new:span  
\iffalse{\fi \let\span|=\:span \iffalse}\fi
\global\let\HRow|=\lgn:r   \global\let\HCol|=\lgn:c
\global\let\MS:count|=\ms:count 
\global\let\new:row|=\sv:new:row 
\global\let\end:omit|=\sv:end:omit
>>>

\<html blocks for halign tables\><<<
\HAssign\Halgn:cnt|=0
>>>




The \''\mu:span' Provides a little movement to 
avoid oscilation of multi spans around incorrect values.
It is attached to \''\TitleCount' ingeneral, but not
within \`'\begin{longtable}...\end{longtable}'.
In that environment, \''\caption' may appear, and so change
the value of \''\TitleCount' in the middle of a table, within
a \''\multispan'.




\<halign tag\><<<
|<auto tag|>M\halign:id x\mu:span>>>


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\SubSection{TD Script}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Through \''\Configure{MkHalign}{....}' with entries of the form 
\`'row col insertion '  (space at end:
 \`'\Contribute{halignTD}{1 1 - }' is fine but
not \`'\Contribute{halignTD}{1 1 -}'. The first character may be a
code
\''<', \''-', \''>', \''^', \''=', \''-', or \''_'. A row of
value 0 applies for a full column, a column of 0 stands for a full
row, and row and col of 0 stand for a full table. 




\<html blocks for halign tables\><<<
\def\derive:TD{%
   \bgroup \no:actv    
       \xdef\:temp{\noexpand\expandafter\noexpand\:temp   
               \noexpand\halign:TD\:MkHalign: -0 0 1 |<par del|>}%
   \egroup  
   \let\hT:D|=\:temp
   \def\:temp##1 ##2 ##3 {\ifnum -1=##1##2##3 \else
      |<process TD op|> \expandafter\:temp \fi}%
   \def\:tempa##1\empty{}%
   \edef\hT:D{\hT:D}}
>>>





\<process TD op\><<<
\ifnum \HRow=##1 \ifnum \HCol=##2 \:TDcode ##3\fi\fi 
\ifnum \HRow=##1 \ifnum    0=##2 \:TDcode ##3\fi\fi 
\ifnum     0=##1 \ifnum \HCol=##2 \:TDcode ##3\fi\fi 
\ifnum     0=##1 \ifnum    0=##2 \:TDcode ##3\fi\fi 
>>>

\<html blocks for halign tables\><<<
\def\:TDcode#1{|<process TD code|>\EndTD:CLASS}
                             \catcode`\_=13  \catcode`\^=13
\pend:defI\:TDcode{\TD:CLASS}%
\let\:temp|=\relax \let\:tempa|=\relax
\edef\no:actv{\let\noexpand\noexpand\noexpand^|=\:temp
   \let\noexpand\noexpand\noexpand_|=\:tempa}
                              \catcode`\_=8  \catcode`\^=7
\def\:temp{^}  \def\:tempa{_}
\edef\no:actv{\no:actv}
>>>


\<html blocks for halign tablesNOOO\><<<
\def\:TDcode#1{|<process TD code|>\EndTD:CLASS}
                             \catcode`\_=13  \catcode`\^=13
\pend:defI\:TDcode{\TD:CLASS
   \ifx _##1 \o:TD \expandafter\:tempa \fi
   \ifx ^##1 \t:TD \expandafter\:tempa\fi}%
\let\:temp|=\relax \let\:tempa|=\relax
\edef\no:actv{\let\noexpand\noexpand\noexpand^|=\:temp
   \let\noexpand\noexpand\noexpand_|=\:tempa}
                              \catcode`\_=8  \catcode`\^=7
\def\:temp{^}  \def\:tempa{_}
\edef\no:actv{\no:actv}
>>>





\<process TD codeOLDTD\><<<
\ifx <#1  \l:TD \expandafter\:tempa \fi
\ifx -#1  \c:TD \expandafter\:tempa \fi
\ifx >#1  \r:TD \expandafter\:tempa \fi
\ifx ^#1  \t:TD \expandafter\:tempa \fi
\ifx =#1  \b:TD \expandafter\:tempa \fi
\ifx ||#1 \m:TD \expandafter\:tempa \fi
\ifx _#1  \o:TD \expandafter\:tempa \fi
\ifx p#1  \p:TD \expandafter\:tempa \fi
\expandafter#1\empty
>>>



\<process TD code\><<<
\expandafter
   \ifx \csname \string#1:T:D\endcsname\relax \else
     \csname \string#1:T:D\endcsname \expandafter\:tempa \fi
\expandafter#1\empty
>>>


\<html config util\><<<
\NewConfigure{halignTD}[2]{\c:def\TD:CLASS{#1}%
   \c:def\EndTD:CLASS{#2}\scan:halignTD}
\def\scan:halignTD#1{\def\:temp{#1}\ifx \:temp\empty\else
    \expandafter \sc:halignTD\fi{#1}}
\def\sc:halignTD#1#2{\expandafter\def\csname 
   \string#1:T:D\endcsname{#2}\scan:halignTD}
>>>


We could also have used \`'\Configure{halignTD}  {CLASS="NOWRAP}{"}
   { LEFT}{ CENTER}{ RIGHT}
   { TOP}{ BASELINE}{ MIDDLE}{ BOTTOM}' fot DTD4.0s.


\<html config util\><<<
\NewConfigure{halignTR}[1]{\def\halignTR{#1}}
\Configure{halignTR}{}
>>>

\<html config util\><<<
\def\halignTBL{\expandafter\ifx \csname v:TBL\endcsname\relax
   \else \expandafter\ifx \csname \v:TBL :T:BL\endcsname\relax\else
       \csname \v:TBL :T:BL\endcsname
   \fi\fi}
\NewConfigure{halignTBL}[1]{\scan:halignTBL{#1}}
\def\scan:halignTBL#1{\def\:temp{#1}\ifx \:temp\empty\else
    \expandafter \sc:halignTBL\fi{#1}}
\def\sc:halignTBL#1#2{\expandafter\def\csname 
   \string#1:T:BL\endcsname{#2}\scan:halignTBL}
>>>


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\SubSection{Utilities}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%





The global is because the table starts within the first entry.

\<html blocks for halign tables\><<<
\def\halign:TB#1<>#2|<par del|>{#1}
\def\halign:TD#1<>#2|<par del|>{#2}
>>>







%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{A Realization for halign}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\<html halign\><<<
\:CheckOption{no-halign} \if:Option \else
   |<halign tables from TeX|>
\fi
>>>



This is the corner stone for deciding the case.


\HTable{
[C10]Witin Picture Environment?\cr
Y&[C10]tex:align\cr
N&[10]within edef (:halign)?\cr
 &Y&tex halign\cr
 &N&[C10]remove `to dim' (:hlgn: + hl:gn)\cr
 &&[C10]change catcode of {\tt \char`\#} (hlg:n)\cr
 &&[C10]within a parameter or a def? (hal:gn)\cr
 &&Y&[C10]tex:align + PRE\cr
 &&N&[C10]open delimiter? (:Hlign)\cr
 &&&{\tt\string\bgroup}&[C10]tex:align + PRE\cr
 &&{\tt\char`\{}&[C10]go for hypertext table\cr
}






Check whether we are in \''\Picture' environment. This can happen
implicitly through environment \`'\[...\]' or through nesting in a
construct that explicitly activates the picture mode.

\<halign tables from TeX\><<<
\def\h:halign{\ifx \EndPicture\:Undef
                \let\to:dim|=\empty  \expandafter\:halign
            \else                    \expandafter\TeXhalign:cr\fi}
\:CheckOption{base}  \if:Option  \else 
    \def\:temp{\Protect\h:halign}
    \HLet\halign|=\:temp
\fi
>>>

\SubSection{Check for /edef Environment}

ENSURE that for cases that reduce to \`'\TeXhalign:cr' the
macro get into edef.






\<halign tables from TeX\><<<
\let\r:lax|=\relax
\def\r:relax{\r:lax}
\let\rl:x|=\relax
\def\:halign{%
   \let\rl:x|=\r:relax
   \ifx \rl:x\r:relax  \expandafter\nodim:hlgn: |%halign not in edef|%
   \else               \expandafter\TeXhalign:cr   |%halign in edef|%
   \fi
}
>>>

\SubSection{Remove Dimension}

Remove the dimension in case of \`'\halign to dim{...}'
or \`'\halign spread dim{...}' and store in \''\to:dim'.
The dimension can be nested within another macro

\<halign tables from TeX\><<<
\def\nodim:hlgn:{\futurelet\:temp\hl:gn}
\def\hl:gn{\ifx   \:temp\bgroup      \let\:tempa|=\hlg:n
   \else \def\:tempa##1{\append:def\to:dim{##1}\nodim:hlgn:}\fi
   \:tempa}
>>>


Without recording, and using the dimension, 
some pictures can get corrupted. For instance,
an overlap of index with the picture may  
%%
\ifHtml[\HPage{occur}\Verbatim
 \input tex4ht.sty         \Preamble{html}
   \EndPreamble

\catcode`\@=11

\def\eqalignno#1{\displ@y \tabskip\centering
  \halign to\displaywidth{\hfil$\@lign\displaystyle{##}$\tabskip\z@skip
    &$\@lign\displaystyle{{}##}$\hfil\tabskip\centering
    &\llap{$\@lign##$}\tabskip\z@skip\ crcr #1\ crcr}}

\eqalignno{
li&= 1\ cr
&> line 2& (7)}

\ bye 
\EndVerbatim\EndHPage{}]\fi

\SubSection{Check for Embedded Def}

Within macros and parameters, and definitions, the catcode of
characters in general, and \`'#' in particular, can't change. Hence,
in such cases \`'@2' is empty.

\<halign tables from TeX\><<<
                              \catcode`\#|=13  \catcode`\~|=6
\def\hlg:n{\begingroup  \catcode`\#|=13 \let#|=\relax \hal:gn}%
|<process pattern of halign tbl|>
|<halign defs in catcode 13|>
                              \catcode`\#|=6  \catcode`\~|=13
>>>


If catcodes don't change, we can't get
the catcode 13 for processing the parameters, and the empty flag
comes up. 

\<halign defs in catcode 13\><<<
\long\def\hal:gn~1{\p:lgn~1#|<par del|>%
   \ifx \:temp\empty   
       |<embedded halign|>%
   \else \def\:temp{\endgroup\:hlign{~1}}\fi   \:temp}
\long\def\p:lgn~1#~2|<par del|>{\def\:temp{~2}}
>>>

\SubSection{/halign Not Within Parameters}

By now we know that we are not within a picture or embeded in other
macro or a parameter, and that we have \`'\halign\bgroup...\egroup' or
\`'\halign{...}'. We are going to scan \''\bgroup' or
\`'{...}'. 

\<halign tables from TeX\><<<
\long\def\:hlign#1{%
    \def\:temp{#1}\def\:tempa{\bgroup}\ifx \:temp\:tempa
       \endgroup  |<halign into pre|>%
         \expand:after{\HRestore\noalign \TeXhalign:cr\bgroup}%
    \else |<halign into MkHalign|>%
    \fi}
>>>



\<halign into pre\><<<
\:warning{\noexpand\halign translated into linear text}%
>>>


In the above if statement, \''\expandafter' does not work for nested
halign in the true part.

If we scan \''\bgroup' we are going after all to use the original
definition of \''\halign'. Otherwise, we are going for \''\HTable',
and for such a case we want the following environment.  The variable
\`'#' controls where patterns should be included in entries and it is
used for spliting the patterns into the two parameters of
\`'\HTableScript'.





\SubSection{Embedded /halign}

The \''\halign' are transformed into pictures
or  \''\TeXhalign:cr'.

We now have a command of the form \`'\halign\bgroup...' or
a break up on a case of the form  \`'\halign{...body...'.
The parameter \`'~1' is either  \''\bgroup' or \`'...body...'.
If we are lucky, the body doesn't start with a \`'#' or \''\bgroup'.

\<embedded halign\><<<
\expandafter\chs:halgn\string ~1|<par del|>%
\:tempb{%
   \csname a:embedded-halign\endcsname
      \ifmmode
        \vbox{|<recall sharp|>$$\TeXhalign:cr \to:dim{~1}$$}%
      \else \vbox{|<recall sharp|>\TeXhalign:cr \to:dim{~1}}\fi
      \:nopartrue
   \csname b:embedded-halign\endcsname
 }%
\let\:temp|=\endgroup
\:tempb|<par del|>%
\:tempb\:temp{\endgroup
   |<halign into pre|>%
   \HRestore\noalign  \TeXhalign:cr~1}\:tempa|<par del|>%
>>>

\<halign tables from TeX\><<<
\NewConfigure{embedded-halign}{2}
\Configure{embedded-halign}
    {\expand:after{\Picture+}\pic:hlng{ \a:@Picture{pic-halign}}}
    {\EndPicture}
>>>

The \`'\vbox{|<recall sharp|>\TeXhalign:cr \to:dim{@1}}' is needed to
keep the picture in one page.  Without this we get from tex4ht.c
\ifHtml\HPage{complaints}\Verbatim
\documentclass{book}

\input tex4ht.sty 
  \Preamble{html} 
\begin{document}  

\EndPreamble

\halign{\empty{#}&&{#}\cr phi&varphi\cr}
\end{document}

\EndVerbatim  \EndHPage{}\fi{} of mismatches \`'\specals{+}' (due to split 
over pages?).

An \''\halign{...}' can be in math mode  \`'$$....$$', but
not within inline math mode. If it is there, there are quite
a few restctions (not clear of which kind) on what can appear in the math 
code outside the \`'\halign'.  Hence, we put everything into math mode
in a sepearte box just for an extra precaution.

%     \:warning{\noexpand\halign translated into a picture}


\''\TeXhalign:cr' reestablishes the meaning of \''\cr' and \''\crcr'
for picture-mode, but not for the second one.  The later case 
may cause problems.


Pictures might be called for also with \`'#' having catcode 13,
as is the case with \`'\halign{\empty{#}&&{#}\cr phi&varphi\cr}'
(but not with
\`'\halign{\empty #&& #\cr phi&varphi\cr}').
In this case, the scanning in \`'\p:lgn@1#|<par del|>%' can't detect
the sharp characters that are embedded in braces. That is, a neccesary
condition for getting tabular representation is at least one \`'#' out
of braces, to ensure that such characters can get catcode 13.



\<recall sharp\><<<
\Rc:sharp
>>>

\<halign tables from TeX\><<<
\catcode`\#=13
\def\Rc:sharp{\let#=\sv:sharp}
\catcode`\#=6
\def\:temp{\let\sv:sharp=##}\:temp
>>>

\SubSection{Utilities fo Embedded /halign}

\<halign tables from TeX\><<<
\def\chs:halgn#1{\def\:temp{#1}%
   \def\:tempa##1##2##3##4##5{\def\:tempa{##1}\def\:tempb{##2}%
      \def\:tempc{##3}\def\:tempd{##4}\def\:tempe{##5}}%
   \expandafter\:tempa\string\bgro
   \ifx \:temp\:tempa \expand:after{\expandafter\try:b\string}%
   \else              \expandafter\brc:halign \fi}
\def\try:b{\try:ch\:tempb\try:g}
\def\try:g{\try:ch\:tempc\try:r}
\def\try:r{\try:ch\:tempd\try:o}
\def\try:o#1{\def\:temp{#1}%
   \ifx \:temp\:tempe \def\:tempb{|<bgroup halign|>}%
   \else  \let\:temp|=\empty
          \def\:tempb{|<braced halign|>}\fi
   |<tempa = consume the rest of @1|>\:tempa}
\def\try:ch#1#2#3{\def\:temp{#3}%
   \ifx \:temp#1 \expand:after{\expandafter#2\string}%
   \else              \expandafter\brc:halign \fi}
>>>

\<halign tables from TeX\><<<
\def\brc:halign{%
   \let\:temp|=\empty   \def\:tempb{|<braced halign|>}%
   |<tempa = consume the rest of @1|>\:tempa}
>>>

\<tempa = consume the rest of @1\><<<
\long\def\:tempa##1|<par del|>{}%
>>>

\<bgroup halign\><<<
\let\:tempb|=\def\:tempa
>>>

\<braced halign\><<<
\let\:tempb|=\:tempa
>>>


\SubSection{/halign into {\tt <PRE>}}




 We temporariliy get out from display mode, because we want the
 \`'<PRE>' before \''\halign' and nothing is allowed before
 \''\halign' in display mode.  The enclosure within table is
to group the content for protection from embedding \''<CENTER>' commands and
the like.


\SubSection{/halign into /MkHalign}


We now have a command of the form \`'\halign{....}' or
a break up on a case of the form  \`'\halign{....\egroup'.



\<halign into MkHalign\><<<
\let\tabskip|=\tmp:dim    \let\hrulefill|=\empty
\let\hidewidth|=\empty    
\expand:after{\h:align#1\cr|<par del|>#1|<par del|>}%
>>>



The pattern of \''\halign' can end with a \''\cr' or a \''\crcr'.  We
first check whether \''\cr' present, and if so whether or not it is
preceded by a \''\crcr'.

\<halign tables from TeX\><<<
\catcode`\#|=13 \catcode`\@|=6
\long\def\h:align@1\cr@2|<par del|>{\def\:temp{@2}\ifx \:temp\empty
   \expandafter\h:alignII \else \crcr:align@1\crcr|<par del|>\fi}
\def\crcr:align@1\crcr@2|<par del|>{\def\:temp{@2}\ifx \:temp\empty
   \expandafter\expandafter\expandafter\h:alignI \else 
   \expandafter\expandafter\expandafter\h:alignII \fi}
\long\def\h:alignI@1\cr@2|<par del|>{%
   \SaveMkHalignConfig |<halign configuration for halign|>%
   \MkHalign#{@1}@2\EndMkHalign \RecallMkHalignConfig}
\def\h:alignII@1\crcr{\h:alignI@1\cr}
\catcode`\#|=6 \catcode`\@|=11
>>>





\<halign configuration for halign\><<<
\Configure{MkHalign}{\hlg:a}{\hlg:b}
   \hlg:c\hlg:d{\hlg:e\RecallMkHalignConfig}\hlg:f
>>>



\<html config util\><<<
\NewConfigure{halign}[6]{\c:def\hlg:a{#1}%
   \c:def\hlg:b{#2}\c:def\hlg:c{#3}\c:def\hlg:d{#4}%
   \c:def\hlg:e{#5}\c:def\hlg:f{#6}}
\NewConfigure{pic-halign}[1]{\def\pic:hlng{#1}}
>>>


\<math config util\><<<
\def\:halign:{<>}
>>>





We must put in at least the \`'<>'.


% [[gif\r:brk]

%%%%%%%%%%%%%%%%%%%%%%%
\SubSection{noalign}
%%%%%%%%%%%%%%%%%%%%%%%%%

In TeX4ht \`'\everycr\noalign' causes a loop because the definition of
\''\halign' includes \''\cr'.  We declare a loop when 100 cycles are
encountered. Another possible problem is due to \''\hline'
which contains \''noalign' at its start.\ifHtml[\HPage{more}\Verbatim
\begin{tabular}{||l|c|c|c||} \hline
\multicolumn{4}{|c|}{\LaTeX\ size changing commands}\\ \hline
Style option         & 10pt (default) & \tt 11pt & \tt 12pt\\ \hline
\end{tabular}
\EndVerbatim\EndHPage{}]\fi

If we want to go for optional \''\noalign' with response to a parameter
in \''\Preamble', we need to take care of places that needs it html interpretation
(in tables?).



\<halign tables from TeX\><<<
|<noalign|>
>>>




\<noalign\><<<
\HAssign\noalign:N|=0
\def\:tempc#1{|<cycle protection fo noalign|>%
   \vtop{\IgnorePar\a:noalign\vtop{\IgnorePar#1}\b:noalign}\cr
   \global\tmp:toks|=\everycr \global\everycr{}\cr   
   \o:noalign:{\global\everycr|=\tmp:toks \gHAssign\noalign:N|=0 }%
 }
\HLet\noalign|=\:tempc
|<another alternative for noalign|>
>>>

We probbaly can remove the cycle protection.

The internal \''\top' is to ensure vertical mode for material which
assumes it. In the extreem, that also prevents infinite loops.

% \h:noalign

\<shared config\><<<
\NewConfigure{noalign-}[2]{\c:def\a:noalign{#1}\c:def\b:noalign{#1}}
>>>

Any reason left for keeping both cases?

\<shared config\><<<
\:CheckOption{no-halign} \if:Option \else
    \NewConfigure{noalign}{2}
\fi
>>>











The \''\Protect' is needed, for instance, in \''\endalignat'
of amstex.tex during a pre-edef stage.

The looping can happen in
\''\displaylines', \''\eqalignno', and \''\leqalignno'
due to the first command below (\''\@align'?.).


\<cycle protection fo noalign\><<<
\gHAdvance\noalign:N by 1 
   \ifnum \noalign:N>100 
      \global\let\noalign|=\o:noalign:
      \:warning{TeX4ht can't handle
                  \string\everycr{...\string\noalign...}}%
   \fi    
>>>


Removed \`'\let\dotfill|=\empty'.  Did I have any reason
to put it there in first place?



\Chapter{Verbatim Enviroments}


\<local env\><<<
|<blocs for local env|>
\ifHtml  |<html local env|>
\fi
|<verbatim|>
>>>



\Section{Verbatim Text}




NOTE: VERBATIM WAS THERE for javascript and the like????










\SubSection{Between Paragraphs}

For the option \`'\Verbatim-', it should be noted the requested
special character should not come from the word \`'EndVerbatim'.
Letters within the environment carry categoty code 11, space, tab and
end-of-line characters carry category code 13, and the other
characters have category code 12. {CHECK TABS}

\<verbatim\><<<
\def\V:rbatim{\begingroup \begin:Verb \Verb:env }
\def\:EndVerbatim{\end:Verb \endgroup }
>>>

\<the /EndVerbatim delimiter\><<<
{
\xdef\Verb:atim#1\EndVerbatim{\noexpand\vrb:tt
   \leavevmode#1\noexpand\:EndVerbatim}
\catcode`\/|=0   /catcode`/\|=12
/xdef/Ver:batim#1\EndVerbatim{/noexpand/vrb:tt
   /leavevmode#1/noexpand/:EndVerbatim}
}
>>>

Without the \''/leavevmode' the header is lost when
\''\Verbatim' is followed by empty line. 
\ifHtml[\HPage{test}\Verbatim
\Verbatim

x       

y
        
\ EndVerbatim


\Verbatim       
x       

y
        
\ EndVerbatim

\EndVerbatim\EndHPage{}]\fi



\Verbatim

>  > 5.  Also, why did you go in the first place to `alltt' and
>  >     not `verbatim'?
>
>   Verbatim is an ugly beast. It can't be placed in the argument of
> another environment - e.g., I can't create a new environment like this:
>
> \newenvironment{\test}
>   {\fontsize{11}{12}\selectfont\begin{verbatim}}
>   {\end{verbatim}}

\EndVerbatim








\<html config util\><<<
\NewConfigure{tt}[1]{\let\vrb:tt|=#1}
\let\vrb:tt|=\tt
>>>

\<verbatim\><<<
\def\Verb:env{\no:catcodes0{64}{12}\no:catcodes{65}{90}{11}%
   \no:catcodes{91}{96}{12}\no:catcodes{97}{122}{11}%
   \no:catcodes{123}{255}{12}%
   \catcode`\^^M|=13    \catcode`\ |=13    \catcode`\^^I|=13
   \:Verbatim      \::Verbatim }%
\def\::Verbatim{\futurelet\:temp\V:erbatim}
\def\V:erbatim{%
   \ifx -\:temp  \expandafter\Ve:rbatim 
   \else  \let\start:verb|=\Ver:batim  \expandafter\Ver:sp \fi }
\def\Ver:sp{%
   \ifx \ver:sp\:temp  \expandafter\Ver:assg 
   \else         \expandafter\Ver:ln \fi }
\def\Ver:ln{%
   \ifx \ver:ln\:temp  \expandafter\Ver:assg
   \else         \expandafter\start:verb \fi }
\def\Ver:assg{\afterassignment\start:verb\let\:temp|=}
|<optional control char in /Verbatim|>
|<space and eoln chars in /Verbatim|>
|<the /EndVerbatim delimiter|>
>>>


\<optional control char in /Verbatim\><<<
{
\catcode`\/|=0
/catcode`/\|=12
/gdef/Ve:rbatim#1#2{/catcode`#2|=0 
   /ifx  #2\/let/start:verb|=/Verb:atim
   /else    /let/start:verb|=/Ver:batim /fi
   /futurelet/:temp/Ver:sp}
}
>>>


\<space and eoln chars in /Verbatim\><<<
{
\catcode`\^^I|=13  \catcode`\/|=0   \catcode`\\|=12
/catcode`/.|=10  /catcode`/^^M|=13      /catcode`/ |=13%   
/gdef/:Verbatim{%
.../def^^M{/ht:everypar{/Verb:eoln}/Verb:boln/par/leavevmode}%
.../def {/Verb:sp}%
.../let/ver:sp|= %
.../let/ver:ln|=^^M%
.../def^^I{/leavevmode  }}}
>>>

The following establishes a configurartion according to
what should appear at the start, end, and each end-of-ln.




%   \def\Verb:eoln{\hfil\break\null}

\<verbatim\><<<
\NewConfigure{VerbatimEnv}[2]{\def\begin:Verb{#1}\def\end:Verb{#2}}
\Configure{VerbatimEnv}
   {\par  \edef\leftsk:p{\hskip\Verb:Left}%
    \leftskip|=\z@ \parindent|=\z@ \ht:everypar{\verb:config}}
   {\aft:Verb\par}
\def\verb:config{\bef:Verb\csname leftsk:p\endcsname 
   \def\verb:config{\Verb:boln \def\Verb:eoln{\leavevmode\par}\leftsk:p}}
>>>

% \def\Verb:eoln{\par  \everypar{\verb:config}%
%   \def\Verb:eoln{\par}}
%


The following uses the above vehicle to establish a configuration
in accordance to what should appear at the start, end, and 
before each of the non-leading lines.





\<html config util\><<<
\NewConfigure{HVerbatim}[4]{\c:def\bef:Verb{#1\Verb:eoln}%
   \c:def\aft:Verb{\ht:everypar{}#2}%
   \c:def\Verb:eoln{#3}\c:def\Verb:boln{#4}}
\NewConfigure{HVerbatim+}[2]{\d:def\Verb:Left{#1}%
   \def\Verb:sp{#2}}
>>>







The above has left margin of \''\Verb:Left' and typically has
inappropriate space above and below the code. The following takes the
left margin of the html code.

\Verbatim
    \Configure{HVerbatim}
    {\HtmlPar\HCode{<NOBR><CODE>}}
    {\HChar{160}\HCode{</CODE></NOBR>}}
    {\HChar{160}\HCode{</CODE></NOBR><BR><NOBR><CODE>}}
\EndVerbatim



%
%\Configure{HVerbatim}
%   {\IgnoreIndent \HObey \par \leavevmode}
%   {\EndHObey\IgnoreIndent \par}
%   {\hfil\break\null \HCode{\html:invisible}\nobreak \hskip
%       \ifdim \leftskip>0pt \leftskip \else 2em \fi}


The \`'\leavevmode' is needed for the case that the commands start
paragrphs, to ensure that \`'\everypar' operations would be performed
outside the groups of the commands. 









\Section{JavaScript}
Note that  the first parameter of \''\ScriptCommand' must  be in
braces, without surrounding spaces.

\<scripting commands\><<<
\def\ScriptCommand{\begingroup \catcode`\\|=12
   \:DefScript}
\def\:DefScript#1{\endgroup \Def:Script#1|<par del|>}
\def\Def:Script#1#2|<par del|>{%
   \expandafter\let\csname :#2:\endcsname|=\empty
   \edef\:temp{\long\def\expandafter\noexpand\csname a:#2\endcsname
                 ####1\expandafter\noexpand\csname End#2\endcsname
                 {####1\noexpand\:EndVerbatim}}\:temp
   \long\expandafter\def\csname
       b:#2\endcsname##1#1End#2{##1\:EndVerbatim}%
   \edef\:temp{\noexpand\DefScript:
      \expandafter\noexpand\csname #2\endcsname
      {\expandafter\noexpand\csname a:#2\endcsname}%
      {\expandafter\noexpand\csname b:#2\endcsname}}\:temp
}
>>>

The \''\long' above is for cases that the new command is embeded
in other commands as is the case, for instance, in \''\CssFile'.



\`'\begin{keep}-\
AAAAAAAAAAAAAAAAA
BBBBB
\end{keep}'
or
\`'\begin{keep}
AAAAAAAAAAAAAAAAA
BBBBB
\end{keep}'



\<scripting commands\><<<
\def\DefScript:#1#2#3#4#5{\def#1{\call:script{#2}{#3}{#4}{#5}}}
\def\call:script#1#2#3#4{\begingroup \vrb:tt   
   \leftskip|=\z@  \parindent|=\z@
   \Configure{HVerbatim}{\empty}{\empty}%
                        {\special{t4ht=}\empty}{\empty}%
   \Configure{HVerbatim+}{\z@}{\hbox{ }}%
   #3\ht:special{t4ht@@}%
   \let\Verb:atim|=#1\let\Ver:batim|=#2%
   \def\:EndVerbatim{\ht:special{t4ht@@}%
   #4\endgroup\ignorespaces}\Verb:env}
>>>

%    \let\html:invisible|=\empty




A \`'\Configure{HVerbatim}{}{}{}{}' above will be problematic for 
the \`'hooks' option. The \`'\special{t4ht=}'is to ensure
pseudo code at empty lines.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Cascade Style Sheets}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



\<scripting commands\><<<
\def\a:rootfont:{-}
\:CheckOption{fonts+} \if:Option \def\a:rootfont:{+} 
\else
   \Log:Note{for marking of the base font, 
       use the command line option `fonts+'}%
\fi
>>>

The above option requests css font information for the root font of
the file.















\''\xml:empty' is for inserting the \''/' at end of tags by demand.

The \''\edef\Preamble{\Preamble}' is needed for context where the
command line arguments come indirectly through an \''\env' macro.

\<utilities\><<<
\ifx \xml:empty\:UnDef  
   \edef\Preamble{\Preamble}
   \:CheckOption{xhtml} 
   \if:Option \else \:CheckOption{xml}\fi
   \if:Option 
      \def\xml:empty{ /}
      \long\def\:xhtml#1{#1}
   \else 
      \Log:Note{for XML code, use the command line option
                `xml' or `xhtml'}%
      
      \let\:xhtml|=\:gobble
      \let\xml:empty|=\empty
\fi \fi 
>>>





Default font (the extra code is neded in order to activate it
within the dvi file before a change in font, e.g., for a title):

\<start html file\><<<
\ht:special{t4ht>\jobname.tmp}{\everyhbox{}\hbox
   {x\ht:special{t4ht;\a:rootfont:}x}}%
\ht:special{t4ht<\jobname.tmp}%
>>>


















\<early Configure\><<<
\NewConfigure{Css}[1]{\def\aa:Css{#1}}
>>>



\<html utilitiesNO\><<<
\tmp:cnt|=\time  \divide\tmp:cnt |by 60
\edef\:temp{\the\tmp:cnt}
\multiply\tmp:cnt |by -60 \advance\tmp:cnt |by \time
\edef\:today{\the\year-\ifnum \month<10 0\fi
  \the\month-\ifnum \day<10 0\fi\the\day 
   \space\ifnum \:temp<10 0\fi \:temp 
   :\ifnum \tmp:cnt<10 0\fi\the\tmp:cnt :00}
>>>



\Chapter{Ditto: Positioned Elements and Gifs}

\<gif\><<<
\ifHtml |<html gif|> 
\fi
>>>


\Section{Positioned Elements}

\<shared config\><<<
\NewConfigure{Canvas}[3]{}
>>>




\Verbatim
% * can be replaced by any distinguished character
% \special{
%    * before-all
%    * after-all     %right  %left %height %depth
%    * before-char   %x %y
%    * after-char    
%    * line          %x %y %thickness %length
%    * x-coefficients %A(x) + %B
%    * y-coefficients %C(y) + %D
% }
\EndVerbatim

\<html gif\><<<
\def\Canvas{\ht:special{t4ht"}}
\let\EndCanvas|=\Canvas
>>>









  

The attached source tries three renderings for `A<sub>x</sub>'.  My
understanding of the positioning mechanism is that, in all three cases,
the reference point for `x' should be 0.7ex under the right leg of A.
Moreover, the measurement 0.7ex should be with respect to the
dimension of the font of A.

\Verbatim

           /\
          /--\
         /    \...........
                \/       } 0.7ex within font of A
               ./\.......}


                      A<SPAN 
STYLE="position:relative"><SPAN 
STYLE="position:absolute; top:0.7ex"><SPAN 
STYLE="font-size: 70% ;">x</SPAN></SPAN></SPAN>
\EndVerbatim










\Section{/Picture Comamnd}





\<html gif\><<<
\def\:img{%
   \ifx       *\:temp  \let\:temp|=\i:mgif \let\:next|=\:GIf
   \else \ifx +\:temp  \let\:temp|=\i:mgif \let\:next|=\:Gif
   \else \ifx [\:temp  \let\:temp|=\im:g
   \else               \def\:temp{\im:g[{\csname
                                        a:Picture-alt\endcsname}]}%
   \fi \fi \fi  \:temp}
>>>

\<html config util\><<<
\NewConfigure{Picture-alt}{1}
\Configure{Picture-alt}{}
>>>




\''\Configure{Picture-alt}' is for \''\Picture{...}' commands; it
provides the default content.  The other two commands tell whether the
bit maps and given alyternate values, respictively, are to be used.
The are used, iff the argument has non empty value (the argument
itself is not used).




Without the \''\leavevmode' above, the start of paragraph can
\HPage{enter} 
\Verbatim
\Picture{OSU.gif  xx yy}

\Picture{OSU.gif  xx yy }

\Picture{OSU.gif}


\Picture{OSU.gif }



\Picture[xx]{OSU.gif  xx yy}

\Picture[xx]{OSU.gif  xx yy }

\Picture[xx]{OSU.gif}

\Picture[xx]{OSU.gif }
\EndVerbatim
\EndHPage{}
into the \''<IMG ..>' tag.




Empty file name is a request for a default name of the form
\`'\jobname%\romannumeral
\P:ctureCount'.



\<gif\><<<
\def\P:ct{\leavevmode  \futurelet\:temp\:img}
\let\Picture|=\P:ct
\def\yes:pic{\PictureOn}
\def\no:pic{\PictureOff}
>>>




\Section{Call to Specials of Gif}


\<gif\><<<
\def\i:mgif#1{\futurelet\:temp\:gif}

\def\:gif{%
   \ifx \:temp[\expandafter\:GifText 
   \else       \expandafter\:next       \fi }
>>>

The following macro is for imported pictures \`'\Picture{....}' and
\`'\Picture[...]{...}'.

\<html gif\><<<
\def\xim:g[#1]#2{{\cond:pic{%
   \def\gif:nm{\edef\gif:nm}\gif:name{#2}%
   \expandafter\get:ext\gif:nm.|<par del|>%
   \edef\PictureFile{\gif:nm\ifx\:temp\empty \PictExt\fi}%
   \Needs-\PictureFile \ht:special{t4ht@-}%
   \a:IMG\ht:special{t4ht=\PictureFile}\b:IMG
   \a:PictureAlt{#1}\b:PictureAlt \d:IMG
   \a:PictureAttr{\at:IMG}\e:IMG}}\After:Picture}
\def\noim:g[#1]#2{}
\let\im:g|=\xim:g
>>>

\<html config util\><<<
\NewConfigure{PictureAlt}{2}
\NewConfigure{PictureAttr}[1]{\def\a:PictureAttr##1{#1}}
\Configure{PictureAlt} {\NoFonts} {\EndNoFonts}
\Configure{PictureAttr} {\HCode{\Hnewline #1}}
>>>



The following macro is for labeled bit pictures \`'\Picture+{....}'
and \`'\Picture*{...}'.



\<html gif\><<<
\def\strt:gf#1#2{#2%
   \csname a:PictureAlt*+\endcsname
   \let\sv:sp\sp
   \let\sv:sb\sb
   \ifx \s:p\:UnDef \else \let\sp\s:p \fi
   \ifx \s:b\:UnDef \else \let\sb\s:b \fi
   \if #1!\ht:special{t4ht!\:AltPicture:}%
          \global\let\:AltPicture:|=\empty  \fi |% send to char map|%
   \ht:special{t4ht||}%
   \ht:special{t4ht++\PictureFile}%
   \iprt:special
}
\def\nd:gf#1#2{%
   \let\ht:special|=\tex:special
   \ht:special{t4ht+}%
   \if #1!\ht:special{t4ht!}\fi    |%stop sending to char map|%
   \let\sp\sv:sp
   \let\sb\sv:sb
   \ht:special{t4ht||}%
   \csname b:PictureAlt*+\endcsname
   \ifx #2\relax \else \csname a:PictureAttr*+\endcsname{#2}\e:IMG\fi
}
\def\img:alt{\ht:special{t4ht@-}%
   \a:IMG\ht:special{t4ht=\PictureFile}\b:IMG}
>>>








\<shared config\><<<
\NewConfigure{PictureAlt*+}{2}
\NewConfigure{PictureAttr*+}[1]{%
   \expandafter\def\csname a:PictureAttr*+\endcsname##1{#1}%
}
\Configure{PictureAttr*+}{\ht:special{t4ht=#1}}
>>>






\Verbatim
flag ){ `<make a special for dvi driver`> }
  else switch( get_char() ){
     case '+': { `<out gif filename`>
     case '@': { `<write to lg file`> break; }

  case '+': { while( special_n-- > 0 )  (void) get_char();  break; }
  case '=': Contribution of text (\''\HCode').
  case '<':
  case '>': { `<redirect html output`>  break; }
  case '!': { `<handle char map mode`>  break; }
  case '|': { gif_ch = !gif_ch;  break; }

  case "..." : Positioned dvi code

\item \`'.extension for root file' 


\item \`'@@' for char mode        (what is this????)  e.g., javascript
\item \`'@+' for note to lg file  (where is this???)
\item \`'@-' for removing left margins from char maps


\HCode{<HR>}

\item \`'@%P' --- On-off modes for traceing of POP, PUSH in DVI
\item \`'@%D' --- On-off modes for traceing CHAR...RAHC in DVI
\item \`'@%H' --- On-off modes for traceing h spaces
\item \`'@%V' --- On-off modes for traceing v spaces
\item \`'@%R' --- On-off modes for traceing x rulers


In all the above, uppercase for plus, lowercase for minus 1

\item \`'@%%x...pre...x...post...' --- Group tracing.
    Default \`'<!-- DVI ' and \`'\n-->', where \''\n' represents
    new line char (i.e., \`'\Hnewline').
    \`'x' can be any character. if it is not there, 
    the postfix is assumed to be empty.
\item \`'@%...' --- Not used, if not of the above format

\HCode{<HR>}

\item \`':+...'  increment by 1( define, if not defined)
\item \`':-...'  decrement by 1
\item \`':>...'  push current value
\item \`':<...'  pop current value
\item \`':!...'   display current value
\item \`':|...'   display top value

\item \`';-' --- yes default font
\item \`';+' --- no default font
\item \`';%' --- insert font size
\item \`';=' --- insert css name of ch


\item \`';i' ---  i=1 (before ch-name),2 (between ch-name and ch),3
    (after ch), 4 (before img-src), 5 (between img-src and alt), 6
    (between alt and name), 7(after name).
\item \`';8' --- PauseFontStyle
\item \`';9' --- ContFontStyle

\item \`'~' --- on/off for transport data to group boundaries
\item \`'~<....' --- transport back
\item \`'~>....' --- transport forward

\EndVerbatim






\Section{The Environment of Gif}



\<html config util\><<<
\NewConfigure{IMG}{5}
>>>


The third and forth parameters are separated by user
cotributed attr-list.




\<html config util\><<<     
\NewConfigure{Picture}[1]{\def\PictExt{#1}}
\Configure{Picture}{.png}
>>>

\<picture off\><<<
\let\im:g|=\noim:g
>>>

\<picture on\><<<
\let\im:g|=\xim:g
>>>



GIF:
\List{*}

\item
  Lossless compression 
\item  Supports 256 colors. Good for pictures that use only a few colors
\item Relies on an algorithm copyrighted by Unisys.  However, the patent 
expired (20 June 2003 in US; a year later in Canada, Germany,
France, Italy, Japan, UK).
\item Supports animation
\item
The name stands for Graphics Interchange Format
\item  Doesn't support unicode
\EndList


PNG:

\List{*}
\item Losless compression superior to GIF
\item Recommendation status at W3C:
  \Link[http://www.w3.org/Graphics/PNG/]{}{}{\tt
    http://www.w3.org/Graphics/PNG/}\EndLink{}.
\item Developed as a patent-free alternative GIF
\item Doesn't support animation
\item The name stands for Portable Network Graphics
\item Supports unicode
\EndList



JPG:
\List{*}
\item 
Uses lossy compression that discards information the human eye cannot detect.
\item
Supports  16 million colors
\item 
Good for photographs and complex graphics
\item
Noticeable reduction in quality for line drawings
\item  Named after the committee Joint Photographic Experts Group
that defined the standard.
\EndList


\SubSection{With Char Map}

Independent block: no brackets.

Resolution can be an integer number or a pair of integer numbers
separated by a comma. The first for x-resolution, the second for
y-resolution. Then we can have a map for boundary characters made
up of pairs: character to be replaced followed by replcment.


For \`'\Picture+{}': (no  box, no pre)

\<html gif\><<<
\def\:Gif#1{\cond:pic{%
   \gif:name{#1}\csname a:Picture+\endcsname
   \strt:gf!\img:alt
   \def\EndPicture{\nd:gf!{\c:IMG\Pic:Img}%
      \let\EndPicture|=\:UnDef \csname b:Picture+\endcsname
      \After:Picture}}}
>>>

\<html config util\><<<
\NewConfigure{Picture+}{2}
>>>








For \`'\Picture*{}': Vertical box + pre. Might be a problem because
vertical boxes assume the width of the page, and a few of them in a
line may cause a picture to go out of the page boundaies---a problem
for convert. If the content of the box is just a box, or boxes, as is
the case in DraTeX, they the ebeded boxes induce the width.
The \`'\hfill\break' may handle some of these cases.

\`'\Picture*{}.....\EndPicture' will go to \''\:GIf'.
\`'\Picture*[..]{}.....\EndPicture' will go to \''\:GifText'.


\<html gif\><<<
\def\:GIf#1{\cond:pic{\ifvmode\vfill\break\else
      \ht:special{t4ht@[}\hfill\break.\ht:special{t4ht@]}\fi 
   \gif:name{#1}\csname a:Picture*\endcsname
   \strt:gf!\img:alt
      \ifmmode \expandafter\vcenter\else \expandafter\vtop\fi
        \bgroup   \let\EndPicture|=\:EndGIf  \NoHtmlEnv }}
\def\:EndGIf{%
        \egroup \nd:gf!{\c:IMG \Pic:Img}\csname b:Picture*\endcsname
        \After:Picture}
>>>

\<html config util\><<<
\NewConfigure{Picture*}{2}
>>>


\<html gif\><<<
\def\After:Picture{\After:EndPicture
   \global\let\After:EndPicture|=\empty}
\let\After:EndPicture|=\empty
\def\AfterPicture#1{\append:def\After:EndPicture{#1}%
   \global\let\After:EndPicture|=\After:EndPicture}
>>>


\''<PRE>'s force line breaks also in visual browsers, and we don't
want these breaks within formulas.

The \`'\let\:Gif|=\:gobble' is no good in the foolowing because it
does not take care of the presence of \`'\EndPicture'.  It is also not
needed because \''\:Gif' has \''\cond:pic' to take care of it.


\<html gif\><<<
\def\iprt:special{%
   \def\ht:special##1{\tex:special{t4ht+##1}}}
\let\tex:special|=\ht:special 
>>>

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\SubSection{With Given Text and Inline Text}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%




\`'\Picture*{}.....\EndPicture' will go to \''\:GIf'.
\`'\Picture+{}.....\EndPicture' will go to \''\:Gif'.
\`'\Picture*[..]{}.....\EndPicture' will go to \''\:GifText'   with \`'\:next=\:GIf'.
\`'\Picture+[..]{}.....\EndPicture' will go to \''\:GifText'  with \`'\:next=\:Gif'.

Given text: \`'[non empty]'. Inline text: \`'[]'.



The following macro is for imported pictures \`'\Picture*+{....}' and
\`'\Picture*+[...]{...}'.


\<html gif\><<<
\def\x:GifText[#1]#2{\cond:pic{%
   \ifx \:next\:GIf 
      \def\gif:box{\vtop\bgroup \NoHtmlEnv \let\gif:box|=\egroup}%
   \else  \let\gif:box|=\empty  \fi
   \gif:name{#2}%
   \img:alt  \def\:temp{#1}%
   \ifx \:temp\empty \else 
       \csname a:PictureAlt*+[]\endcsname
           {#1}\csname b:PictureAlt*+[]\endcsname\fi
   \ht:special{t4ht>\jobname.tmp}%                    |%dump|%
   \strt:gf-\empty  \gif:box
   \def\EndPicture{%
     \gif:box  \nd:gf-\relax  \ht:special{t4ht<\jobname.tmp}%
     \csname a:PictureAttr*+[]\endcsname{\c:IMG\Pic:Img}\e:IMG
     \After:Picture}%
}}
\let\:GifText|=\x:GifText
\def\no:GifText[#1]{\:gobble}
>>>



\<shared config\><<<
\NewConfigure{PictureAlt*+[]}{2}
\NewConfigure{PictureAttr*+[]}[1]{%
   \expandafter\def\csname a:PictureAttr*+[]\endcsname##1{#1}%
}
\Configure{PictureAlt*+[]} {\NoFonts} {\EndNoFonts}
\Configure{PictureAttr*+[]} {\ht:special{t4ht=#1}}
>>>



\<html gif\><<<
\ifx \:DraCatCodes\:UnDef 
   |<set basic Pic:Img|>
\fi
>>>

\<set basic Pic:Img\><<<
\def\Pic:Img{\at:IMG}
>>>



The \`'\everypar{t4ht="#1"}' can't be
\List{disc}
\item  \`'{\everypar{}\HCode{#1}} --- the \''\leavevmode' can be
ruinful (e.g., in \`'$$ \underbrace{1,...,1}
 s_{aaaaaaa}\underbrace{1,...,1}
$$')

\item \`'{\IgnorePar\HCode{#1}} ---  Besides of the above, it
also ruins the paragraph break-up info (e.g.,  with \''\L' having a definition \`'\def\L{\Picture+[]...\EndPicture').
\EndList



CHECK ISSUE OF ATTRIBUTES FOR IMAGES

\<picture off\><<<
\let\:GifText|=\no:GifText
>>>

\<picture on\><<<
\let\:GifText|=\x:GifText
>>>


\SubSection{File Name}

We have a command of the form \''\gif:name{file-name attributes}'



\<html gif\><<<
\def\gif:name#1{\edef\at:IMG{\noexpand\get:gfnm#1 |<par del|>}\at:IMG}
>>>

The material within the if is for eliminating the extra space
introduced before \`'|<par del|>'.

\<html gif\><<<
\def\get:gfnm#1 #2|<par del|>{\def\at:IMG{#2}%
   \ifx \at:IMG\empty\else 
      \expandafter\aT:IMG\at:IMG|<par del|>%
   \fi
   \gif:nm{#1}}
\def\aT:IMG#1 |<par del|>{\def\at:IMG{#1}}
>>>

It used to be as follows, which caused extra space at end of arguments.

\Verbatim
\def\gif:name#1{\edef\at:IMG{\noexpand\get:gfnm#1 |<par del|>}\at:IMG}
\def\get:gfnm#1 #2|<par del|>{\def\at:IMG{#2}\gif:nm{#1}}

\EndVerbatim




\<html gif\><<<
\def\NextPictureFile{\def\Next:PictureFile}
\NextPictureFile{}
\def\gif:nm#1{%
   \gHAdvance\P:ctureCount |by 1
   \xdef\PictureFile{#1}\ifx  \PictureFile\empty
      \xdef\PictureFile{\Next:PictureFile}\fi
   \global\let\Next:PictureFile|=\empty
   \ifx  \PictureFile\empty
      \bgroup  \Advance:\P:ctureCount |by -\Pic:Cnt
      \xdef\PictureFile{\j:bname|<tail for file name|>\P:ctureCount
                        x\Pic:Dm\PictExt}%
      \egroup
   \else
      \expandafter\get:ext\PictureFile.|<par del|>%
      \ifx\:temp\empty \xdef\PictureFile{\PictureFile\PictExt}\fi
   \fi
   \immediate\write-1{l. \the\inputlineno\space Writing
                 \jobname.idv[\P:ctureCount] (\PictureFile)}%
   }%
>>>

\<html gif\><<<
\def\SavePicture#1{\def\:tempa{#1}\SaveP:cture}
\Odef\SaveP:cture[#1]{%
   \edef\:tempb{\noexpand\Odef\expandafter\noexpand\:tempa[####1]{{%
      \let\noexpand\Log:Needs|=\noexpand\:gobble
      \noexpand\Picture[\HCode{#1}]{\PictureFile\space####1}}}}%
   \:tempb \expand:after{\global\expandafter\let\:tempa|=}\:tempa }
>>>

Without the \''\HCode{#1}' above things like \''--&gt;'  expand. Why
the \''\HCode' is not a problem?


\<html gif\><<<
\def\NewPictureDomain#1{%
   \global\let\Pic:Cnt|=\P:ctureCount
   \def\Pic:Dm{#1} \ifx \Pic:Dm\empty
      \xdef\Pic:Dm{\P:c:Dm}%
      \gHAdvance\P:c:Dm   |by 1
   \fi }
\HAssign\P:c:Dm |= 0
\let\Pic:Dm|=\empty   
\HAssign\Pic:Cnt|=1
>>>


\SubSection{Counter}

\<html gif\><<<
\HAssign\P:ctureCount|=0 
\let\:AltPicture:|=\empty        |%100 = default size|%
>>>

\SubSection{Non-Html}



Don't do \''\let\EndPicture=\relax'. Within \''\PictureOff' it is treated as
undefined.



\Section{Utilities for Gif}


In \`'\pic:cond\a\b' the \`'\b' refers to the command to be used when
already within a gif-picture. The \`'\a' is to be used if a
gif-picture is to be opened.


\<html gif\><<<
\def\pic:gobble{\ifx \EndPicture\:UnDef \else \expandafter\:gobble\fi}
\def\pic:gobbleII{\ifx \EndPicture\:UnDef \else \expandafter\:gobbleII\fi}
\def\nopic:gobble#1{\ifx \EndPicture\:UnDef \else #1\fi}
\def\pic:cond#1#2{%
   \ifx\EndPicture\:UnDef \def\end:condpic{\EndPicture}\expandafter#1%
   \else                  \let\end:condpic|=\empty  \expandafter#2%
   \fi }
\def\cond:pic#1{%
   \ifx \EndPicture\:UnDef #1\else     
      \let\E:pic|=\EndPicture \PushMacro\E:pic
      \def\EndPicture{\PopMacro\E:pic \let\EndPicture|=\E:pic}\fi}
>>>



\SubSection{Disabled Math}

Global on and off for some reason fails sometimes.


\<html gif\><<<
\def\PictureOff{%
   \expandafter\let\csname Pic:\Pic:On\endcsname|=\EndPicture
   \ifx \EndPicture\:UnDef   \let\EndPicture|=\empty \fi
   |<picture off|>%
   \Advance:\Pic:On |by 1 }
\def\PictureOn{%
   \ifnum \Pic:On>0
     \Advance:\Pic:On |by -1
     \ifnum \Pic:On=0  |<picture on|>%
     \fi
     \expand:after{\let\EndPicture|=}\csname Pic:\Pic:On\endcsname
     \ifx \EndPicture\relax \let\EndPicture|=\:UnDef\fi 
   \else
     \:warning{\string\PictureOn\space without \string\PictureOff}%
   \fi }
\HAssign\Pic:On |= 0
>>>















Don't go directly for \`'\PushMacro\EndPicture', just in case the
user wants to use this stack.  

Smash is most often used to produce comples patterns, so
let su go and make them pictures.

\<html gif\><<<
\def\:temp#1{\ifx \EndPicture\:Undef
      \relax\ifmmode\hbox{$#1$}\else \hbox{#1}\fi
   \else \o:smash:{#1}\fi}
\HLet\smash|=\:temp
>>>



The definition \''\def\HCode#1{\leavevmode\special{t4ht=#1}}' can be
problematic for grouping in pictures because of the \''\leavevmode'
that in immediate environment produces some side code.


It looks like the following problems, or most
of them, have been resolved with a fix to \''\noalign'.


The \`'\openup10pt' causes too much space in 
%
\ifHtml[\HPage{some pictures}\Verbatim
\openup10pt \halign{
 $2^{#}$\quad&\(
     \overbrace{2\cdots 2}^{#\
     \rm times}\)\quad& #\ cr
 3&3&8\ cr }
\EndVerbatim\EndHPage{}]\fi
%
and too much memory in 
%
\ifHtml[\HPage{others}\Verbatim
% \input tex4ht.sty         \Preamble{html}
%   \EndPreamble
%
%\catcode`\@=11
%
%\def\eqalign#1{\null\,\vcenter{\openup\jot\m@th
%  \ialign{\strut\hfil$\displaystyle{##}$&$\displaystyle{{}##}$\hfil
%      \ crcr#1\ crcr}}\,}
%
%\def\eqalignno#1{\displ@y \tabskip\centering
%  \halign to\displaywidth{\hfil$\@lign\displaystyle{##}$\tabskip\z@skip
%    &$\@lign\displaystyle{{}##}$\hfil\tabskip\centering
%    &\llap{$\@lign##$}\tabskip\z@skip\ crcr #1\ crcr}}
%
%\def\displ@y{\global\dt@ptrue\openup\jot\m@th
%  \everycr{%
%      \noalign{\ifdt@p \global\dt@pfalse \ifdim\prevdepth>-1000\p@
%      \vskip-\lineskiplimit \vskip\normallineskiplimit \fi
%      \else \penalty\interdisplaylinepenalty \fi}}}
%
%
%\def\displ@y{\global\dt@ptrue
%  \everycr{\noalign{\ifdt@p \global\dt@pfalse \ifdim\prevdepth>-1000\p@
%      \vskip-\lineskiplimit \vskip\normallineskiplimit \fi
%      \else \penalty\interdisplaylinepenalty \fi}}}
%
%\def\openup{\afterassignment\@penup\dimen@=}
%\def\@penup{\advance\lineskip\dimen@
%  \advance\baselineskip\dimen@
%  \advance\lineskiplimit\dimen@}
%
%\openup10pt \halign{
% $2^{#}$\quad&\(
%     \overbrace{2\cdots 2}^{#\
%     \rm times}\)\quad& #\ cr
% 3&3&8\ cr }
%
%\eqalignno{
%li&= 1\ cr
%&> line 2& (7)}
%
%\bye 
\EndVerbatim\EndHPage{}]\fi
%
Putting a \''\offinterlineskip' solves sometimes the problem
in some pictures of getting too much vertical
spcace, but may create 
\ifHtml[\HPage{improper pictures}\Verbatim
% \input tex4ht.sty         \Preamble{html}
%   \EndPreamble
%
%\catcode`\@=11
%
%\def\eqalignno#1{\displ@y \tabskip\centering
%  \halign to\displaywidth{\hfil$\@lign\displaystyle{##}$\tabskip\z@skip
%    &$\@lign\displaystyle{{}##}$\hfil\tabskip\centering
%    &\llap{$\@lign##$}\tabskip\z@skip\ crcr #1\ crcr}}
%
%\eqalignno{
%li&= 1\ cr
%&> line 2& (7)}
%\bye 
\EndVerbatim\EndHPage{}]\fi{} with depth and hiehgt 0 (put 
in TeX4ht1.sty the picture in box0 and measure). The problem
is because \''\def\offinterlineskip{\baselineskip-1000\p@
  \lineskip\z@ \lineskiplimit\maxdimen}' puts too much space
in \''\lineskiplimit'.



\Chapter{Math}


\<math config util\><<<
\:CheckOption{base}
\if:Option  \else
   |<config math end-points|>
   |<sub and sup|>
   |<math classes|>
   |<grouped math classes|>
   |<built-in tex math ops|>
\fi
>>>


\Section{End Points of Math Environments}


The following become active only when they are being configured.



\<config math end-points\><<<
   \NewConfigure{$}[3]{%
      \def\a:mth{\bgroup#1}\def\b:mth{#2\egroup}%
      \def\c:mth{|<empty script base trap|>#3}%
      \everymath{\ifx \EndPicture\:UnDef
          $\a:mth\everymath{}\everydisplay{}$%
                 \aftergroup\b:mth \c:mth \fi}}
>>>




\<config math end-points\><<<
   \NewConfigure{$$}[3]{%
      \def\a:display{\bgroup#1}%
      \def\b:display{#2\egroup}%
      \def\c:display{#3}%
      \everydisplay{\ifx \EndPicture\:UnDef 
           $$\a:display\everymath{}\everydisplay{}$$%
                 \aftergroup\b:display \c:display\fi}}

>>>


Can't put \Verb'|<empty script base trap|>' into \Verb+\def\c:display{#3}%+
because of cases such as \Verb+$$\halign{#\cr a\cr}$$+


\<empty script base trap\><<<
{\csname HCode\endcsname{}}%
>>>

Tex4ht translate each \`'$$...$$' into \`'$$
$$$$...$$' and upon
reaching the second environment the mode is already horizontal.  For
such case, the above approach of distinguishing in-line and off-line
display math don't work.  This is a place where an implimentation
within the tex engine can do a better work.  On the other hand, all of
this can be fixed within and XSL-like transformations on the final
output of tex4ht.


\''\halign' doesn't allow expansion into content to precede
it within the math mode. Hence, the \''\aftergroup' below.






%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Math into Pictures}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\<config math end-points\><<<
\def\PicDisplay{\pic:gobble\env:PD
   \def\:temp{$$}\pic:cond\Pic:math\:temp}
\def\EndPicDisplay{\end:condpic\pic:gobble\endenv:PD}
\def\Pic:math{\hfil\break 
   \expand:after{\Picture*}\alt:Mth{ \c:Math}}
>>>


\<config math end-points\><<<
\def\PicMath{\leavevmode\pic:gobble\env:PM\hbox\bgroup
   \everymath{}\everydisplay{}\pic:cond\pic:math$}
\def\EndPicMath{\end:condpic\egroup\pic:gobble\endenv:PM}
\def\pic:math{\expand:after{\Picture+}\alt:mth{ \c:math}}
>>>




\<config math end-points\><<<
\NewConfigure{PicDisplay}[4]{\def\alt:Mth{#3}%
   \ifx \alt:Mth\empty\else \def\alt:Mth{[#3]}\fi\def\c:Math{#4}%
   \c:def\env:PD{#1}\c:def\endenv:PD{#2}}
\NewConfigure{PicMath}[4]{\def\alt:mth{#3}%
   \ifx \alt:mth\empty\else \def\alt:mth{[#3]}\fi\def\c:math{#4}%
   \c:def\env:PM{#1}\c:def\endenv:PM{#2}}
>>>

\`'\Configure{PicDisplay}{}{}{[ALT]}{extra-attributes}'
\`'\Configure{PicMath}{}{}{[ALT]}{extra-attributes}'


\Section{Non-Pictorial Math}


\SubSection{Dvi Math}


\<config math end-points\><<<
\def\DviMath{\a:DviMath\leavevmode \MathClass |<same page|> \DviSend}
\def\EndDviMath{\EndDviSend |<end same page|>\EndMathClass \b:DviMath}
\NewConfigure{DviMath}{2}
>>>



The above need to be boxed to prevent page breaks within the send 
environment  \`'\special{t4ht~}...\special{t4ht~}'..

\<same page\><<<
\ht:special{t4ht@(}\vbox
   \bgroup{\expandafter\ifx\csname ht:everypar\endcsname\relax
                \expandafter\everypar
           \else \expandafter\ht:everypar\fi{}\leavevmode\ht:special{t4ht@)}}%
       \relpenalty=10000 
       \binoppenalty=10000 
>>>

\<end same page\><<<
\ht:special{t4ht@(}\egroup\ht:special{t4ht@)}%
>>>

The penalty is to prohibit line breaks. For instance, the following
formula under the mathml mode.

\Verbatim
\documentclass{scrartcl}  
\begin{document}  
$a^{n_{1}+n_{2}+n_{3}}  
 (1-p_{1})^{n_{4} +n_{6} +n_{7} +(N-n_{1}-...b- n_{7})}  
  p_{2}^{n_{1} +n_{2} +n_{4} +n_{6}}  
 (1-p_{2})^{n_{3} +n_{5} +n_{7} +(N-n_{1}-...b- n_{7})}  
 p_{3}^{n_{1} +n_{3}+n_{4} +n_{7}}  
 (1-p_{3})^{n_{2} +n_{5} +n_{6} +(N-n_{1}-...b- n_{7})}$  
\end{document}
\EndVerbatim


The  specials remove the space at  the start and end points of the box.



Examples:

\Verbatim
\Configure{$} {\Tg<math>\DviMath} {\EndDviMath\Tg</math>} {}
\Configure{$$} {\Tg<display>\DviMath} {\EndDviMath\Tg</display>} {}

\Configure{()} {\Tg<math>\DviMath$} {$\EndDviMath\Tg</math>} 
\Configure{[]} {\Tg<display>\DviMath$$} {$$\EndDviMath\Tg</display>} 
\EndVerbatim




\SubSection{Positioned Math}



\<config math end-points\><<<
\def\PMath{\bgroup\Canvas \x:SUBOff  \x:SUPOff 
   \let\Picture|=\empty \everymath{}\everydisplay{}}
\def\EndPMath{\EndCanvas\egroup}
\:CheckOption{PMath} \if:Option  
   \def\:Pmath{$\PMath$\aftergroup\EndPMath}
   \def\:Pdisp{$$\PMath$$\aftergroup\EndPMath}
   \everymath{\:Pmath}
   \everydisplay{\:Pdisp}
\fi
>>>


Example: \`' \def\({\PMath$} \def\){$\EndPMath} \def\[{\PMath$$}
\def\]{$$\EndPMath}'.



\ifHtml[\HPage{positioned math}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%






\Verbatim
\Css{.Canvas { position:absolute; }}
\Css{.Canvas { font-size:100\%; }}
\Css{.Canvas .cmr-7{ font-size:70\%; }}
\Css{.Canvas .cmmi-7{ font-size:70\%; font-style: italic;}}

$ a \over  b + c $
\EndVerbatim


\Tg<hr />


\Verbatim
\input tex4ht.sty         \Preamble{html,sty,4.0s,PMath}

\Css
 BODY{ font-size : 200% }
 .Canvas { position: relative; }
 SPAN.cmr-7  .Canvas-char ,
 SPAN.cmmi-7 .Canvas-char ,
 SPAN.cmsy-7 .Canvas-char { font-size: 70% ; }
 SPAN.cmr-5  .Canvas-char ,
 SPAN.cmmi-5 .Canvas-char { font-size: 50% ; }
\EndCss


   \EndPreamble
aa
$
{{A+C \over B+D}+F \over X*Y}
$

\bye
\EndVerbatim
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\EndHPage{}]\fi





\Section{Subscripts and Superscripts}


\<sp and sb for catcode 13\><<<
\ifnum \the\catcode`^=13
   \let\expandafter\noexpand
                     \csname x:SUPOff\endcsname|=\noexpand\empty
   \let\expandafter\noexpand
                     \csname x:SUPOn\endcsname|=\noexpand\empty
   \catcode`\noexpand ^|=\the\catcode`^\fi
\ifnum \the\catcode`_=13 
   \let\expandafter\noexpand
                     \csname x:SUBOff\endcsname|=\noexpand\empty
   \let\expandafter\noexpand
                     \csname x:SUBOn\endcsname|=\noexpand\empty
   \catcode`\noexpand _|=\the\catcode`_\fi
>>>

The \''\x:SUBOff' (and \''\x:SUPOff') are activated only if the catcodes
of \`'^' and \`'_', respectively, were not 13 when tex4ht.sty was
loaded. If the catcode were 13, we need a user intervention, in which
\`'\sp' and \`'\sb' should be referenced for math mode. That is,
something along the lines \`'\ifmmode \expandafter\sp\else
\expandafter current^\fi' will probably work most of the times.

TRY: Replace SUBOn with HSUBOn, SUBOff with HSUBOff, Ditto for SUP

\<sub and sup\><<<
\let\s:b|=\sb
\let\:sbb|=\sb                 |%DraTeX already uses \:sb|%
\def\sb{\m:op\:sbb{SUB}}
\catcode`\_|=8 
\:CheckOption{no_} \if:Option
   \let\s:b|=\:UndFi  
   |<old SUB 0|>
   |<new SUB 0|>
   \def\no:restore{\let\no:restore|=\:UnDef}
\else
   \Log:Note{for non active \string_, 
       use the command line option `no\string_'}%
   |<old SUB 1|>
   |<new SUB 1|>
   \catcode`\_|=13   
      |<math sb|>
      \def\x:SUBOff{\let_|=\s:b}
      \def\pr:sb{\ifx \EndPicture\:UnDef
                     \expandafter\Protect\expandafter\S:b
                 \else \expandafter\s:b \fi}
      |<old SUB 2|>
      |<new SUB 2|>
      |<old SUB 3|>
      |<new SUB 3|>
   \catcode`\_|=8
   \:CheckOption{_13} \if:Option
      \def\no:restore{\let\no:restore|=\:UnDef
                \mathcode`\_|="8000 \catcode`\_|=13 }
      \append:def\SUBOn{\mathcode`\_|="8000 \catcode`\_|=13 |<let sb|>}
   \else
      \Log:Note{for \string_ of catcode 13, 
          use the command line option `\string_13'}
      \def\no:restore{\let\no:restore|=\:UnDef
                \mathcode`\_|="8000 \catcode`\_|=12 }
      \append:def\SUBOn{\mathcode`\_|="8000 \catcode`\_|=12 |<let sb|>}
   \fi
   \bgroup
      \SUBOn  \def\:temp{|<let sb|>} 
   \expandafter \egroup \:temp
\fi
>>>


\<old SUB 0\><<<
\let\x:SUBOff|=\empty  \let\x:SUBOn|=\empty  
>>>
\<new SUB 0\><<<
\let\SUBOff|=\empty  \let\SUBOn|=\empty  
>>>

\<old SUB 1\><<<
\ifx \sys:sb\:UnDef \def\:tempaa{_}    
\else               \def\:tempaa{\noexpand\sys:sb}\fi
>>>
\<new SUB 1\><<<
\ifx \sys:sb\:UnDef \def\:tempa#1{\append:def\SUBOff{\let#1|=_}}  
\else               \def\:tempa#1{\append:def\SUBOff{|<HSUBOff op|>}}\fi
>>>

\<HSUBOff op\><<<
\def#1{%
  \ifmmode \expandafter\s:b \else \expandafter\sys:sb \fi
}%
>>>

\<old SUB 2\><<<
\edef\:SUBOff{\def\noexpand_{\:tempaa}}
>>>

\<new SUB 2\><<<
\:tempa_
>>>

\<old SUB 3\><<<
\def\x:SUBOn{\def_{\ifmmode \expandafter\pr:sb
                 \else    \expandafter\sys:sb\fi}|<let sb|>} 
\x:SUBOn
>>>

\<new SUB 3\><<<
\def\SUBOn{\catcode`\_|=8
   \def_{\ifmmode \expandafter\pr:sb
         \else    \expandafter\sys:sb\fi}} 
\SUBOn
>>>












\<record external sub-sup\><<<
\edef\SUPOff{%
   \catcode`\noexpand ^|=\the\catcode`^\relax 
}
\edef\SUBOff{%
   \catcode`\noexpand _|=\the\catcode`_\relax
}
\bgroup
   \catcode`\^|=13   \global\let\sys:sp|=^
   \catcode`\_|=13   \global\let\sys:sb|=_
\egroup
>>>


\<sub and sup\><<<
\let\s:p|=\sp
\let\:spp|=\sp
\def\sp{\m:op\:spp{SUP}}
\catcode`\^|=7
|<default sup sup config|>
\:CheckOption{no^} \if:Option
   \let\s:p|=\:UndFi
   |<old SUP 0|>
   |<new SUP 0|>
\else
   \Log:Note{for non active \string^, 
       use the command line option `no\string^'}%
   |<old SUP 1|>%
   |<new SUP 1|>%
   \catcode`\^|=13
      |<math sp|>
      \def\x:SUPOff{\let^|=\s:p }
      \def\pr:sp{\ifx \EndPicture\:UnDef
                     \expandafter\Protect\expandafter\S:p
                 \else \expandafter\s:p \fi}
      |<old SUP 2|>
      |<new SUP 2|>
      |<old SUP 3|>
      |<new SUP 3|>
      |<sup 13|>
   \catcode`\^|=7
   \:CheckOption{^13} \if:Option
      |<sup sup 13 config|>
      \append:def\no:restore{\mathcode`\^|="8000 \catcode`\^|=13 }
      \append:def\SUPOn{\mathcode`\^|="8000 \catcode`\^|=13 |<let sp|>}
   \else
      \Log:Note{for \string^ of catcode 13, 
          use the command line option `\string^13'}%
      \append:def\no:restore{\mathcode`\^|="8000 \catcode`\^|=12 }
      \append:def\SUPOn{\mathcode`\^|="8000 \catcode`\^|=12 |<let sp|>}
   \fi
   \bgroup
      \SUPOn  \def\:temp{|<let sp|>} 
   \expandafter \egroup \:temp
\fi
>>>


\<default sup sup config\><<<
\NewConfigure{\string^\string^}[2]{%
   \def\:tempa##1>{}\def\:temp{#1}\:warning{\string
       \Configure{\string\string\string ^\string\string
       \string^}{\expandafter\:tempa\meaning \:temp}{...} 
       ignored; option \string^13 is not on}}
>>>



\<sup 13\><<<
\def\:sUp{%
   \let\:sUp|=^%
   \def^{\futurelet\:temp\next:hat}
   \def\next:hat{\ifx ^\:temp \expandafter\:dblhat\else
      \expandafter\:sUp\fi}%
}
>>>

\<sup sup 13 config\><<<
\:sUp
\def\:dblhat#1#2{\def\:temp{#2}%
   \def\:tempc{\def\:tempa####1>{}\:warning{\string^\string
       ^\expandafter\:tempa\meaning\:temp? \string\Configure{\string
       \string\string ^\string\string\string^}{\expandafter\:tempa
       \meaning \:temp}{...} or use option no\string^}}%
   \ext:chr \:tempc}
\let\ext:chr|=\empty
\NewConfigure{\string^\string^}[2]{%
   \NewConfigure{\string^\string^}{2}%
   \append:def\ext:chr{\def\:tempa{#1}\ifx \:temp\:tempa 
      \def\:tempc{#2}\fi}}             
>>>



\<old SUP 0\><<<
\let\x:SUPOff|=\empty  \let\x:SUPOn|=\empty
>>>
\<new SUP 0\><<<
\let\SUPOff|=\empty \let\SUPOn|=\empty
>>>
\<old SUP 1\><<<
\ifx \sys:sp\:UnDef \def\:tempbb{^}    
\else               \def\:tempbb{\noexpand\sys:sp}\fi
>>>
\<new SUP 1\><<<
\ifx \sys:sp\:UnDef \def\:tempb#1{\append:def\SUPOff{\let#1|=^}}  
\else               \def\:tempb#1{\append:def\SUPOff{|<HSUPOff op|>}}\fi
>>>





\<HSUPOff op\><<<
\def#1{%
  \ifmmode \expandafter\s:p \else \expandafter\sys:sp \fi
}%
>>>


\<old SUP 2\><<<
\edef\:SUPOff{\def\noexpand^{\:tempbb}}
>>>
\<new SUP 2\><<<
\:tempb^
>>>

\<old SUP 3\><<<
\def\x:SUPOn{\def^{\ifmmode \expandafter\pr:sp
                 \else    \expandafter\sys:sp\fi}|<let sp|>} 
\x:SUPOn
>>>

\<new SUP 3\><<<
\def\SUPOn{%
   \def^{\ifmmode \expandafter\pr:sp
         \else    \expandafter\sys:sp\fi}} 
\SUPOn
>>>



\<let sp\><<<
\let\sp=^
>>>

\<let sb\><<<
\let\sb=_
>>>



\<math sp\><<<
\if:Option
   \def\S:p{\m:op\s:p{SUP}}
\else
   \def\S:p#1{\def\SuP:{#1}\futurelet\:temp\sup:sub}
   \:CheckOption{^13} \if:Option \catcode`\_|=13
   \else \catcode`\_|=12\fi
   \def\blank:space{
   }
   \def\sup:sub{\expandafter
      \ifx \blank:space\:temp \expandafter\sup:subA
       \else   \expandafter\sup:subB\fi}
   \expandafter\def
      \expandafter\sup:subA\blank:space{\futurelet\:temp\sup:sub}  
   \def\sup:subB{\ifx _\:temp \expandafter\SUP:SUB
      \else \expandafter\a:putSUP \fi }
   \catcode`\_|=8
   \def\a:putSUP{\sup:I \SuP:}
   \def\sup:I{\m:op\s:p{SUP}}
\fi
>>>


\<math sb\><<<
\if:Option
   \def\S:b{\m:op\s:b{SUB}} 
\else
   \def\S:b#1{\def\SuB:{#1}\futurelet\:temp\sub:sup}
   \def\blank:space{
   }
   \def\sub:sup{\expandafter
      \ifx \blank:space\:temp \expandafter\sub:supA
       \else   \expandafter\after:sub\fi}
   \expandafter\def
      \expandafter\sub:supA\blank:space{\futurelet\:temp\sub:sup}  
   |<extension of sub|>
   \def\a:putSUB{\sub:I \SuB:}
   \def\sub:I{\m:op\s:b{SUB}} 
\fi
>>>


%   \def\sub:supB{\ifx ^\:temp \expandafter\SUB:SUP
%      \else  \expandafter\after:sub\fi}


\<utilities\><<<
\NewConfigure{afterSUB}[2]{\expandafter
   \def \csname \meaning#1sb\endcsname{#2}}
\NewConfigure{putSUB}[1]{\def\a:putSUB{#1}}
\NewConfigure{putSUP}[1]{\def\a:putSUP{#1}}
\:CheckOption{no^} \if:Option \else
   \:CheckOption{^13} \if:Option \catcode`\^|=13
   \else \catcode`\^|=12 \fi
      \Configure{afterSUB}^{\SUB:SUP}
   \catcode`\^|=7
\fi
>>>

The following is needed for a math prime after sub. For instance, \'+a_1'$+.

\<extension of sub\><<<
\def\after:sub{\futurelet\:temp\choose:sub}
\def\choose:sub{\expandafter
   \ifx \csname \meaning\:temp sb\endcsname\relax
       \expandafter \a:putSUB
   \else
       \expandafter\expandafter\csname \meaning\:temp sb\endcsname
   \fi
}
>>>


We need to catch cases like the blank space appearing after the b 
within AmsTeX in an equation like:
\Verbatim
\begin{equation}
a^b
_c
\end{equation}
\EndVerbatim
We can't use a declaration of the form
   \''\def\sub:supA#1{...'
because the macro consumes the parameter following the space,
and that parameter can a forbidden token.



The \`'\edef\:SUBSUPOff' doesnt wotk with \''\let' instead
of \''\def' in the body. Why? 


\<sub and sup\><<<
\def\m:op{\ifx \EndPicture\:UnDef  \expandafter\:mop
          \else                    \expandafter\:m:p\fi}
\def\:mop{\relax\ifmmode \expandafter \mo:p \else \expandafter\mop:\fi}
\def\mo:p#1#2#3{{\csname a:#2\endcsname
   #1{#3}\csname b:#2\endcsname}}
\def\mop:#1#2#3{#1}
\def\:m:p#1#2{#1}
>>>

\<sub and sup\><<<
\NewConfigure{SUB}{2}
\NewConfigure{SUP}{2}
>>>

We need to pause the hyperext font for the case that the
subscript itself comes with a font change. Without the
pause we'll get a partial overlap with the \''<SUB/SUP>' 
font (e.g., \`'\it $\A_{\mathbf{R}}$').


In case that \`'^' looses its original meaning, TeX will complain
about double exponnet if it follows a quote symbol.\ifHtml[\HPage{'}\Verbatim
\input tex4ht.sty   \Preamble{html}   \EndPreamble

$\overline{a'^b}$

\csname bye\endcsname 

\EndVerbatim\EndHPage{}]\fi.

\SubSection{Merging Subscripts and Superscripts}

Two options \`'\Configure{SUBSUP}{ before }{ between }{ after }'
and
\`'\Configure{SUPSUB}{ before }{ between }{ after }', differing in the
way the reorder the superscript and subscript.  However, if the
three parameters are empty, or just a single subscript / superscript
is present, then \`'\Configure{SUB}{ before }{ after }'
and \`'\Configure{SUP}{ before }{ after }' get into effect.

\<sub and sup\><<<
\:CheckOption{no^} \if:Option \else \:CheckOption{no_}\fi
\if:Option 
   \NewConfigure{SUBSUP}[3]{}
   \NewConfigure{SUPSUB}[3]{}
   \NewConfigure{SUB/SUP}[6]{}
\else
   \def\SUP:SUB#1#2{\let\chs:sbsp|=\:gobble\def\SuB:{#2}\SUBSUP:}
   \def\SUB:SUP#1#2{\def\chs:sbsp##1##2{##1}\def\SuP:{#2}\SUBSUP:}
   \let\SUBSUP:|=\empty
   \NewConfigure{SUBSUP}[3]{%
      \def\:temp{#1#2#3}\ifx \:temp\empty
        \def\SUBSUP:{\sub:I\SuB:\sup:I\SuP:}%
      \else   \def\SUBSUP:{#1\s:b{\SuB:}#2\s:p{\SuP:}#3}\fi}
   \NewConfigure{SUPSUB}[3]{%
      \def\:temp{#1#2#3}\ifx \:temp\empty
        \def\SUBSUP:{\sup:I\SuP:\sub:I\SuB:}%
      \else   \def\SUBSUP:{#1\s:p{\SuP:}#2\s:b{\SuB:}#3}\fi}
   \NewConfigure{SUB/SUP}[6]{%
      \def\:temp{#1#2#3#4#5#6}\ifx \:temp\empty
        \def\SUBSUP:{\sub:I\SuB:\sup:I\SuP:}%
      \else   \def\SUBSUP:{\chs:sbsp
                 {#1\s:b{\SuB:}#2\s:p{\SuP:}#3}%
                 {#4\s:p{\SuP:}#5\s:b{\SuB:}#6}}\fi}
\fi
>>>



\SubSection{Early Activation of Sub/Sup Scripts}


\<early latex subs/sups\><<<
\ifx \config:opt\:UnDef \else 
  |<defs for early latex subs/sups|>
\fi
>>>

\<defs for early latex subs/sups\><<<
\append:def\:RestoreCatcodes{\early:sub\early:sup}
\let\:IfFileExists\IfFileExists
\long\def\IfFileExists#1#2#3{%
   \csname recall:sub\endcsname   
   \csname recall:sup\endcsname
   \expandafter\let\csname #1:sub\endcsname=\early:sub
   \expandafter\let\csname #1:sup\endcsname=\early:sup
   \let\early:sub=\relax     \let\recall:sub\relax   
   \let\early:sup=\relax     \let\recall:sup\relax
   \:IfFileExists{#1}{#2}{#3}%
   \expandafter\let\expandafter\early:sub\csname #1:sub\endcsname
   \expandafter\let\expandafter\early:sup\csname #1:sup\endcsname
   \early:sub \early:sup
}
\ifx \o:document\:UnDef
   \pend:def\Preamble{%
     \csname recall:sub\endcsname   
     \csname recall:sup\endcsname}
\fi
>>>

\</document recall sub/sup\><<<
\csname recall:sub\endcsname   
\csname recall:sup\endcsname
>>>

\<defs for early latex subs/sups\><<<
\def\:CheckOption#1{\def\:temp{#1}%
   \:Optionfalse
   \expandafter\:ScanOptions\config:opt,,//}
\def\:ScanOptions#1,#2//{\def\:next{#1}%
   \ifx        \:next\empty
   \else \ifx  \:temp\:next   \:Optiontrue   \let\:next\relax
   \else \def\:next{\:ScanOptions#2//}%
   \fi  \fi  \:next }
|<cats early latex subs/sups|>
\let\:CheckOption|=\:UnDef
>>>



\<cats early latex subs/sups\><<<
\let\early:sub=\empty
\:CheckOption{early_} \if:Option
   \:CheckOption{no_} \if:Option  \else
      \:CheckOption{_13} \if:Option
           \def\early:sub{%
               \xdef\recall:sub{%
                  \mathcode`\noexpand\_=\the\mathcode`\_
                  \catcode`\noexpand\_=\the\catcode`\_
               }
              \mathcode`\_="8000 \catcode`\_=13 
          }
      \else
           \def\early:sub{%
               \xdef\recall:sub{%
                  \mathcode`\noexpand\_=\the\mathcode`\_
                  \catcode`\noexpand\_=\the\catcode`\_
   % \writesixteen{.....sub \the\catcode`\_}%
               }%
              \mathcode`\_="8000 \catcode`\_=12 
   % \writesixteen{.....sub 12}
          }
      \fi
   \fi
\else 
   \Log:Note{for \string_ at preamble, 
          use the command line option `early\string_'}%   
\fi
>>>

\<cats early latex subs/sups\><<<
\let\early:sup=\empty
\:CheckOption{early^} \if:Option
   \:CheckOption{no^} \if:Option \else
      \:CheckOption{^13} \if:Option
           \def\early:sup{%
               \xdef\recall:sup{%
                  \mathcode`\noexpand\^=\the\mathcode`\^
                  \catcode`\noexpand\^=\the\catcode`\^
               }
              \mathcode`\^="8000 \catcode`\^=13 
          }
      \else
           \def\early:sup{%
               \xdef\recall:sup{%
                  \mathcode`\noexpand\^=\the\mathcode`\^
                  \catcode`\noexpand\^=\the\catcode`\^
   % \writesixteen{.....sup \the\catcode`\^}%
               }%
              \mathcode`\^="8000 \catcode`\^=12
   % \writesixteen{.....sup 12}% 
          }
      \fi
   \fi
\else 
   \Log:Note{for \string^ at preamble, 
          use the command line option `early\string^'}%   
\fi
>>>


\Section{Math Classes}





The requests are placed on symbols of the fonts, which might be a
problem for symbols  not used in math.

\<math classes\><<<
\def\MathClass{\ht:special{t4ht\string^}}
\let\EndMathClass|=\MathClass
\def\PauseMathClass{\ht:special{t4ht\string^-}}
\def\EndPauseMathClass{\ht:special{t4ht\string^+}}
>>>




Math classes: Ordinary (0), large operators (1), binary operators (2),
relation (3), opening del (4), closing delimiter (5),
punctuation (7).



\SubSection{Configure Characters}


Set the class delimiters for the symbols.

\<math classes\><<<
\catcode`\^=7
\NewConfigure{MathClass}[5]{\NoFonts \ht:special{t4ht@[}%
   \def\:temp{#2}\ifx \:temp\empty \else
      \ht:special{t4ht\string^#1#2#3#2#4}\fi
   \def\:temp{#5}\ifx \:temp\empty \else
      \bgroup \everypar{}\everymath{}\everydisplay{}%
      \hbox{${\ht:special{t4ht\string^#1}%
         {#5}^{{#5}^{#5}}\ht:special{t4ht\string^}}$}%
      \vbox{$${\ht:special
         {t4ht\string^#1}{#5}^{{#5}^{#5}}\ht:special{t4ht\string^}}$$}\egroup
   \fi
   {\everypar{}\noindent\vfill\break}% 
   \ht:special{t4ht@]}\EndNoFonts
}
\NewConfigure{MathDelimiters}[2]{\NoFonts \ht:special{t4ht@[}%
  \bgroup \everypar{}\everymath{}\everydisplay{}%
  \hbox{${\ht:special
                     {t4ht\string^4}#1\ht:special{t4ht\string^5}#2%
    \ht:special{t4ht\string^4}{}^{#1}\ht:special{t4ht\string^5}{}^{#2}%
    \ht:special{t4ht\string^4}{}^{{}^{#1}}\ht:special
                                         {t4ht\string^5}{}^{{}^{#2}}%
    \ht:special{t4ht\string^}}$}%
  \vbox{$${\ht:special
                     {t4ht\string^4}#1\ht:special{t4ht\string^5}#2%
    \ht:special{t4ht\string^4}{}^{#1}\ht:special{t4ht\string^5}{}^{#2}%
    \ht:special{t4ht\string^4}{}^{{}^{#1}}\ht:special
                                         {t4ht\string^5}{}^{{}^{#2}}%
    \ht:special{t4ht\string^}}$$}%
    {\everypar{}\noindent\vfill\break}% 
    \ht:special{t4ht@]}\egroup
  \EndNoFonts}
\catcode`\^=12
>>>



\<math classes\><<<
\HAssign\New:MathClass|=7
\catcode`\/=0
\catcode`\\=12
/def/NewMathClass#1{/relax
  /expandafter/ifx /csname /expandafter/:gobble/string#1/endcsname/relax
    /gHAdvance/New:MathClass by 1/relax
    /ifnum /New:MathClass>78
       /:warning{Too many math classes}
    /else
       /HAssign#1/New:MathClass /def/:tempc{#1}/:NewMC
       0123456789:;<=>?%
       @ABCDEFGHIJKLMNO%
       PQRSTUVWXYZ[\]{/string^}{/string_}%
       `abcdefghijklmno%
       pqrstuvwxyz{/string{}||{/string}}{/string~}|<par del|>%
    /fi
  /else
     /:warning{/string#1 is already defined}
  /fi}
/catcode`/\=0 
\catcode`\/=12
\def\:NewMC#1{%
   \ifnum \:tempc=0 \expandafter\xdef\:tempc{#1}\expandafter\stop:do
   \else
      \expandafter\HAdvance\:tempc |by -1\relax
      \expandafter\:NewMC
   \fi
}
>>>

79 math classes: 0--78.


\<math classes\><<<
\NewConfigure{nolimits}[1]{\def\:temp{#1}\ifx \:temp\empty
   \let\nolimits|=\o:nolimits: \else 
   \def\:temp{\o:nolimits:\futurelet\:temp\:nolimits}%
   \def\:nolimits{\ifx \:temp\limits \else
                  \ifx \:temp\nolimits \else #1\fi\fi}%
   \HLet\nolimits|=\:temp \fi}
\let\o:nolimits:|=\nolimits
\NewConfigure{limits}[1]{\def\:temp{#1}\ifx \:temp\empty
   \let\limits|=\o:limits: \else
   \def\:limits{\ifx \:temp\nolimits \else#1\fi}%
   \def\:temp{\o:limits:\:l:mits}%
   \HLet\limits|=\:temp \fi}
\let\o:limits:|=\limits

\def\::limits{\expandafter\ifx \blank:spc\:temp
     \afterassignment\:l:mits \tmp:cnt0%
  \else
     \ifx \limits\:temp\else 
        \expandafter\expandafter\expandafter\:limits 
     \fi
  \fi}
\def\:l:mits{\futurelet\:temp\::limits}
\catcode`\ =13\relax\def\blank:spc{\let\blank:spc= }\blank:spc%
\catcode`\ =10\relax
>>>


Test case to check: \Verb=\[\sum\nolimits\limits_a^b  u_s^2 \]=


The assignment \`'\tmp:cnt0%' also consumes the space that follows.




\<math classes\><<<
\NewConfigure{displaylimits}[1]{\def\:temp{#1}\ifx \:temp\empty
   \let\displaylimits|=\o:displaylimits: \else
   \def\:displaylimits{\ifx \:temp\nolimits \else
           \ifx \:temp\limits \else  #1\fi\fi}%
   \def\:temp{\o:displaylimits:\display:l:mits}%
   \HLet\displaylimits|=\:temp \fi}
\let\o:displaylimits:|=\displaylimits
\def\::displaylimits{\expandafter\ifx \blank:spc\:temp
     \afterassignment\display:l:mits \tmp:cnt0%
  \else\expandafter\:displaylimits \fi}
\def\display:l:mits{\futurelet\:temp\::displaylimits}
>>>



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\SubSection{Configure Grouped Classes}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\`'\mathord{...}' et al request delimiters for their arguments.  The
\`'\special{t4ht^X}' , for `~'-`0' (digit) greater than 79, request
the delimiters of class 0 to apply to the next group (created by the
math ord).  The \`'0' asks to ignore nested delimiters; can be
replaced by \`'1' to request the sub delimiters.




A \`'\special{t4ht\string^)*...*...}' is variant of
\`'\Send{Group}{1}...  \Send{EndGroup}{1}' for delimiters, without
subdelimiters. Taking \`'(' (or any other character which below a
digit and not + or -) instead of \`')' gives also the subdelimiters.

A \`'\special{t4ht\string^i)}'  takes the delimiters from
the characters of class i.


\<grouped math classes\><<<
\def\:temp{\a:mathord \o:mathord:}      \HLet\mathord|=\:temp
\let\a:mathord|=\empty 
\def\:temp{\a:mathop \o:mathop:}        \HLet\mathop|=\:temp
\let\a:mathop|=\empty 
\def\:temp{\a:mathbin \o:mathbin:}      \HLet\mathbin|=\:temp
\let\a:mathbin|=\empty 
\def\:temp{\a:mathrel \o:mathrel:}      \HLet\mathrel|=\:temp
\let\a:mathrel|=\empty 
\def\:temp{\a:mathopen \o:mathopen:}    \HLet\mathopen|=\:temp
\let\a:mathopen|=\empty 
\def\:temp{\a:mathclose \o:mathclose:}  \HLet\mathclose|=\:temp 
\let\a:mathclose|=\empty 
\def\:temp{\a:mathpunct \o:mathpunct:}  \HLet\mathpunct|=\:temp
\let\a:mathpunct|=\empty 
>>>



\<grouped math classes\><<<
\NewConfigure{FormulaClass}[4]{%
   \def\:temp{#2}%
   \expandafter\edef\csname a:\ifcase #1 mathord\or mathop\or
      mathbin\or mathrel\or mathopen\or mathclose\else
      mathpunc\fi\endcsname{\noexpand\ht:special
      {t4ht\string^\ifx\:temp\empty#1)\else )#2#3#2#4\fi}}}
>>>




\`'\Configure{FormulaClass}{class number}{char}{before}{after}':
char+before+after=empty implies same markings as for single 
characters.  In fact, can do the same for any sub formula with any function,
not just the math functions.

\<grouped math classes\><<<
\NewConfigure{FormulaClass*}[4]{%
   \def\:temp{#2}%
   \expandafter\edef\csname a:\ifcase #1 mathord\or mathop\or
      mathbin\or mathrel\or mathopen\or mathclose\else
      mathpunc\fi\endcsname{\ht:special
      {t4ht\string^\ifx\:temp\empty#1(\else (#2#3#2#4\fi}}}
>>>

The following are generalizations, introduced for allowing temporary
changs, like in \`'
\renewcommand{\opname}[1]{%
   \Configure{mathop*}{*}{<mrow>}{</mrow>}{\Configure{FormulaClass}{0}{}{}{}}
   \mathop{\fam0#1}}'.

\<grouped math classes\><<<
\NewConfigure{mathord}[4]{\Configure{FormulaClass}{0}{#1}{#2}{#3}%
   \pend:def\a:mathord{#4}}
\NewConfigure{mathop}[4]{\Configure{FormulaClass}{1}{#1}{#2}{#3}%
   \pend:def\a:mathop{#4}}
\NewConfigure{mathbin}[4]{\Configure{FormulaClass}{2}{#1}{#2}{#3}%
   \pend:def\a:mathbin{#4}}
\NewConfigure{mathrel}[4]{\Configure{FormulaClass}{3}{#1}{#2}{#3}%
   \pend:def\a:mathrel{#4}}
\NewConfigure{mathopen}[4]{\Configure{FormulaClass}{4}{#1}{#2}{#3}%
   \pend:def\a:mathopen{#4}}
\NewConfigure{mathclose}[4]{\Configure{FormulaClass}{5}{#1}{#2}{#3}%
   \pend:def\a:mathclose{#4}}
\NewConfigure{mathpunct}[4]{\Configure{FormulaClass}{6}{#1}{#2}{#3}%
   \pend:def\a:mathpunct{#4}}
>>>



\<grouped math classes\><<<
\NewConfigure{mathord*}[4]{\Configure{FormulaClass*}{0}{#1}{#2}{#3}%
   \pend:def\a:mathord{#4}}
\NewConfigure{mathop*}[4]{\Configure{FormulaClass*}{1}{#1}{#2}{#3}%
   \pend:def\a:mathop{#4}}
\NewConfigure{mathbin*}[4]{\Configure{FormulaClass*}{2}{#1}{#2}{#3}%
   \pend:def\a:mathbin{#4}}
\NewConfigure{mathrel*}[4]{\Configure{FormulaClass*}{3}{#1}{#2}{#3}%
   \pend:def\a:mathrel{#4}}
\NewConfigure{mathopen*}[4]{\Configure{FormulaClass*}{4}{#1}{#2}{#3}%
   \pend:def\a:mathopen{#4}}
\NewConfigure{mathclose*}[4]{\Configure{FormulaClass*}{5}{#1}{#2}{#3}%
   \pend:def\a:mathclose{#4}}
\NewConfigure{mathpunct*}[4]{\Configure{FormulaClass*}{6}{#1}{#2}{#3}%
   \pend:def\a:mathpunct{#4}}
>>>





%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Renewed Commands}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\SubSection{Math Symbols from Macros}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

The \`'\MathSymbol' works on empty when the symbol comes from a font.
That is, when the macro is defined as \`'\mathchar"xxxx'.  A
\`'\MathSymbol+' variant may be applied to force definitions.  Warning
messages are not helpful as the symbols may have nultiple definitions
dependent on the style files being loaded.

\<built-in tex math ops\><<<
\def\MathSymbol{\futurelet\:temp\:::MathSymbol}
\def\:::MathSymbol{\if +\:temp
   \expandafter\:MathSymbol \else
   \expandafter\::MathSymbol \fi
}
\def\::MathSymbol#1#2{%
   \def\:tempb##1"##2///{##1}%
   \edef\:tempa{\expandafter\expandafter\expandafter\:tempb
       \expandafter\meaning\csname#2\endcsname"///}%
   \edef\:tempc{\string\mathchar}%
   \ifx \:tempa\:tempc 
      \NewConfigure{#2}{1}\Configure{#2}{\csname o:#2:\endcsname}%
   \else
      \:MathSymbol{}{#1}{#2}%
   \fi
}
\def\:MathSymbol#1#2#3{%
   \def\:temp{{\math:sym#2{#3}}}%
   \expandafter\HLet\csname #3\endcsname\:temp
   \NewConfigure{#3}{1}\Configure{#3}{\csname o:#3:\endcsname}%
}
\def\math:sym#1#2{{\relax\ifmmode \expandafter#1\fi
   {\csname a:#2\endcsname}}}
>>>

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\SubSection{/left and /right}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Again, we don't want line breaks from \''<PRE>'s  within
formulas in visual browsers.

\<built-in tex math ops\><<<
\def\:temp#1{\a:left{#1}\o:left:#1\b:left{#1}}
\HLet\left|=\:temp
\def\:temp#1{\a:right{#1}\o:right:#1\b:right{#1}}
\HLet\right|=\:temp
\NewConfigure{left}[2]{\def\a:left##1{#1}\def\b:left##1{#2}}
\NewConfigure{right}[2]{\def\a:right##1{#1}\def\b:right##1{#2}}
\Configure{left}{}{}
\Configure{right}{}{}
>>>



\SubSection{Fractions}


\<built-in tex math ops\><<<
\def\:tempc{\pic:gobble\a:over \o:over: \pic:gobble\b:over}
\HLet\over|=\:tempc
\NewConfigure{over}{2}
\def\:tempc{\pic:gobble\a:atop \o:atop: \pic:gobble\b:atop}
\HLet\atop\:tempc
\NewConfigure{atop}{2}
\def\::above{\pic:gobble\a:above \o:above:\tmp:dim
            \pic:gobble\b:above }
\def\:above{\afterassignment\::above}
\def\:tempc{\Protect\:above \tmp:dim|=}
\HLet\above\:tempc
\NewConfigure{above}{2}
>>>

\<built-in tex math ops\><<<
\def\::abovewithdelims#1#2{\pic:gobble\a:abovewithdelims
   \o:abovewithdelims:#1#2\tmp:dim\pic:gobble\b:abovewithdelims}
\def\:abovewithdelims#1#2{\def\:temp{\::abovewithdelims#1#2}%
   \afterassignment\:temp\tmp:dim=}
\def\:tempc{\Protect\:abovewithdelims }
\HLet\abovewithdelims\:tempc
                            \NewConfigure{abovewithdelims}{2}
\def\:overwithdelims#1#2{\pic:gobble\a:overwithdelims 
   \o:overwithdelims:#1#2\pic:gobble\b:overwithdelims}
\def\:tempc{\Protect\:overwithdelims}
\HLet\overwithdelims\:tempc
                            \NewConfigure{overwithdelims}{2}
\def\:atopwithdelims#1#2{\pic:gobble\a:atopwithdelims 
   \o:atopwithdelims:#1#2\pic:gobble\b:atopwithdelims}
\def\:tempc{\Protect\:atopwithdelims}
\HLet\atopwithdelims\:tempc
                            \NewConfigure{atopwithdelims}{2}
>>>



\`'\Configure{over}
    {\Send{GROUP}{0}{[before]}[before-rule]}
    {[before-argument]\Send{EndGROUP}{0}{[after]}}'



\`'
\Configure{over}
   {\special{t4ht\string~<<NOMINATOR>}\HCode
     {</NOMINATOR><DENOMINATOR>}}
   {\special{t4ht\string~></DENOMINATOR>}}'


   
   Beware of nested formulas for proper arrangments of
   \`'\special{t4ht\string~...}'






\SubSection{Radical's}

\<built-in tex math ops\><<<
\def\:temp{\pic:gobble\a:radical\o:radical:}
\HLet\radical|=\:temp
\NewConfigure{radical}{1}
>>>

\Verbatim
\Configure{radical}{%
   [before-sign]%
   \Send{EndGROUP}{2}{[after-sign]}%
   \Send{GROUP}{3}{[before-body]}%
   \Send{EndGROUP}{3}{[after-body]}%
}
\EndVerbatim


\SubSection{Mathchoice}

The following is disabled because \TeX{} evaluates the four parameters
and then keeps one and throws away the other.  With the picture
environment enabled, we'll get messages in the log file of the form
\`'--- needs --- a.idv[1] ==> ai.gif ---' for pictures that are not
included in the code.


\<built-in tex math ops\><<<
\def\:temp#1#2#3#4{\a:mathchoice
   \o:mathchoice:{#1}{#2}{#3}{#4}\b:mathchoice }
\HLet\mathchoice|=\:temp
\NewConfigure{mathchoice}{2}
>>>



The following, for \''\?phantom', is not needed because it is already
covered by \''\mathchoice'.

\Verbatim
\def\makeph@nt#1{\PictureOff
   \setbox\z@\hbox{#1}\finph@nt  \PictureOn}
\def\mathph@nt#1#2{\PictureOff
   \setbox\z@\hbox{$\m@th#1{#2}$}\finph@nt \PictureOn}
\EndVerbatim




\SubSection{Equation Numbers}

The \''\eqno' and \''\leqno' refer to what follow them in the math
environment as left and right equation numbers, respectively. Tex
typesets them within groups, so material can be sent to the end of the 
number with a \`'\Send{GROUP}{0}{...}'.

\<built-in tex math ops\><<<
\def\:temp{\o:eqno:\a:eqno}
\HLet\eqno|=\:temp
\def\:temp{\o:leqno:\a:leqno}
\HLet\leqno|=\:temp
\NewConfigure{eqno}{1}
\NewConfigure{leqno}{1}
>>>






In addition, 
\`'1140. We get into ordinary math mode from display math mode when 
the equation numbers \eqno and \leqno appear'.
Hence, the \`'\everymath{}' is needed also for the display case.
To be on the sure side, we also put \`'\everydisplay{}' in the math mode.




\Chapter{Decorated Symbols}



\Section{Htf Classes: Requesting BackEnd Fonts through /specials}


\<font config util\><<<
\NewConfigure{htf}[9]{{%
  \tmp:cnt|=#1 \ifnum \tmp:cnt>255  \:warning{Code larger than 
              255 in \string\Configure{htf}}\else
  \ht:special{t4ht;||\ifnum \tmp:cnt<10 00\else 
    \ifnum \tmp:cnt<100 0\fi\fi
    \the\tmp:cnt#2#3#2#4#2#5#2#6#2#7#2#8#2#9#2\the\tmp:cnt}%
  \fi}}
>>>


A \`'\%x' requests character code in hexadecimal representation.


\`'\Configure{htf}' is essentially a configuration on
fonts, where even cases, for instance, the \`'\special{t4ht;|004...}'
extra independent information for characters.
Odd cases like  \`'\special{t4ht;|003...}', on the other hand, are 
addition to the \`'IMG' and not an independent info !!!

\SubSection{Pausing}

\<font config util\><<<
\def\NoFonts{\ht:special{t4ht;8}}
\def\EndNoFonts{\ht:special{t4ht;9}}
>>>


Nesting is allowed.

\SubSection{Configurations}

Code for calls made from htf fonts.  Should start with three
digits defining a number smaller than 256.  Odd numbers apply
to gifs, and even to text.  The odd are intended for insertion into
IMG marks, the odd are not used yet.

The character part is prented for codes that are not given in 
cases of characters and image-characters, respectively.
Code 000 is created to groups of non image characters, and the
codes 002, 004, 006, add extras to individual characters. The
od codes deal only with specific characters, not groups.

The corresponding formatting instructions in the css
file are determined in the `Font' option within the
perl script.



\<font config util\><<<
\NewConfigure{FontCss}[2]{\def\a:FontCss:{#1}\def\a:FontCssPlus:{#2}}
>>>

\<font config util\><<<
\NewConfigure{htf-css}[2]{{%
   \def\:temp##1|<par del|>{\def\:tempa{##1}}%
   \afterassignment\:temp\tmp:cnt|=0#1|<par del|>%
   \def\:temp{\Configure{Needs}}%
   \ifx  \:tempa\empty
       \expandafter\:temp\expandafter{\a:FontCss:}\Needs{("#1"): #2}%
   \else
       \expandafter\:temp\expandafter{\a:FontCssPlus:}\Needs{#1 #2}%
   \fi}}
\NewConfigure{htf-attr}[2]{{%
   \Configure{Needs}{##1}%
   \Needs{Font\string_css\string_base: #1Font\string_css\string_mag: #2}}}
>>>


\`'\NewConfigure{htf-css}{number}{...}' for a class;
\`'\NewConfigure{htf-css}{not-number}{...}' for a htf font.




\`'\Configure{htf}{even}{+}{open}{name}{size}{mag}{ord}{ch}{end}{gif-id}'



\`'\Configure{htf}{odd}{+}{open}{alt}{class}{size}{mag}{ord}{end}': mag and
ord must be integer patterns.


\`'\Configure{htf-css}{4}{.underline{text-decoration:underline; }}' is
alredy covered.



HOW \`'\Configure{htf-css}{4}{.small-caps{font-variant: small-caps; }}'
differs from \`'\Css{.small-caps{font-variant: small-caps; }}'?
The latter is alway introduced into the
css file, wheras the earlier only conditionally when the font/class is in use.


% \special{t4ht;||003"\Hnewline ALIGN="MIDDLE}


% \special{t4ht;||003-MIDDLE}





We have
\Verbatim
\Configure{htf}
     {odd-for-img-chr}
     {distinguished delimiter ch+id}
     {prefix for file name, if the latter is desired}
     {prefix for alt, if the latter is desired}
     {c-template, if family name is desired}
     {c-template, if font size is desired}
     {c-template, if font mag is desired}
     {c-template, if ch ord is desired}
     {close of tag}
\Configure{htf}
     {even-for-reg-chr}
     {distinguished delimiter ch+id}
     {prefix}
     {c-template, if family name is desired}
     {c-template, if font size is desired}
     {c-template, if font mag is desired}
     {c-template, if ch ord is desired}
     {postfix}
     {closing tag}
\EndVerbatim



The id is to be used in Needs fo associating styles to the
character decorations.  Also, due to the id, we can assign to the
same code of font different styles.
\ifHtml[\HPage{example}\Verbatim
\Configure{htf}{6}{+a}{}{}{<a..
   FONT="\%s}{\%s"}{MAG="\%d"}{ORD="\%d"}{>}
$\leq$
\Configure{htf}{6}{+b}{}{}{<b...
   FONT="\%s}{\%s"}{MAG="\%d"}{ORD="\%d"}{>}
$\leq$

\Needs{a .......}
\Needs{b .......}
\EndVerbatim

produces

\Verbatim
Font class 6 a: <a.. FONT="%s%s"MAG="%d"ORD="%d">
Font class 6 b: <b... FONT="%s%s"MAG="%d"ORD="%d">
l. 27 --- needs --- a ....... ---
l. 28 --- needs --- b ....... ---
\EndVerbatim\EndHPage{}]\fi

Newer:

\Verbatim
Css: TD.caption{white-space: nowrap; }
Font("cmex","10","100")
Font("cmmi","10","100")
Font("cmmi","5","100")
Font("cmmi","7","100")
Font("cmr","10","100")
Font("cmr","5","100")
Font("cmr","7","100")
Font("cmsy","10","100")
Font("cmsy","7","100")
Font("cmti","10","100")
Font("cmtt","10","100")
Font_Class(1,""): <IMG SRC=""ALT=""CLASS="%s%s-%d--%x">
Font_Class(3,"mva"): <IMG SRC=""ALT=""CLASS="%s-%d--%x"ALIGN="MIDDLE">
Font_Class(6,"ul"): <SPAN CLASS="underline"></SPAN>
Font_Css("sc"): .small-caps{font-variant: small-caps; }
Font_Css("ul"): .underline{text-decoration:underline; }
\EndVerbatim

The \`'Font(...)' indicates the fonts in use; it's format is determined
by the system variable LGFNT, and can be changed within the env file
through a `f' flagged field. The indicated fonts are used for deciding
which entries in \`'htf.sty' should be introduced into the css file.

The \`'Font_Class(...)' indicates the classes in use within the fonts;
it's format is determined by the system variable LGCLS, and can be
changed within the env file through a `c' flagged field.

The \`'Font_Css' is a contribution from the TeX file, from
\`'\Configure{htf-css}{...}'   commands.
It overides info found in \`'htf.sty'.
  Its format can be
changed by \`'\Configure{FontCss}{...##1...}', before the
\''\Preamble' command.

The \`'Css' is a contribution from the TeX file, from \`'\Css{...}'
comamnds that preced the \''\CssFile' command.  Its format can be changed
by \`'\Configure{Css}{...##1...}', before the \''\Preamble' command.

The \`'\special{t4ht;,}' prevents notification to the
log file of the change requested by \`'\Configure{htf}'.

\`'\Configure{htf-css}{cmmi}{font-style: italic;}'
produces
\`'Font_Css_Plus cmmi font-style: italic;'
and that appears also in \`'htf.sty'.
The following are already in \`'htf.sty'.


%%%%%%%%%%%%%%%%%%%%%%
\Section{New Accents}
%%%%%%%%%%%%%%%%%%%%%%

\<accents\><<<
\:CheckOption{new-accents}     \if:Option
   |<new accents|>
\else
   |<tools for accents|>
   |<old accents|> 
\fi
>>>





Some accents of TeX are defined through commands of the form
\`'\accent <number> <char>', and some throught macros (e.g., \''\b',
\''\c', and \''\d').  Moreover,the \`'\accent <number> <char>' reduces
to \`'\char <number>', whenever \''<char>' doesn't immediately follows
\''<number>' (however, font changes, etc, are possible in between).

We can't decide the content of accented charaters without looking at
the htf fonts.  The accented characters of the source (la)tex files
may go through transformations due to \''\uppercase' and
\''\lowercase' operations (e.g., \'+\uppercase \'a+).

\<new accents\><<<
\def\:temp{\leavevmode\ifx \d:mathaccent\empty
    \else \ht:special{t4ht\string~>1\d:mathaccent}\fi
    \ht:special{t4ht*\string^m}\o:mathaccent:}
\HLet\mathaccent|=\:temp
\def\:temp{\leavevmode\ht:special{t4ht*\string^t}\o:accent:}
\HLet\accent|=\:temp
\NewConfigure{accent}[6]{\ht:special{t4ht*\string^t#1#2#1#3#1#4#1#5#1#6}}
\NewConfigure{mathaccent}[6]{\ht:special{t4ht#1\string
  ^m#1#2#1#3#1#4#1#5#1}\edef\d:mathaccent{#6}}
\let\d:mathaccent|=\empty
\NewConfigure{accented}[6]{\ht:special
     {t4ht*\string^a#1#2#1#3#1#4#1#5#1#6}}
\NewConfigure{accenting}[3]{\ht:special{t4ht*\string^i#1#2#1#3#1#1}}
>>>

%%%%%%%%%%%%%%%%%%%%%%
\SubSection{Screening}
%%%%%%%%%%%%%%%%%%%%%%

The following feature is used as in

\`'\Configure{HAccent}\hat{AEIOUaeiou{}}{\Picture+{}}{\EndPicture}'

and it screens which characters are allowed to use the native
definitions of the accents, and which one the commands tailored for
the hooks.




\<new accents\><<<
\NewConfigure{HAccent}[1]{\pic:Accent#1}
\def\pic:Accent#1#2#3#4{\edef\:tempb##1{{\expandafter\:gobble\string#1}}%
   \pend:defI\:tempb{\choose:accent{####1}#2\relax|<par del|>}%
   \append:defI\:tempb{{#3}{#4}}%
   \expandafter\let\csname \string#1:\endcsname|=\:tempb
   \edef\:tempb{\noexpand\Protect\noexpand\acc:nm{\string#1}}%
   \HLet#1|=\:tempb}
\def\acc:nm#1{\csname \string#1:\endcsname}
>>>

The following sub-utilities iteratively search the dictionary to check
whether the parameter is known.

\<new accents\><<<
\def\choose:accent#1{\def\:accented{#1}\cs:accent}
\def\realx:par{\relax}
\def\cs:accent#1{\def\:tempa{#1}%
   \ifx \:tempa\realx:par \expandafter\pic:accent
   \else
       \ifx \:tempa\:accented
            \expandafter\expandafter\expandafter\nopic:accent 
       \else \expandafter\expandafter\expandafter\cs:accent\fi
   \fi}
\def\pic:accent#1|<par del|>#2#3#4{%    
   #3\nopic:accent|<par del|>{#2}{}{}#4}
\def\nopic:accent#1|<par del|>#2#3#4{\expandafter\expandafter
   \csname o:#2:\endcsname\expandafter{\:accented}}
>>>

%%%%%%%%%%%%%%%%%%%%%%
\Section{Old Accents}
%%%%%%%%%%%%%%%%%%%%%%



For entries not in the given font tables (not specified in the
\`'\Configure{accent}'), problems can arise for cases such as
\`'csname \ifmmode m\else t\fi :\acn:no\endcsname{#2}' and
\`'\hat{\char o}' when they don't go into pictures. 

\SubSection{Accents through `accents' Configurations}

The
\`'\Configure{accent}\^\hat{{A-in}{A-out}{B-in}{B-out}...{}{last-out}}
{do-found} {do-not-found}' defines the text accent \''\^' and math
accent \''\hat'.  In cases that the text or math accent has no counter math
accent, we fake \''\null' for the math part.

When \''\hat{foo}' is encountered, a search is made for an \`'??-i'
that equals  \`'foo' in the given accent table. If found, do-found is
executed; otherwise, do-not-found is executed. The do-found can reference the
??-out through \`'#1'. The do-not-found can reference the 
old definition of \`'\hat' through \`'#1' and the foo through \`'#2'.



\SubSection{Foundation for Accents}




\<tools for accents\><<<
\NewConfigure{accent}[5]{%
   \expandafter\ifx \csname x:\string#2\endcsname\relax
      \expandafter\edef
         \csname x:\string#2\endcsname{\accent:cnt}%
      |<save old accent comamnd|>%
      |<new accent command|>%
      \Advance:\accent:cnt by 1  
   \fi
   \edef\:tempa{\csname x:\string#2\endcsname}%
   |<get accent config|>%
   }
\def\accent:cnt{0}
>>>

The \`'\csname t:\accent:cnt\endcsname' part is for the text mode,
and the \`'\csname m:\accent:cnt\endcsname' part is for math mode.


\<save old accent comamnd\><<<
\expandafter\let\csname t:\accent:cnt\endcsname|=#1%
\expandafter\let\csname m:\accent:cnt\endcsname|=#2%
>>>


\<new accent command\><<<
\edef\:temp{\ifx \accent:def\:UnDef \noexpand\def \else
     \noexpand\accent:def \fi 
   \noexpand\:temp{\noexpand\ac:pc{\accent:cnt}}%
   \noexpand\HLet\noexpand#1|=\noexpand\:temp
   |<hook accent table|>}%
\:temp
\def\:temp{#1}\def\:tempa{#2}\ifx \:temp\:tempa \else \HLet#2|=#1\fi
>>>

The search starts at \`'\ac:pc{\accent:cnt}'.
The accent table is stored in \`'\csname\accent:cnt :ac\endcsname'.
The table is searched by \''\acpc:', which puts the result in  \''\end:accent'.

\<hook accent table\><<<
\noexpand\pend:defI
  \noexpand\:accnts{\noexpand\ifnum ########1=\accent:cnt
  \noexpand\expandafter \noexpand\acpc: 
  \expandafter\noexpand\csname\accent:cnt :ac\endcsname
  \noexpand\expandafter \noexpand\end:accent \noexpand\fi}%
>>>

The pend above is just:
\`'\pend:defI\:accnts{\ifnum ########1=\accent:cnt
     \expandafter\acpc: \csname\accent:cnt :ac\endcsname
     \expandafter\end:accent\fi}'



\<get accent config\><<<
\def\:temp{#3}\ifx \:temp\empty \else
  \expandafter\def\csname \:tempa :ac\endcsname{#3}
\fi
\long\def\:temp##1##2{#4#5}\ifx \:temp\:gobbleII \else
  \expandafter\def\csname C:\:tempa\endcsname##1{#4}%
  \expandafter\def\csname MT:\:tempa\endcsname##1##2{#5}%
\fi
>>>



\''\acp:c' might go to the aux file of latex, where \`':' has standard
cat code. Hence, the protection on \''\csname' and not the command
itself (as was the case at the beginning).


\<old accents\><<<
\def\ac:pc{\Protect\csname acp:c\endcsname}
\def\acp:c#1#2{{\def\acn:no{#1}\def\:temp{#2}\ifx \:temp\empty
      |<accent on empty arg|>% 
   \else |<tabacckludge|>%
      \def\ac:pc{\ac:nt{#2}}\a:cpc{#1}\fi }}
\def\ac:nt{\csname \ifmmode m\else t\fi :\acn:no\endcsname}
>>>

\<accent on empty arg\><<<
\ac:nt{}%
>>>

\<old accents\><<<
\def\Ac:nt{\edef\:temp{\ifx \EndPicture\:UnDef  
      \def\noexpand\ac:pc{\noexpand\Protect \noexpand\acp:c}%
      \expandafter\noexpand \csname MT:\acn:no\endcsname
  \fi  
  \expandafter\noexpand
  \csname\ifmmode m\else t\fi :\acn:no\endcsname}\:temp 
}
>>>

The second line above is for nested accents in nonpictorial 
environments (e.g., \''\hat{\hat{x}}').  Otherwise, we are
getting an infinite loop because by now \''\ac:pc' has been 
modified to equal \''\Ac:nt'.


\`' \def\acp:c#1#2{{\def\:temp{#2}\def\ac:pc{\accent#1 #2}\a:cpc{#1}}}'

We can't have braces around \`'#2' in \`'\accent#1 #2' because they 
get TeX \ifHtml[\HPage{confused}\Verbatim
\Draw \Text(--Ra\'ul--) \EndDraw
\EndVerbatim\EndHPage{}]\fi{} on the exact location of the mark.


\<old accents\><<<
\def\a:cpc#1{%
  \ifx \EndPicture\:UnDef  
     \def\AC:PC{|<default accent|>%
     }%
     \:accnts{#1}\empty
  \else   \ac:pc  \fi  }
>>>


The \''\empty' is for the skiping over the leftover of the fonts, once
a font is found. It is used in \''\end:accent'.

\<tools for accents\><<<
\def\end:accent#1\empty{}
\def\:accnts#1{}
>>>







Latex has \`'\def\@tabacckludge#1{\csname #1\endcsname}'.

\<tabacckludge\><<<
\let\@tabacckludge|=\:tabacckludge
>>>

\SubSection{Getting the Html Replacement}


\<old accents\><<<
\def\acpc:#1#2{%
   \def\:tempa{#1}\ifx \:tempa\empty  
      |<char/pic accent|>%
   \else \ifx \:tempa\:temp  \let\AC:PC|=\empty  
             |<accent for table entry|>\fi
         \expandafter\acpc:
   \fi}
>>>

/:temp below is the parameter of the accent, and it can be empty
(e.g. \''\^{}').    If the parameter is empty, the accent is just a
character, given in the last parameter of \''\acpc:'. The recursive
macro  \''\acpc:' eats two parameters at  a time, and it terminates
when the first in the pair of parameters is empty.

\<char/pic accent\><<<
\ifx \:temp\empty
   \def\:tempa{#2}\ifx \:tempa\empty  \AC:PC
   \else |<accent for ?|>\fi
\else \AC:PC \fi
>>>


\<accent for ?\><<<
\csname \ifmmode m\else t\fi :\acn:no\endcsname{#2}%
>>>


\<accent for table entry\><<<
\csname C:\acn:no\endcsname{#2}%
>>>


The else \`'\csname \ifmmode m\else t\fi :\acn:no\endcsname{}' is for
the case that the parameter is empty, in which case the accent needs
to be converted into a stand alone character (e.g., \`'\={}').


Default is needed for symbols not found in initiation tables.


\<default accent\><<<
{\let\AC:PC|=\ACP:C  \let\ac:nt|=\Ac:nt \ac:pc}%
>>>             





The \`'\let\AC:PC=\ACP:C' above is for recursive cases like in
\`'$A\hat{B\hat{x}}$'.


\<config nonspecified accent\><<<
                   \def\:temp##1##2{#5#6}\ifx \:temp\:gobbleII \else
\expandafter\def\csname C:#3\endcsname##1{#5}%
\expandafter\def\csname MT:#3\endcsname##1##2{#6}%
                   \fi
>>>








\Section{End-of-Line Ch Characters}

\<html utilities\><<<
\def\Hnewline{\:newlnch}
>>>

Without the following, we get in toc things like \`'^^J' 
that don't go together with catcode 13 for \`'^'.

\<no Hnewline\><<<
\let\:newlnch|=\space
>>>


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Symbols}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Check that all the symbols belong to TeX and LaTeX


\<shared config\><<<
\def\HChar#1{{\leavevmode |%\ifmmode\else\expandafter\immediate\fi|%
\ht:special{t4ht@#1}\ifnum #1>-1 \a:HChar\fi}}
\NewConfigure{HChar}{1} 
\Configure{HChar}{x}
>>>



There is a boundary case of \''\HChar{0}' we didn't
handle above. Do we want to take care of it?


\`'\HChar{i}' inserts the character code i, with its font info, if
i is positive. If i is negative, the font info is not included.  The
first case is obtained with a special that inserts its content
directly, and the second by a special sending its content as override
on top of the next character.

The \''\Configure' tells from where the font info comes.  With the
presence of regular and pictorial symbols, we should be careful 
not to get here into a mess.

Without checking for the math mode the immediate becomes problematic in math mode (why?).

\Verbatim
\documentclass{article}  
\begin{document}  
$\_$ vs \_
\end{document}
\EndVerbatim


Same problem for tables (why?)

\Verbatim
\documentclass{article} 
\begin{document} 
\begin{tabular}{l} \_ \end{tabular} 
\end{document} 
\EndVerbatim



%%%%%%%%%%%%%%%%%%%%%%%%%
\SubSection{Symbols}
%%%%%%%%%%%%%%%%%%%%%%%%%%

% After |<dvi-based hooks|>

%   |<html math and non-math symbols|>    |%after <math>|%

% \<html math and non-math symbols\><<<
% \ifHtml
%   \let\:copyright|=\copyright
%   \def\::copyright{\gt:ch\:copyright{copy}}
%   \def\copyright{\Protect\::copyright}
%   \def\gt:ch#1#2{\ifx \EndPicture\:Undef \HCode{&#2;}\else #1\fi }
% \fi
% >>>
% 


\<shared config\><<<
\NewConfigure{@Picture}[1]{\def\a:@Picture{#1}}
\let\a:@Picture|=\:gobble
>>>





\Chapter{Dvi-Based Hooks}

\<dvi-based hooks\><<<
|<tracing dvi|>
|<sent to dvi|>
>>>



\Section{Tracing Dvi}

\<tracing dvi\><<<
\def\HTrace#1{\csname #1:T\endcsname}
\def\EndHTrace#1{\csname #1:t\endcsname}
>>>

\<tracing dvi\><<<
\def\RULE:T{\ht:special{t4ht@\%R}}  \def\RULE:t{\ht:special{t4ht@\%r}}
>>>

\<shared config\><<<
\NewConfigure{RULE}[5]{\ht:special{t4ht@\%\%R#1#2#1#3}
  \ht:special{t4ht@\%\%r#1#4#1#5}}
>>>

\<tracing dvi\><<<
\def\GROUP:T{\ht:special{t4ht@\%P}}  \def\GROUP:t{\ht:special{t4ht@\%p}}
>>>


\<shared config\><<<
\NewConfigure{GROUP}[5]{\ht:special{t4ht@\%\%P#1#2#1#3}
  \ht:special{t4ht@\%\%p#1#4#1#5}}
>>>


\<tracing dvi\><<<
\def\CHAR:T{\ht:special{t4ht@\%C}}  \def\CHAR:t{\ht:special{t4ht@\%c}}
>>>

\<shared config\><<<
\NewConfigure{CHAR}[5]{\ht:special{t4ht@\%\%C#1#2#1#3}
  \ht:special{t4ht@\%\%c#1#4#1#5}}
>>>

\<tracing dvi\><<<
\def\HSPACE:T{\ht:special{t4ht@\%H}}  \def\HSPACE:t{\ht:special{t4ht@\%h}}
>>>

\<shared config\><<<
\NewConfigure{HSPACE}[3]{\ht:special{t4ht@\%\%H#1#2#1#3}}
>>>


\<tracing dvi\><<<
\def\VSPACE:T{\ht:special{t4ht@\%V}}  \def\VSPACE:t{\ht:special{t4ht@\%v}}
>>>

\<shared config\><<<
\NewConfigure{VSPACE}[3]{\ht:special{t4ht@\%\%V#1#2#1#3}}
>>>



tex4ht.c has implicit \`'\Configure{VSPACE}{.}{}{}', etc. for the
above.


Comamnd line `-p' requests tracings of specials.  \`'\special{t4ht@/}' 
for flip-floping requests of such tracings.

The switch `-c' in the command line asks for context dump into the log
when dvi errors/ warning are provided.

\Section{Sent to Dvi}

All the control flow commads should be located within the
\`'\Send' environment.  The \`'\send:special' takes care
of killing casses not obeying this requirement.

\<sent to dvi\><<<
\def\Send#1{\Configure{Send:#1}}
\def\DviSend{\let\send:special|=\ht:special
   \ht:special{t4ht\string~}\EndPauseBACK\ht:special{t4ht\string~}%
   \ht:special{t4ht\string~}}
\def\EndDviSend{\send:special{t4ht\string~}%
   \send:special{t4ht\string~}\PauseBACK\send:special{t4ht\string~}%
   \let\send:special|=\:gobble}
\def\PauseBACK{\send:special{t4ht\string~<(}}
\def\EndPauseBACK{\send:special{t4ht\string~<)}}
\def\HideBACK{\send:special{t4ht\string~<[}}
\def\EndHideBACK{\send:special{t4ht\string~<]}}
\def\MiniBACK{\send:special{t4ht\string~<-}}
\def\EndMiniBACK{\send:special{t4ht\string~<+}}
>>>

\<shared config\><<<
\let\send:special=\:gobble
\NewConfigure{Send:GROUP}[2]{\send:special{t4ht\string~<#1#2}}
\NewConfigure{Send:EndGROUP}[2]{\send:special{t4ht\string~>#1#2}}
\NewConfigure{Send:BACK}[1]{\send:special{t4ht\string~<*#1}}
>>>



What \`'\MiniBACK...\EndMiniBACK' do here.

\`'{\special{t4ht=}}' ----forcing a group
i.e. use  \`'{\special{t4ht=}}^x'   instead of \`'{}^x'.


\Section{Observations}

\List{*}
\item \`'\HChar{...}' sends forward a character to the next printable
char (can be refined to specific characters).  That is, it uses the
character of the command, with the decoration of the character that
follows.
\item \`'\special{t4ht@+...}' sends forward a string to the next printable
chr



\item
\Verbatim
  \special{t4ht@+. ...string...} configure insertions at eoln
  \special{t4ht@+(} ignore spaces
  \special{t4ht@+)} end ignore spaces
  \special{t4ht@+[} ignore chs and spaces
  \special{t4ht@+]} end ignore chs and spaces (but not the content of some
                    of the specials)
  \special{t4ht@+!} get last  ignored space (none, if from previous lines).
\EndVerbatim


\EndList

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Chapter{Loose Ends}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%
\Section{Hyphenation}
%%%%%%%%%%%%%%%%%%

\<core tex\><<<
\def\hyphenation#1{}
>>>








%%%%%%%%%%%%%
\Section{String Encode}
%%%%%%%%%%%%%

\<html config util\><<<
\expandafter\def\csname c:string-encoder:\endcsname#1{%
   \expandafter\def\csname c:#1:\endcsname{%
      \csname #1:String\endcsname 
      \expandafter\let\csname #1:String\endcsname=\empty
      \expandafter\let\expandafter\Char:dic
                             \csname #1Char:dic\endcsname
      \cnf:transString}
   \expandafter\def\csname #1\endcsname##1##2|<par del|>{%
      \if !##1!\expandafter\gob:par
      \else
         \expandafter\ifx \csname \string##1:#1EnCoDe\endcsname\relax
            \string ##1\else
            \csname \string##1:#1EnCoDe\endcsname
         \fi
         \if !##2!\expandafter\expandafter\expandafter\gob:par
         \else
             \expandafter\expandafter\expandafter
             \expandafter\expandafter\expandafter
                    \csname #1\endcsname
         \fi
       \fi
       ##2|<par del|>%
   }
   \expandafter\def\csname #1Char:dic\endcsname##1##2{%
      \def\:temp{##1}\ifx \:temp\empty \egroup 
      \else  \egroup
          \expandafter\append:def\csname #1:String\endcsname
               {\expandafter\let
                        \csname \string##1:#1EnCoDe\endcsname=\:UnDef}%
          \expandafter\def\csname \string##1:#1EnCoDe\endcsname{##2}%
          \expandafter \cnf:transString 
      \fi
   }
}
\def\cnf:transString{\bgroup 
   \catcode`\%=12
   \catcode`\~=12
   \catcode`\$=12
   \catcode`\&=12
   \catcode`\#=12
   \catcode`\^=12
   \catcode`\_=12
   \catcode`\?=12 \Char:dic }
\def\gob:par#1|<par del|>{}
>>>


Offers applications similar to the following one.

\Verbatim
\Configure{string-encoder}{urlEncoder}

\Configure{urlEncoder}
    {!}{%21}
    {"}{%22}
    {#}{%23}
    {$}{%24}
    {%}{%25}
    {&}{%26}
    {'}{%27}
    {(}{%28}
    {)}{%29}
    {+}{%2B}
    {,}{%2C}
    {<}{%3C}
    {>}{%3E}
    { }{+}
    {}{}




   \catcode`\%=11
   \catcode`\~=11
   \catcode`\$=11
   \catcode`\&=11
   \catcode`\#=11
   \catcode`\^=11
   \catcode`\_=11
   \catcode`\ =12


\urlEncoder ! " # $ % & ' ( ) + , < > |<par del|>

\Configure{urlEncoder}{}{}

\urlEncoder ! " # $ % & ' ( ) + , < > |<par del|>
\EndVerbatim



%%%%%%%%%%%%%
\Section{Moveright}
%%%%%%%%%%%%%

\<shared config\><<<
\def\:temp{\a:moveright \o:moveright:}
\HLet\moveright|=\:temp
\NewConfigure{moveright}{1}
>>>

The \''\leavevmode' is to force paragraph break, but we might end
here with extra one because of the internal content of the 
parameter.  An \''\IgnoreIndent' after \''\par' may solve the problem
of extra paragraph breaks, but it might also have adverse effect of
loosing paragraph breaks.


\Section{Debugging Mode}


\<debug\><<<      
\:CheckOption{debug}
\if:Option |<html debug|>
\else      |<no debug|> \fi   
>>>









              






\Chapter{e tex/latex}


\Link[http://www.vms.rhbnc.ac.uk/e-TeX/v1/etex\string
  _ref.html]{}{}e-TeX\EndLink

\<e tex\><<<
\def\:temp{\o:beginL:\a:Lregion}
\HLet\beginL=\:temp
\def\:temp{\b:Lregion\o:endL:}
\HLet\endL=\:temp
\NewConfigure{Lregion}{2}
\def\:temp{\o:beginR:\a:Rregion}
\HLet\beginR=\:temp
\def\:temp{\b:Rregion\o:endR:}
\HLet\endR=\:temp
\NewConfigure{Rregion}{2}
>>>






\Chapter{Utilities}



\Section{Vertical Break Points}

La\TeX{} already has a \''\newpage'. Do we want the following to
be \''\clear:page'?

\<general utilities\><<<
\ifx \newpage\:UnDef
\def\newpage{\vfil\penalty-10000 }
\fi
>>>









\Section{Counters}

With packages like pictex around, counters become scarce resources.
Hence, their use is minimized here in favor of macros. The tradeoff
in time is minor because counters are scarcely needed in TeX4ht.


NOTE: /g:advance in wripro...?????????????????????


\<general utilities\><<<
\ifx\tmp:toks\:UnDeF    \csname newtoks\endcsname\tmp:toks\fi
\ifx\tmp:cnt\:UnDeF    \csname newcount\endcsname\tmp:cnt\fi
\def\Advance:{\ip:op\advance\:Advance}
\def\Multiply:{\ip:op\multiply\:Advance}
\def\Divide:{\ip:op\divide\:Advance}
\def\gHAdvance{\ip:op\advance\g:Advance}
\def\gHMultiply{\ip:op\multiply\g:Advance}
\def\gHDivide{\ip:op\divide\g:Advance}
>>>


psfig already has /Multiply and /Divide

When defined, \''\HAdvance' is the same as \''\Advance:'.

\<general utilities\><<<
\def\DefOp#1#2{
   \ifx #1\:UnDef  
      \expandafter \ifx  \csname #2:\endcsname\relax
            \:warning{\string\DefOp...\string{#2\string}?}%
      \else \expand:after{\let#1|=}\csname #2:\endcsname
      \fi
   \else \:warning{\string\DefOp\string#1\string{#2\string}
                 can't redefine \string#1}%
   \fi      
}
\DefOp\HAdvance{Advance}
\DefOp\HMultiply{Multiply}
\DefOp\HDivide{Divide}
>>>



\<general utilities\><<<
\def\ip:op#1#2{\let\mth:op|=#1\let\adv:c|=#2\adv:}

\def\adv:#1{\def\:var{#1}\futurelet\:temp\Advanc:}
\def\Advanc:{\ifx [\:temp \expandafter\Advanc:e
              \else \expand:after{\expandafter\adv:c\:var}\fi}
\def\Advanc:e[#1]{\expandafter\adv:c\csname
                  \expandafter\string\:var[#1]\endcsname}

\def\g:Advance#1{\bgroup \def\:temp{#1}%
                 \tmp:cnt|=#1\afterassignment\:gplus \mth:op\tmp:cnt}
\def\:gplus{\expandafter\xdef\:temp{\the\tmp:cnt}\egroup}
\def\:Advance#1{\bgroup \def\:temp{#1}%
                \tmp:cnt|=#1\afterassignment\:aplus \mth:op\tmp:cnt}
\def\:aplus{\xdef\:temp{\def\expandafter\noexpand\:temp{\the\tmp:cnt}}%
            \egroup \:temp}
>>>

\<general utilities\><<<
\def\HAssign{\:ssg\edef}
\def\gHAssign{\:ssg\xdef}

\def\:ssg#1#2{\let\d:fn|=#1\def\:var{#2}\futurelet\:temp\:Assgn}
\def\:Assgn{%
   \ifx [\:temp  
         \expandafter\d:fn\:var[##1]{%
              \noexpand\csname  \expandafter
                                  \string\:var[##1]\noexpand\endcsname}%
         \expandafter\assg:m
   \else \afterassignment\assg:v \expandafter \tmp:cnt \fi }

\def\assg:v{\expandafter\d:fn\:var{\the\tmp:cnt}}
\def\assg:m[#1]{%
   \def\:temp{\expandafter\d:fn
      \csname \expandafter\string\:var[#1]\endcsname{\the\tmp:cnt}}%
   \afterassignment\:temp  \tmp:cnt}
>>>



\Section{Pushdowns}

\SubSection{Expanded Lists}

\<utilities\><<<
\def\PushStack#1#2{%
   \ifx #1\:UnDef \global\let#1|=\empty\fi
   {\let\Picture|=\relax \xdef#1{{#2}{#1}}}}
\def\PopStack#1#2{%
   \ifx #1\empty    \:warning{empty \string\PopStack\string#1\string#2?}%
                    \global\let#2|=\empty
   \else  \def\:temp{\:recall#1#2}\expandafter\:temp#1\fi}
\def\:recall#1#2#3#4{\gdef#1{#4}\gdef#2{#3}}
>>>

\SubSection{Control Sequences}

\<utilities\><<<
\def\PushMacro#1{%
   \expandafter\ifx \csname c:\string#1\endcsname\relax
      \expandafter\gHAssign \csname c:\string#1\endcsname |= 0 
   \fi
   \HAssign\:temp |= \csname c:\string#1\endcsname
   \let\:tempa|=#1%
   \ifx \:tempa\:UnDef  \let\:tempa|=\like:unDef\fi
   \global\expandafter\let\csname \:temp\string#1\endcsname |= \:tempa
   \expandafter\gHAdvance \csname c:\string#1\endcsname |by 1 }
>>>

\<utilities\><<<
\def\PopMacro#1{%
   \expandafter\gHAdvance \csname c:\string#1\endcsname |by -1 
   \HAssign\:temp |= \csname c:\string#1\endcsname\relax
   \ifnum \:temp < 0
      \expandafter\gHAssign \csname c:\string#1\endcsname |= 0 
      \:warning{ignored \string\PopCs\string#1 on empty stack}%
   \else
      \expand:after{\let#1|=}\csname \:temp\string#1\endcsname 
      \ifx #1\like:unDef  \let#1|=\:UnDef\fi
   \fi
   }
\def\like:unDef{\:UnDef\:CS}
>>>


\<utilities\><<<
\def\PushConfigure#1{\def\cf:name{#1}\expandafter
   \expandafter\expandafter\Push:Configure\expandafter
   \meaning\csname c:#1:\endcsname|<par del|>}
\def\PopConfigure#1{\def\cf:name{#1}\expandafter
   \expandafter\expandafter\Pop:Configure\expandafter
   \meaning\csname c:#1:\endcsname|<par del|>}
\def\do:undef#1->#2|<par del|>{%
   \if :#2:\:warning{\string\PushConfigure{\cf:name}?}\fi
}
\catcode`\@=6
\catcode`\#=12
\def\Push:Configure@1|<par del|>{%
   \do:undef@1->|<par del|>%
   \do:para@1#1|<par del|>\push:config
   \do:parb@1#2|<par del|>\push:config
   \do:parc@1#3|<par del|>\push:config
   \do:pard@1#4|<par del|>\push:config
   \do:pare@1#5|<par del|>\push:config
   \do:parf@1#6|<par del|>\push:config
   \do:parg@1#7|<par del|>\push:config
   \do:parh@1#8|<par del|>\push:config
   \do:pari@1#9|<par del|>\push:config
}
\def\Pop:Configure@1|<par del|>{%
   \do:pari@1#9|<par del|>\pop:config
   \do:parh@1#8|<par del|>\pop:config
   \do:parg@1#7|<par del|>\pop:config
   \do:parf@1#6|<par del|>\pop:config
   \do:pare@1#5|<par del|>\pop:config
   \do:pard@1#4|<par del|>\pop:config
   \do:parc@1#3|<par del|>\pop:config
   \do:parb@1#2|<par del|>\pop:config
   \do:para@1#1|<par del|>\pop:config
}
\def\do:para@1#1@2|<par del|>@3{@3{a}{@2}}
\def\do:parb@1#2@2|<par del|>@3{@3{b}{@2}}
\def\do:parc@1#3@2|<par del|>@3{@3{c}{@2}}
\def\do:pard@1#4@2|<par del|>@3{@3{d}{@2}}
\def\do:pare@1#5@2|<par del|>@3{@3{e}{@2}}
\def\do:parf@1#6@2|<par del|>@3{@3{f}{@2}}
\def\do:parg@1#7@2|<par del|>@3{@3{g}{@2}}
\def\do:parh@1#8@2|<par del|>@3{@3{h}{@2}}
\def\do:pari@1#9@2|<par del|>@3{@3{i}{@2}}
\catcode`\@=11
\catcode`\#=6
\def\push:config#1#2{%
   \if :#2:\else
      \expandafter\expandafter\expandafter\ifx \expandafter
              \csname \csname#1New:Conf\endcsname\cf:name\endcsname\relax
         \:warning{\string\PushConfigure{\cf:name} Failed}%
      \else
         \expandafter\expandafter\expandafter\PushMacro \expandafter
             \csname \csname#1New:Conf\endcsname\cf:name\endcsname
      \fi
   \fi }
\def\pop:config#1#2{%
   \if :#2:\else
      \expandafter\expandafter\expandafter\ifx \expandafter
           \csname \csname#1New:Conf\endcsname\cf:name\endcsname\relax \else
         \expandafter\expandafter\expandafter\PopMacro \expandafter
             \csname \csname#1New:Conf\endcsname\cf:name\endcsname
      \fi
   \fi }
>>>


\Section{Catergory Codes}

We need category code 12, and not 11, because the latter
choise would cause control sequences of unbounded length within
the option \`'\Verbatim-'.

\<general utilities\><<<
\def\no:catcodes#1#2#3{%
   \tmp:cnt|=#1
   \def\no::catcodes{%
      \catcode\tmp:cnt|=#3
      \ifnum\tmp:cnt<#2
          \advance\tmp:cnt |by 1  \expandafter\no::catcodes
      \fi }%
   \no::catcodes }
>>>


\Section{/pend:def and /append:def}

The \''\long' below is to allow \''\par' in the second argument.

\<early utilities\><<<
\long\def\append:def#1#2{%
   \long\def\:temp{\long\def#1}%
   \expandafter\expandafter\expandafter\:temp\expandafter{#1#2}}
\long\def\pend:def#1#2{%
   \long\def\:temp{#2}%
   \long\def\:tempa{\long\def#1}%
   \expandafter\expandafter\expandafter\expandafter
       \expandafter\expandafter\expandafter\:tempa
   \expandafter\expandafter\expandafter{\expandafter\:temp #1}}
\long\def\pend:defI#1#2{%
   \long\def\:tempa{\long\def#1####1}%
   \ex:pend{#2}{\expandafter\:temp #1{##1}}}
\long\def\ex:pend#1{\long\def\:temp{#1}%
  \expandafter\expandafter\expandafter\expandafter
       \expandafter\expandafter\expandafter\:tempa
   \expandafter\expandafter\expandafter}
>>>

\<early utilities\><<<
\long\def\append:defI#1#2{%
   \long\def\:temp{\long\def#1####1}%
   \expandafter\expandafter\expandafter\:temp\expandafter{#1{##1}#2}}   
\long\def\pend:defII#1#2{%
   \long\def\:tempa{\long\def#1####1####2}%
   \ex:pend{#2}{\expandafter\:temp #1{##1}{##2}}}
\long\def\append:defII#1#2{%
   \long\def\:temp{\long\def#1####1####2}%
   \expandafter\expandafter\expandafter\:temp\expandafter{#1{##1}{##2}#2}}
\long\def\pend:defIII#1#2{%
   \long\def\:tempa{\long\def#1####1####2####3}%
   \ex:pend{#2}{\expandafter\:temp #1{##1}{##2}{##3}}}
\long\def\append:defIII#1#2{%
   \long\def\:temp{\long\def#1####1####2####3}%
   \expandafter\expandafter\expandafter
      \:temp\expandafter{#1{##1}{##2}{##3}#2}}
>>>

\SubSection{/Odef}

\<general utilities\><<<
\HAssign\def:cnt=0
\def\Odef#1{\gHAdvance\def:cnt |by 1
   \edef#1{\noexpand\with:op
             \expandafter\noexpand\csname \def:cnt \string#1\endcsname }%
  \expandafter\gdef\csname\def:cnt\string#1\endcsname}
\def\with:op#1{\let\n:xt|=#1\futurelet\:temp\wth:opt}
\def\wth:opt{\ifx [\:temp
   \expandafter\n:xt\else \expand:after{\n:xt[]}\fi}
>>>

The
\`'  \expandafter\gdef\csname\def:cnt\string#1\endcsname}'
allo \`'\global\let#1=#1'.





\Section{/Needs}

\<general utilities\><<<
\def\Log:Needs#1{{\escapechar=`\\\immediate\write-1{\:Neds{#1}}}}
>>>

\<html config util\><<<
\def\c:Needs:{\def\:Needs##1}
\expandafter\def\csname c:Needs-:\endcsname{\def\:Neds##1}
>>>





Put the following in a group so that the temporary variables
will not interfere with other usages.

\<html utilities\><<<
\def\Needs{\bgroup\catcode`\"=12 \cat:Needs}
\def\cat:Needs#1{\def\:temp{-}\def\:tempa{#1}\ifx \:temp\:tempa
   \aftergroup\Log:Needs \else \ht:special{t4ht+@\:Needs{#1}}\fi
   \egroup}
>>>





\Section{/HCommand and /LinkCommand}






The following is introduced at the end of the style file, to
allow for \''\Contribute{name}{...}' commands that check 
for the legality of \`'name'. Otherwise, it
is identical to the above.




\`'\LinkCommand\Frame{FRAME,SRC,ID}
\Frame{a}{A}...\EndFrame
\LinkCommand\FRAME{FRAME,SRC,ID,attr}
\LinkCommand\FRAME{FRAME,SRC,ID,attr,/,sharp}
\FRAME{a}{A}
\FRAME[b 1]{c}{d}'




\<html utilities\><<<
\def\LinkCommand#1#2{\L:Com#1#2,,,,,,|<par del|>{#1}}
\let\:Link|=\Link
\def\L:Com#1#2,#3,#4,#5,#6,#7,#8|<par del|>#9{\def\:tempe{#7}%
   \def\:tempa{#2}\def\:tempb{#3}\def\:tempc{#4}\def\:tempd{#6}%
   \expandafter\edef\csname
           End\expandafter\:gobble\string #9\endcsname{%
      \ifx\:tempd\empty \noexpand\HCode
         {\Hbrakets</\ifx\:tempa\empty \tag:A\else#2\fi>}\fi }%
   \edef\:temp{%
      \noexpand\Odef\noexpand#1[####1]####2####3{{%
         \def\noexpand\tag:A{\ifx\:tempa\empty\tag:A\else#2\fi}%
         \def\noexpand\HREF:{ \ifx\:tempb\empty\HREF:\else#3=\fi}%
         \def\noexpand\NAME:{ \ifx\:tempc\empty\NAME:\else#4=\fi}%
         \def\noexpand\empty:lnk{\ifx\:tempd\empty\else#6\fi}%
         \def\noexpand\:sharp{\ifx\:tempe\empty\:sharp\else#7\fi}%
         \noexpand\M:link[####1 #5]{####2}{####3}}}}\:temp
   |<add - opt to command|>%
  }
>>>


\<add - opt to command\><<<
\expandafter\let\csname \string#1 :\endcsname|=#1
\def#1{\bgroup\LD:Link{#1}\futurelet#1\M:link}
>>>

\<html utilities\><<<
\def\LD:Link#1{%
   \def\M:link{\ifx -#1\egroup \def\M:link{\:Link-}\expandafter\gob:lnk
               \else   \egroup \let\M:link|=\:Link \fi
     \csname \string#1 :\endcsname }}
\def\gob:lnk#1-{#1}
>>>

\<html Configure's\><<<
\NewConfigure{Link}[4]{%
   \def\empty:lnk{#4}\ifx\empty:lnk\empty\else \def\:sharp{#4}\fi
   \let\empty:lnk|=\empty     \def\tag:A{#1}%
   \def\HREF:{#2}\def\NAME:{#3}}
\Configure{Link}{}{}{}{}
\let\NOHREF:|=\:gobble
>>>



The \`'\let\:Link|=\Link' is to allow for the redefinition of 
\`'\Link' and hadling -. An \`'\if !#4!\else'  will not work
for the case that \''\empty' is given to \''#4'.


% \`+\Attribute\onSelect{onSelect="loc='#1'"}
% \HCommand\Option{OPTION,\onSelect}+
% 
% \<html utilities\><<<
% \def\Attribute#1{%
%    \def#1{\expandafter\noexpand\csname\string#1\endcsname}%
%    \expandafter\def\csname\string#1\endcsname="##1"}
% >>>




\Section{Loose Ends}



\<general utilities\><<<
\def\g:delete#1{%
   \expandafter\expandafter\expandafter\global
      \expandafter\let\csname #1\endcsname|=\:UnDef
}
\def\xdef:cs#1{\expandafter\xdef \csname #1\endcsname}%
\def\:csname{\expandafter\noexpand\csname}
>>>


\<general utilities\><<<
\long\def\:gobble#1{}
\long\def\:gobbleII#1#2{}
\long\def\:gobbleIII#1#2#3{}
\long\def\:gobbleIV#1#2#3#4{}
\long\def\:gobbleV#1#2#3#4#5{}
\long\def\:gobbleVI#1#2#3#4#5#6{}
\long\def\:gobbleVIII#1#2#3#4#5#6#7#8{}
>>>











\ifHtml[\HPage{more}\Verbatim
change CutAt{a,b} to CutAt{a,/b} and add exercises here.
\EndVerbatim\EndHPage{}]\fi


\ifHtml[\HPage{more}\Verbatim

In TeX4ht, \''\begin{...}' and \''\end{...}' are redefined
to \''\SaveEverypar\begin{...}' and \''\end{...}\RecallEverypar' 
so it is pointless to directly deal with paragraph breaks 
and saving.  Since the saving and recalling are global
operations (in a pushdown fashion), the following
redefine the saved environment to eliminate 
paragraph breaks after the environment.


WE HAVE here a problem if someone goes directly, e.g., for
\''\quotation...\endquotation' instead of 
\''\begin{quotation}...\end{quotation}'. On the other hand, 
LaTeX doesn't mention the first case as an option.
\EndVerbatim\EndHPage{}]\fi



\<html utilities\><<<
\ifx\tmp:dim\:UnDeF    \csname newdimen\endcsname\tmp:dim\fi
>>>




\SubSection{Protection}

Fonts in sectioning titles can be a problem, when delivered to tocs. Hence,
we need to protect them from early expansions.

Without the space, we can have  in toc file expanded control
sequences  (e.g., \`'\protect\tt x' becomming \''\ttx').

The following is for preveting expansions in edef environments while
preserving the meaning within standard environments. We need it, in
particular, for writing into toc and for (i.e., HPage?) CutAt when
titles of sections are referenced.

\<html utilities\><<<
\def\pr:tc{\relax}
\let\prOteCt|=\relax
\def\Protect{%
   \let\prOteCt|=\pr:tc
   \ifx \prOteCt\pr:tc    \let\prOteCt|=\relax
   \else \noexpand\Protect\expandafter\noexpand\fi
}
>>>

LaTeX has \`'\def\@unexpandable@protect{\noexpand\protect\noexpand}' to be included in  immediate defines.


\Section{Tags}

\SubSection{Html}


The following create \`'<A HREF="aav.\:html#Q1-5-1"
NAME="Q2-5-1">.........</A>' in the table of contents and 
\`'<A HREF="a.\:html#Q2-5-1" NAME="Q1-5-1">..........</A>' in the
title. The address \`'Qi-j-m' tells that we deal with tag of type
\`'Qi', in file \`'j', for title \`'m' in the file. 



\<toc tag\><<<
Q>>>


The prefix \`'\<toc tag\>' is required for distinguishing the tocs tags
from other tags to allow for selective loading of cross references
when communicating toc info.





\<csname: file name -> file id\><<<
 FN >>>




\SubSection{Standard}


\FreeCode\<tag of Tag\>  % to avoid duplication

\<tag of Tag\><<<
 cw:>>>









\<File tag\><<<
(L >>>




\<next HPage tag\><<<
|<auto tag|>N >>>



\<bib tag\><<<
|<auto tag|>B >>>



\SubSection{Internal}

\<tag MarkCurFile\><<<
cf: >>>






\Chapter{wripro.tex: HTML Stuff Shared by  TeX4ht and AlProTex}



TeX4ht writes its tags into \`+.ref+ files until ProTex takes over
and gets the tags into \`+.xref+ files.  




\<check that TeX4ht is not loaded after protex\><<<
\def\:warning#1{\writesixteen{l.\the\inputlineno\space
            --- TeX4ht warning --- #1 ---}}
\ifx \:ShowCode\:UnDeF \else 
   \:warning{|<TeX4ht name|>.sty loaded after ProTeX?}
\fi
>>>



\`'\NewHaddr' provides an address that encodes a location
together with its file name.

Is the followint true? We can have for hadresses 
\`'\Link{Haddr}{}    \Link{}{Haddr}' without worrying about
extracting the file names as long as we use HAddress we get from 
\`'\NewHaddr'!!! That is, in \`'\Link'the [] option is needed
just for external files compiled separately. WELL, it seems to be true
for any tags because they are resolved indirectly through thr REF
file!!!! Great , how could I have forgotten about this pearl?


AlProTex used something like the following.
Create saving at direct programming of HREF and HTAG in \`'<A>' coomands, because we don't need now Ref/Tag intermediates.

\<html utilities\><<<
\def\NewHaddr#1{\html:addr \let#1|=\last:haddr}
\def\GetHref#1{\expandafter\get:href#1-}
\def\GetHname#1{\expandafter\get:htag#1-}
\ifx \make:addr\:UnDeF
   \def\make:addr#1{|<tail for file name|>#1} \fi
>>>

\`'make:addr' may already be defined from AlProTex. It had\''\space' after \`'#1' that has been removed (see AlProTex).


\<html utilities\><<<
\def\FileNumber{\file:id}
\def\c:XrefFile:#1{\def\aXrefFile{#1}}
>>>


\openin15= wripro.tex
\ifeof15 \closein15 
   \writesixteen{*********************************}
   \writesixteen{* - error - missing wripro.tex  *}
   \writesixteen{*********************************}
\else \closein15 \input wripro.tex \fi

\<warnings for missing /Link\><<<
\ifx \:::HRefTag\:UnDef\else
  \pend:defII\:::HRefTag{%
    \if \relax##1\relax\else
      \expandafter\ifx\csname cw:)Q\aXrefFile ##1\endcsname\relax
         \:warning{\string\Link{##1}?}\csname a:?Link\endcsname 
    \fi\fi }
\fi
>>>

\<cross references\><<<
\NewConfigure{?Link}{1}
>>>


\Chapter{Background Material}
\Link[http://www.diku.dk/students/turtle/trick.html]{}{}Tricks for TeX
and LaTeX\EndLink{} (Collected by Peter M\o{}ller Neergaard)



%------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\<TeX4ht name\><<<
tex4ht>>>




%-------------------------------------------------------
\openin15= wripro.tex
\ifeof15 \closein15 
   \writesixteen{***********************************}
   \writesixteen{* -- error -- missing wripro.tex -*}
   \writesixteen{* Making a broken tex4ht.sty file.*}
   \writesixteen{* Don't use this tex4ht.sty file! *}
   \writesixteen{***********************************}
\else \closein15  \fi
%-------------------------------------------------------

\OutputCode\<tex4ht\>


\bye
