% $Id: tex4ht-sty.tex 1556 2024-09-23 10:50:11Z michal_h21 $ % tex tex4ht-sty or ht tex tex4ht-sty % % Copyright 2009-2022 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 (sty)------------} \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{}} %% \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{

A Literate View of tex4ht.sty

} \csname TableOfContents\endcsname[ParentOf,Part,Chapter,% Appendix,LikeChapter,Section,LikeSection] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \Chapter{Outline of the Code} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \Section{TeX4ht} \<<< \ifnum\the\catcode`\%=14\else\expandafter\edef\csname \string:RestoreCatcodes\endcsname{\catcode`\%|=\the \catcode`\%}\catcode`\%|=14\fi | \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 % we used to disable new LaTeX's tagging support, % because it clashed with TeX4ht and caused fatal errors % we fixed the fatal errors, so it should be possible to % fix other issues as well. The upside will be that we % should be able to coordinate the projects and reuse some code. % https://github.com/michal-h21/make4ht/issues/145 % \ifdefined\DocumentMetadata % \def\DocumentMetadata#1{\def\:DocumentMetadata{#1}} % \fi \def\writesixteen#1{\immediate\write99999{#1}} | | | \ifx \Preamble\UnDef \ifx \PLATFORM\:UnDef \else \message{ [\PLATFORM] }\let\PLATFORM|=\:UnDef\fi | | | \expandafter\ifx \csname tex4ht\endcsname\relax \let\:temp|=\empty \else | \fi \let\:tempc|=\:temp | \pend:def\:tempc{\:RestoreCatcodes } \append:def\:tempc{\endinput} \let\:temp|=\:tempc \expandafter\:temp \fi | \ifx \Hinput\:UnDef \else \Hinput{tex4ht2} | \fi | | \rmv:ifs \let\rmv:ifs|=\:UnDef \:RestoreCatcodes \TeXivht \endinput >>> \<<< \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 \<<< \def\HLet#1{% \expandafter\ifx \csname o:\expandafter\:gobble\string#1:\endcsname\relax |% \fi |% \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'. \<<< \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. \<<< \expandafter\let \csname o:\expandafter\:gobble\string#1:\endcsname|=#1% >>> \<<< \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} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \<<< \NewConfigure{ProTex}[1]{\def\a:ProTex{#1}} >>> \<<< \ifx \a:ProTex\:UnDef \else \input ProTex.4ht \fi >>> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \Section{Support for httex} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \<<< | | \expandafter\expandafter\expandafter \:temp\csname tex4ht\endcsname |% \ifx \:temp\relax | \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 >>> \<<< \ifx \:temp\relax \let\:tempd|=\:temp \let\:tempc|=\empty \config:opt #1,#2,|% \else \:temp \let\:tempd|=\:temp \let\:tempc|=\empty \config:opt #2,|% \fi \let\config:opt|=\:tempc \let\:temp|=\:tempd >>> \<<< \def\:tempc#1#2.#3|{\edef\:tempa{#3}\edef\:temp{% #1\ifx \:tempa\empty .cfg\fi}} \def\config:opt#1,#2|{\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|}\fi \:temp} >>> \<<< \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} \<<< \ifx \Log:Needs\:UnDef \else \:warning{Again `\noexpand\input tex4ht.sty'?}\fi | |%still necessary?|% | | >>> \<<< \expandafter\ifx \csname @latex@error\endcsname\relax \:latexfalse \tracingstats|=1 \else \if:latex\else |\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} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \<<< \def\:Preamble{\ifx \:next[% \def\Preamble[##1]##2{\egroup |\input ##1 } \else \def\Preamble##1{\egroup |% \input |.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. \<<< |% \ifHtml \Htmlfalse \def\Preamble{html,##1}\else \def\Preamble{##1}\fi |% |% >>> \<<< |% \ifHtml \Htmlfalse \def\Preamble{html,##2}\else \def\Preamble{##2}\fi |% |% >>> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \SubSection{End Preamble} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \<<< \def\EndPreamble{\b:Preamble \global\let\missing:endpream\empty \csname |\file:id\endcsname \B:DY} \def\B:DY{|% \HtmlEnv \IgnorePar \IgnoreIndent {\ht:everypar{}\leavevmode}\a:BODY \csname a:@BODY\endcsname} \def\missing:endpream{\:warning{Missing \string\EndPreamble}} >>> \<<< \missing:endpream >>> \<<< \NewConfigure{@HTML}[1]{\concat:config\a:@HTML{#1}} \let\a:@HTML|=\empty >>> \<<< \:tempb >>> \<<< \NewConfigure{Preamble}{2} >>> \<<< \ifHtml \else \let\EndPreamble|=\empty \fi >>> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \SubSection{Selecting Preamble} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \<<< \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 } >>> \<<< \def\:temp{\def\ifOption##1} \expandafter\expandafter\expandafter\:temp \expandafter{\Preamble,,//\if:Option |\else |\fi \tmp:toks=} \pend:defI\ifOption{\def\:temp{##1}\:Optionfalse\:ScanOptions} >>> \<<< \def\:temp{% \def\:temp{\the\tmp:toks}% \afterassignment\:temp \tmp:toks=}% \afterassignment\:temp >>> \<<< \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'. \<<< \: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. \<<< \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 |\else |\fi \tmp:toks=} \pend:defI\ifOption{\def\:temp{##1}\:Optionfalse\:ScanOptions} \fi >>> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \Section{LaTeX at First Pass} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \<<< \if:latex | | \fi | | | >>> The following is a temporary patch, waiting fo a fix in hyperref.sty. \<<< \expandafter\def\csname opt@hyperref.sty\endcsname{tex4ht} >>> \<<< \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}' \<<< \ifx\XeTeXversion\@undefined\else \ifx\xeuniuseblock\@undefined \input tuenc-xetex-input.4ht \fi\fi >>> Add support for package commands redefining \<<< \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} >>> \<<< \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 |\a:usepackage% \a:usepackage:lthooks{#1}{#4} |}% \def\:currentoptions{#2} \:onefilewithoptions#1[#2][#3]{#4}\package:hooks{#1.#4}} \def\a:usepackage{\input usepackage.4ht } >>> \<<< \edef\TivhTcats{% \catcode`:=\the\catcode`:% \catcode`@=\the\catcode`@}% \catcode`\:=11 \catcode`\@=11 >>> \<<< \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 \<<< \Configure{PackageHooks}{packagename.sty}{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 \<<< \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). \<<< | |%should be first|% | | | \ifHtml | \Hinput{Preamble} \ht:special{t4ht.\:html} | | \Hinput{tex4ht} | \fi | | | | | | \ifHtml | \fi | | | | | | |%after Preamble|% \ifHtml | | \fi | |% after accents, {\vrb:tt\`} in particular|% \ifx\beginL\@undefined \else \ifHtml | \Hinput{etex4ht} \fi\fi | | | \ifHtml | \fi |%should be last|% >>> \Section{Copyright Note} \input tex4ht-cpright.tex \<<< % tex4ht.sty (|version), generated from |jobname.tex % Copyright 2009-|the|year|empty TeX Users Group % Copyright |CopyYear.1996. Eitan M. Gurari | >>> \Section{Category 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 |% \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 | \catcode`\^|=7 \catcode`\||=12 \catcode`"|=12 >>> \Section{Ifs} \<<< \def\:temp{\csname newif\endcsname} \def\:tempa#1{% \expandafter\ifx \csname #1\endcsname\relax \expandafter\:temp \csname #1\endcsname \fi} | \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 | >>> The temporary ifs are needed only for loading time to allow TeX to scan material that will not be loaded. \<<< \:tempa{if:latex} >>> \Section{User File Requests} \<<< \def\:usersty#1,#2|{\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,|\fi \let\noexpand\TeXivht|=\noexpand\:UnDef \let\noexpand\:usersty|=\noexpand\:UnDef } >>> \Section{Usepackage Interface for LaTeX} \<<< \ifx \@currname\empty | \else | \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. \<<< \ProvidesPackage{tex4ht} \let\config:file|=\empty | \DeclareOption*{\load:cfg} \ProcessOptions \let\o:document|=\document \def\document{% |% \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 |% \let\document\o:document% \fi% \let\:latex@error|=\@latex@error \def\@latex@error##1{\:latex@error{##1 in `\config:file'}}% |% \let\@latex@error|=\:latex@error } >>> \<<< \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 >>> \<<< |% \ifx \config:file\empty \def\:temp{|}% \else \def\:temp{|}% \fi \:temp >>> \<<< | \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}{}{} >>> \<<< \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. \<<< \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'. \<<< \ifx \config:opt\:UnDef \edef\config:opt{\ifx \config:file\empty html\fi}\fi \expandafter\Preamble\expandafter{\config:opt }\EndPreamble >>> \<<< \input \config:file\relax >>> \<<< \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,|% >>> The following removes duplications in \''\Preamble'. Important, in particular, when 4ht configuration files are included in the list of options. \<<< \def\set:Preamble#1,#2|{% \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|}\fi } >>> \''\ProcessOptions' calls \''\cfg:fl' repeatedly for each option. \List{} \item{Empty, or Cfg File} \<<< \def\load:cfg{|<2nd option|>% \def\:temp{\expandafter\cfg:fl\CurrentOption.|}% \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|{\edef\:tempa{#2}\edef\config:file{% \CurrentOption \ifx \:tempa\empty .cfg\fi}} >>> \<<< \def\:temp#1,#2|{% \def\:temp{\:tempc{#1}#1.|}% \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 |% } >>> \item{First Option for /Preamble} \<2nd option\><<< \def\load:cfg{\let\config:opt|=\CurrentOption |}% >>> \item{Non-First Option for /Preamble} \<<< \def\load:cfg{\edef\config:opt{\config:opt,\CurrentOption}}% >>> \EndList \def\gt:laopt#1,#2|{\def\:temp{#1}\ifx \:temp\empty \else \cfg:fl#1.|\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. \<<< \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} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \<<< \csname newskip\endcsname\tmp:dim >>> \<<< | | >>> \<<< | \ifHtml | \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. \<<< \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'. \<<< \def\:temp####1.4ht####2|{\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|% \expandafter\xtrct:hin\Preamble,,|% |% >>> \<<< \def\xtrct:hin#1,{\def\:temp{#1}\ifx \:temp\empty \def\xtrct:hin##1|{\let\xtrct:hin|=\:UnDef}\else \def\:tempa##1.4ht##2|{% \def\:temp{\Hinclude[*]{##1.4ht}}\def\:tempa{##2}}% \expandafter\:tempa\:temp .4ht|% \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. \<<< \:Hinclude >>> \<<< \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? \<<< \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 |\:Hinput}\fi} >>> \<<< \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 } >>> \<<< \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 >>> \<<< \catcode`\#=12 \def\#{#} \catcode`\#=6 >>> The starred command is for immediate expansion Can we avoid the following file? \<<< \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} >>> \<<< \def\if:notempty#1#2{% \def\:temp{#1}\ifx \:temp\empty \else \expand:after{#2}\fi } >>> \Chapter{Configurations} \Section{Contributes} \<<< \long\def\Contribute#1#2{% \expandafter\ifx \csname :#1:\endcsname\relax \:warning{\string\Contribute{#1}?}\fi \long\expandafter\def\csname :#1:\endcsname{#2}} >>> \<<< \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#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\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{|}\:temp } \def\N:wCnfgb#1#2{% \edef\:temp{|{\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\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\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}} | >>> After each loading of the vertical 4ht files, the coefficients of newconfigure assume their initial definitions. \<<< \Configure{NewConfigure}{a:}{b:}{c:}{d:}{e:}{f:}{g:}{h:}{i:}% >>> \Section{Tracing Configurations} See also LaTeX part \<<< \:CheckOption{hooks++} \if:Option | \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 | \let\edit:p|=\empty \fi \fi \if:Option | \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 | \fi >>> \<<< \pend:defI\Configure{\tmp:cnt|=0 \long\def\c:def####1####2{\advance\tmp:cnt |by1 | \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 }} >>> \<<< \pend:defI\Configure{\tmp:cnt|=0 \long\def\c:def####1####2{\advance\tmp:cnt |by1 | \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 }} >>> \<<< \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} >>> \<<< \edef\:tempb{\expandafter \meaning\csname c:##1:\endcsname}% \expandafter\par:N \:tempb////% >>> \Section{Editing and Xml} Note that \`'edit' is not the option \`'tty'! \<<< \def\Tg<#1>{% \expandafter\ifx \csname\try:tagend <#1\endcsname\is:empty \:tagend#1|\else \expandafter\ifx \csname\try:tagempty #1>/>|\endcsname\is:empty \:tag{#1}\else \:tagempty #1>\fi\fi} \def\try:tagend#1{#1is:empty} \def\try:tagempty#1/>#2|{#2is:empty} \def\is:empty{\empty\empty} \:CheckOption{edit} \if:Option | | \else | \:CheckOption{verify}\if:Option\else \:CheckOption{verify+}\fi \if:Option | \else | \fi \fi >>> The \''\tg' is also part of mex. \<<< % \def\tg<#1>{\c:edit#1\d:edit} \def\TG<#1>{\a:edit#1\b:edit} >>> \<<< % \def\tg<#1>{<#1>} \def\TG<#1>{\HCode{<#1>}} >>> The \`'edit+' is a pseudo-browser mode showing a possible view of the code. \<<< \def\:tag#1{\hbox{\HCode{<#1>}}} \def\:tagend#1#2|{\hbox{\HCode{}}} \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 \''>'. \<<< \def\tag:of#1 #2|{#1} \def\pl:s{+} \def\:tag#1{\VerifyOpen{#1}\expandafter\ifx \csname A:\tag:of#1 |\endcsname\pl:s\else \hbox{\a:edit\HCode{#1}\b:edit}% \fi \csname B:\tag:of#1 |\endcsname } \def\:tagend#1#2|{\VerifyClose{#2}\expandafter\ifx \csname A:/\tag:of#2 |\endcsname\pl:s\else \hbox{\a:edit\HCode{/#2}\b:edit}% \fi \csname B:/\tag:of#2 |\endcsname } \def\:tagempty#1/>{\VerifyEmpty{#1}\expandafter\ifx \csname A:\tag:of#1 |/\endcsname\pl:s\else \hbox{\a:edit\HCode{#1/}\b:edit}% \fi \csname B:\tag:of#1 |/\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{<}} {\HCode{>}} >>> \<<< \def\tag:of#1 #2|{#1} \def\:tag#1{\csname A:\tag:of#1 |\endcsname \VerifyOpen{#1}\a:edit\HCode{#1}\b:edit \csname B:\tag:of#1 |\endcsname } \def\:tagend#1#2|{\csname A:/\tag:of#2 |\endcsname \VerifyClose{#2}\a:edit\HCode{/#2}\b:edit \csname B:/\tag:of#2 |\endcsname } \def\:tagempty#1/>{\csname A:\tag:of#1 |/\endcsname \VerifyEmpty{#1}\a:edit\HCode{#1/}\b:edit \csname B:\tag:of#1 |/\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{<}}{\HCode{>}} {<}{>} >>> \<<< \def\:tag#1{\VerifyOpen{#1}\hbox{\HCode{<#1>}}} \def\:tagend#1#2|{\VerifyClose{#2}\hbox{\HCode{}}} \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. \<<< \def\tag:of#1 #2|{#1} \def\mn:s{-} \def\:tag#1{\VerifyOpen{#1}\expandafter\ifx \csname A:\tag:of#1 |\endcsname\mn:s\else \csname A:\tag:of#1 |\endcsname \hbox{\a:edit\HCode{#1}\b:edit}% \fi \csname B:\tag:of#1 |\endcsname } \def\:tagend#1#2|{\VerifyClose{#2}\expandafter\ifx \csname A:/\tag:of#2 |\endcsname\mn:s\else \csname A:/\tag:of#2 |\endcsname \hbox{\a:edit\HCode{/#2}\b:edit}% \fi \csname B:/\tag:of#2 |\endcsname } \def\:tagempty#1/>{\VerifyEmpty{#1}\expandafter\ifx \csname A:\tag:of#1 |/\endcsname\mn:s\else \csname A:\tag:of#1 |/\endcsname \hbox{\a:edit\HCode{#1/}\b:edit}% \fi \csname B:\tag:of#1 |/\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} \<<< \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{}} \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} \<<< \:CheckOption{verify} \if:Option | \else \:CheckOption{verify+} \if:Option | \fi \fi \if:Option | \else \let\VerifyOpen|=\:gobble \let\VerifyClose|=\:gobble \let\VerifyEmpty|=\:gobble \long\def\Verify#1\EndVerify{} \def\trace:chk#1 #2|{} \fi >>> \<<< \let\:chk:trc|=\:gobble >>> \<<< \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. \<<< \HAssign\:ChkLevel|=0 \let\:CurrentChk|=\empty \PushStack\:CHK\empty \def\VerifyOpen#1{\Protect\trace:chk#1 |} \def\trace:chk#1 #2|{% \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 |} \def\trace:endchk#1 #2|{% \:chk:trc{Close......#1}% \expandafter\ifx \csname #1Level:\endcsname\relax \writesixteen{\the\inputlineno. --- warning --- 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 --- instead of }% \fi \fi } \def\VerifyEmpty#1{\Protect\trace:emptychk#1 |} \def\trace:emptychk#1 #2|{% \: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. \<<< \def\:tempa#1#2#3#4|{#1#2#3} \:CheckOption{htm} \if:Option \edef\:html{\expandafter\:tempa\:html\empty\empty|} | \else \:CheckOption{htm5} \if:Option \edef\:html{\expandafter\:tempa\:html\empty\empty|} | \else \:CheckOption{htm4} \if:Option \edef\:html{\expandafter\:tempa\:html\empty\empty|} | \else \:CheckOption{htm3} \if:Option \edef\:html{\expandafter\:tempa\:html\empty\empty|} | \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} |% | | | \fi >>> \<<< \NewConfigure{ext}[1]{% \def\:temp##1ext=##2,##3|{% \if !##2!\edef\:html{#1}% \else \edef\:html{##2}\fi}% \expandafter\:temp\Preamble ,ext=,| } \Configure{ext}{html} >>> \<<< \def\:temp#1#2#3|{\def\j:bname{#1\ifx ?#2\else #2\fi}} \expandafter\:temp \jobname ?| >>> \<<< \def\:temp#1#2#3#4|{\def\j:bname{#1\ifx ?#2\else #2\ifx ?#3\else #3\fi\fi}} \expandafter\:temp \jobname ??| >>> \<<< \def\:temp#1#2#3#4#5|{\def\j:bname{#1\ifx ?#2\else #2\ifx ?#3\else #3\ifx ?#4\else #4\fi\fi\fi}} \expandafter\:temp \jobname ???| >>> \<<< \def\:temp#1#2#3#4#5#6|{\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 ????| >>> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \Section{\TeX{} Parameters} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \`'\html:rightskip' is already defined in AlProTex, but we need it early here. \<<< \def\html:rightskip{\rightskip|=\z@ plus 0.5\hsize minus0.5\hsize } \def\HtmlEnv{% \html:rightskip |% \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. \<<< \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. \<<< \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. \<<< | \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}} >>> \<<< \edef\NoHtmlEnv{\NoHtmlEnv}% \append:def\NoHtmlEnv{\SUBOff \SUPOff}\HtmlEnv >>> \<<< \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. \<<< \let\skip:Par|=\empty >>> \<<< \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 }}% >>> \<<< \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 >>> \<<< \:tempa{if:removeindent} \:tempa{if:nopar} >>> \<<< \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!!!!! \<<< \NewConfigure{HtmlPar*}[2]{% \def\:temp{#2}\ifx \:temp\empty \c:def\skip:Par{#1}\else \c:def\skip:Par{#1\Next:EndP{#2}}\fi} >>> \<<< \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} >>> \<<< \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. \<<< \Configure{HtmlPar}{\sva:Par}{\svhtml:par} {}{} >>> \<<< \Configure{HtmlPar}{}{}{}{}% >>> \<<< \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. \<<< | \ifHtml | \fi >>> \Section{The Commands} \SubSection{Ref} The implementations of \''\XRef' and \''\Tag' view the crosswords $\alpha$ as pointers to macros that carry the names `\''\cw:'$\alpha$'. \<<< \def\XRef#1{\expandafter\ifx \csname |#1\endcsname \relax \:NoTag{#1}% \else \csname |#1\endcsname \fi} >>> \<<< \def\ifTag#1#2#3{\expandafter\ifx \csname |#1\endcsname \relax #3\else #2\fi} >>> \SubSection{LikeRef} The \`'\:LikeRef' command is a stripped down version of \`'\XRef'; it doesn't check whether the tag is defined. The space in \`'\space' is needed for carrying MAME tags in (mosaic) html files. \<<< \def\LikeRef#1{\expandafter\ifx \csname |#1\endcsname \relax \space% \else \csname |#1\endcsname \fi} \def\:LikeRef#1{\csname |#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$\''}'. \<<< \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. \<<< \def\:writeref{\write\:refout}% >>> \<<< \catcode`\%|=12 \def\prcnt:ch{%} \catcode`\%|=14 >>> I don't know what this code is supposed to do, but it can produce fatal errors when \''\%' is used inside of title, captions or sections. See \Link[https://tex.stackexchange.com/q/652848/2891]{}{} this question on TeX.sx for an example\EndLink. But when I remove it, the compilation process of TeX4ht sources fails, so we will need to revert to the original version of the percent command probably in latex.4ht. \<<< \catcode`\%|=12 \def\%{%} \catcode`\%|=14 >>> \Section{Internal References} \SubSection{Loading} \<<< \def\load:ref#1{% |% \get:input{#1}% \re:call \let\:CrossWord|=\sv:crs } | \ifx \:refout\:UnDef | \load:ref{\jobname.xref} \csname newwrite\endcsname\:refout |\openout\:refout=\jobname.xref \fi >>> \<<< \openin15=\jobname.xref \ifeof15 \def\:NoTag#1{\hbox{$???$}} \else \def\:NoTag#1{\hbox{$???$} \:warning{\string\XRef\string{\string#1\string}?}} | \fi \closein15 >>> \<<< \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 \`'\XRef' 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 \`'\XRef' and \`'LikeRef' commands will refer to truncated tags in which the specified prefixes are omitted. Intuitively, a tag can be viewed as a triplet \`':' 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} \<<< \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[ \<<< \def\:loadref[#1]{% \let\sv:cros|=\:CrossWord \edef|{#1}\ifx |\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 .|% \ifx \:temp\empty \set:CrossWord#2.|{|}\load:ref{#2.xref}% \else \set:CrossWord#2|{|}\load:ref{#2}\fi \let\:CrossWord|=\sv:cros } \def\get:ext#1.#2|{\def\:temp{#2}} \def\loadr:ef#1{\let|<+?|>=x \let||=\empty \lo:adref{}{#1}{##1}} >>> \<<< \:tempa>>> \<-?\><<< \:tempa>>> \<[?\><<< \:tempb>>> \<+?\><<< \:tempc>>> \<<< \:tempd>>> \SubSection{Incorporating the Preamble} \<<< \def\set:CrossWord#1|#2{% \edef\:temp{\noexpand\:setCrossWord#1|{#2}}\:temp} \def\:setCrossWord|.#2||{% \ifx [|<[?|> \def\:CrossWord##1##2##3{% \cond:CrossWord##1||{##1}{##2}{##3}}% \def\:tail|##1|{##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{|::}}% >>> \<:CrossWord := extend selected words\><<< \if -|<-?|> \def\cond:CrossWord##1|##2|##3##4##5{% \def\:temp{##1}\ifx \:temp\empty \Cross:Word{|::}% {\:tail##3|}{##4}{##5}\fi }% \else \def\cond:CrossWord##1|##2|##3##4##5{% \def\:temp{##1}\ifx \:temp\empty \Cross:Word{|::}{##3}{##4}{##5}\fi }% \fi >>> \<:CrossWord := selected words\><<< \if -|<-?|> \def\cond:CrossWord##1|##2|##3##4##5{% \def\:temp{##1}\ifx \:temp\empty \Cross:Word{}{\:tail##3|}{##4}{##5}\fi }% \else \def\cond:CrossWord##1|##2|##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. \<<< \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 |\cw:format{#1#2}\endcsname{% \expandafter\ifx\csname |\cw:format{#1#2}\endcsname\relax \else \csname |\cw:format{#1#2}\endcsname , \fi \ifx \:temp\empty #4\else \the\tmp:toks\fi}} \def\cw:format#1{#1}% >>> \<<< !*?: >>> \<<< #3>>> \<<< #1>>> %%%%%%%%%%%%%%%%%%% \Section{Link} %%%%%%%%%%%%%%%%%% Good for \''\Link{...}{...}' across files when we have \''\LoadRef+{...}{#1}'. \<<< \catcode`\:=12 \def\get@hfile#1{\get@hfil@ #1:::://} \def\get@hfil@#1::#2::#3//{% \expandafter\ifx \csname |#1::|#2\endcsname \relax \else \expandafter\expandafter\expandafter\get@@hfile \csname |#1::|#2\endcsname,//{#1}% \fi} \def\get@@hfile#1,#2//#3{% \expandafter\ifx \csname |#3::|#1% | file-name|>\endcsname \relax \else \csname |#3::|#1% | 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. \<<< \def\hidden:anchor{} >>> %%%%%%%%%%%%%%%%%%%%%%%%%% \SubSection{Latex Anomalies} %%%%%%%%%%%%%%%%%%%%%%%%%% \<<< \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 \<<< \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'. \<<< \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. \<<< | >>> \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} \<<< \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. \<<< | \ifHtml | \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. \<<< \ifx \FileStream\:UnDef \else \errmessage{--- TeX4ht error --- \noexpand\FileStream is defined outside of TeX4ht}\endinput \fi \def\FileStream{\IgnorePar \let||=-\futurelet\:temp\F:le} \def\F:le{\if +\:temp \let||=+\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[ \<<< \def\:File[#1]#2{% \no:pic\edef\file:name{#2}\yes:pic \expandafter\ifx\csname | file id|>\file:name\endcsname\relax |% \else |% \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. \<<< \xdef\file:id{\csname | file id|>\file:name\endcsname}% \ht:special{t4ht>\ifnum \file:id>\bs:fileid\space \file:name\fi }% >>> \<<< \ht:special{t4ht>\file:name}% \immediate\write-1{--- file \file:name\space ---}% |% \gHAdvance\maxfile:id |by 1 \global\let\file:id|=\maxfile:id \Tag{|\file:id | file-name|>}{\file:name}% \expandafter\xdef\csname | file id|>\file:name\endcsname{\file:id}% |% |% \a:PROLOG \a:HTML \a:HEAD \ifx +|% |% \xdef:cs{|\file:id}{\noexpand\a:TITLE |% \noexpand\b:TITLE\noexpand\a:@HEAD\noexpand\b:HEAD}% \else \xdef:cs{|\file:id}{}% \a:TITLE|\b:TITLE \a:@HEAD\b:HEAD\B:DY \fi >>> \<<< \bgroup \:TITLE: \c:TITLE \egroup >>> \<<< \bgroup \noexpand\:TITLE: \noexpand\c:TITLE \egroup >>> \<<< \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'. \<<< \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 >>> \<<< \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 \<<< \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. \<<< \:CheckOption{hshow} \if:Option \def\hshow#1{\writesixteen {..#1.......\expandafter\meaning\csname #1\endcsname}} | \fi >>> \<<< \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. \<<< Lv >>> \Section{Close Files} \<<< \def\EndFileStream#1{% \expandafter\ifx \csname | file id|>#1\endcsname\relax \:warning{\string\EndFileStream{#1}?}% \else \ifnum\csname | file id|>#1\endcsname=\bs:fileid \:warning{\string\EndFileStream{\jobname .\:html}?}% \else \expandafter\ifnum |% |% \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). \<<< {\let\inputlineno|=\tmp:cnt \tmp:cnt|=1 \root:next }% |% \ht:special{t4ht<#1}% \g:delete{\empty | file id|>#1}% |% >>> 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. \<<< \expandafter\expandafter\expandafter\global \expandafter \let\csname |\file:id\endcsname|=\:UnDef \global\let\file:id|=\maxfile:id \find:fileid >>> \<<< \def\find:fileid{% \expandafter\ifx \csname |\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'). \<<< \def\TagFile#1{% \expandafter\ifx \csname ||\endcsname \relax \else \Tag{#1|}{\LikeRef{|}}% \fi } \def\RefFile#1{\LikeRef{#1|}} \def\FileName{\LikeRef {|\file:id | file-name|>}} >>> \<<< |\file:id | file-name|>% >>> \`'\def\RefFile#1{\XRef{#1|}} \def\LikeRefFile#1{\LikeRef{#1|}}' \<<< \def\RefFileNumber#1{% \expandafter\ifx \csname ||#1% | file-name|>\endcsname\relax \else \:LikeRef{|#1| 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} \<<< \xdef:cs{\empty | file id|>\jobname .\:html}{\file:id} \xdef:cs{\empty | file id|>}{\file:id} \Tag{|\file:id | file-name|>}{\jobname .\:html} \bgroup |% \xdef:cs{|\file:id}{\noexpand\a:TITLE |% \noexpand\b:TITLE \noexpand\a:@HEAD\noexpand\b:HEAD}% \egroup >>> \Section{Document Head} \<<< \:startdoc >>> \<<< \def\at:startdoc{% \let\:startdoc|=\:UnDef \let\at:startdoc|=\:UnDef |% \a:Preamble |} \def\:startdoc{% \at:startdoc \edef\:temp{\pageno|=\the\pageno}% {\let\HCode|=\:gobble \par\newpage}\:temp} >>> The \''\let\HCode=\:gobble' is to prevent \`'
' 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 \<<< %\let\:shipout|=\shipout %\def\shipout{\vfil\break\let\shipout|=\:shipout \shipout} >>> \<<< \a:PROLOG \a:HTML \a:HEAD |% >>> 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'. \<<< \def\:prolog#1#2,#3|{% \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|}\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,|} >>> 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. \<<< \NewConfigure{PROLOG}[1]{\seq:config{PROLOG}{#1}} >>> \<<< \def\Goto:Configure{\long\def \Goto:Configure##1\:Configure{\let\Goto:Configure |=\:UnDef}\expandafter\Goto:Configure} | | | | | | >>> \Section{Document Tail} \<<< \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. \<<< \let\o:enddocumenthook|=\@enddocumenthook \def\@enddocumenthook{% \o:enddocumenthook \csname export:hook\endcsname } >>> \<<< \def\at:docend{|\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} >>> \<<< |% \HAssign\op:fl|=\maxfile:id\space \close:files |% |% >>> \<<< {\b:BODY \b:HTML}% >>> \<<< \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} \<<< | \ifHtml | | \fi >>> \Section{HPages} \`'\HPage[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-[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. \<<< \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} >>> \<<< \def\strt:bt#1{% \def\:bgtr<##1>{|% |% \futurelet\:temp#1}% \futurelet\:temp\ch:btgr} \def\ch:btgr{\ifx <\:temp \expandafter\:bgtr \else \expand:after{\:bgtr<>}\fi}% >>> \<<< \ifx #1\ch:bbtf \else \PushStack\:btid{##1}\fi >>> \<<< \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{% |% \:hookI{BeforeHPageButton}{}{#2}% \hpg:wrn{#1}{#2}\HPage \TagFile{|\: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{% |% \:hookI{BeforeHPageButton}{}{#1}% \NewFileName\HP:file \Save:Link\HP:file \Save:Temp\HP:file \TagFile{|\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}} >>> \<<< \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 >>> \<<< \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. \<<< \def\m:HPage#1{\futurelet\:temp\ch:mbut} \def\ch:mbut{\ifx [\:temp \expandafter\op:mbut \else \expandafter\:mbut \fi} \def\op:mbut[#1]{% |% \:hookI{BeforeHPageButton}{}{}% \edef\:temp{#1}% \ifx \:temp\empty \:warning{\string\HPage-[]?}\fi \TagFile{|\:temp}% \Save:HPageTag\:temp \Save:HPage{}% \NewFileName\HP:file \Save:Link\HP:file \HP:Link% \def\ContHPage{\:ContHPage{x}{#1}}} \def\:mbut{% |% \:hookI{BeforeHPageButton}{}{}% \NewFileName\HP:file \Save:Link\HP:file \TagFile{|\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}} >>> \<<< \def\:hookI#1#2#3{% \expandafter\ifx \csname #1\endcsname\relax #2\else \csname #1\endcsname{#3}\fi } >>> \<<< \def\NewFileName#1{% \HAssign#1|=\maxfile:id \Advance:#1 |by 1 \ifx \:NxtNwFN\:Undef \edef#1{\j:bname \ifx \big:fn\:UnDef|#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}} >>> \<<< \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). \<<< \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{|\: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{|\:temp}% \edef\HP:file{\RefFile\:temp}% \HP:Link% \def\ContHPage{\EndLink \:hookI{AfterHPageButton}{}{}% \csname AfterHPage\endcsname }} >>> \<<< \def\BeginHPage{\futurelet\:temp\ch:bbbt} \def\ch:bbbt{% |% \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 \<<< \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}% |% \FileStream{\:tempd}% \RecallEverypar \gHAdvance\HPageDepth |by -1 \PopStack\:afterbt\:temp \ifx \:temp\empty \else \csname AfterHPage\endcsname \fi } >>> Overrides earlier defs, including the default. \<<< \def\AtEndHPage{% \expandafter\gdef\csname EndHPage\HPageDepth\endcsname} >>> \<<< \HAssign\HPageDepth|=0 \PushStack\:btid{} >>> %\NewStack\:btid \<<< \ifnum \HPageDepth> 0 \EndHPage[1]{}\fi |% >>> \SubSection{Debugging} \<<< \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. \<<< %\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'.) \<<< %\chk:hpfl >>> \<<< \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. \<<< \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 >>> \<<< \def\:buttrc#1#2{} \let\HTraceHPageOn|=\empty \let\HTraceHPageOff|=\empty >>> \SubSection{Utilities} \<<< \expand:after{\bt:fn##1.}\:html|% >>> \<<< \expand:after{\def\bt:fn##1.}\:html#2|{% \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 '. 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. \<<< \Odef\ExitHPage[#1]#2{% \Recall:HPageTag\HP:file \Save:HPageTag\HP:file \Link[\RefFile{|\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 } >>> \<<< \NewConfigure{ExitHPage}{3} >>> \<<< )B>>> \`'\RefHPage' can be used for the filename and HPage location. \<<< \def\RefHPage{\RefFile} >>> \<<< \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. \<<< \def\CutAt#1{% \if +\:firstch#1 //\:CutAt#1,//\else \if |<- TITLE|>\:firstch#1 //\:CutAt#1,//\else \:CutAt=#1,//\fi\fi } >>> \<<< \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 |% \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}' \<<< \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\
}}




 We temporariliy get out from display mode, because we want the
 \`'
' before \''\halign' and nothing is allowed before
 \''\halign' in display mode.  The enclosure within table is
to group the content for protection from embedding \''
' 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'. \<<< \let\tabskip|=\tmp:dim \let\hrulefill|=\empty \let\hidewidth|=\empty \expand:after{\h:align#1\cr|#1|}% >>> 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'. \<<< \catcode`\#|=13 \catcode`\@|=6 \long\def\h:align@1\cr@2|{\def\:temp{@2}\ifx \:temp\empty \expandafter\h:alignII \else \crcr:align@1\crcr|\fi} \def\crcr:align@1\crcr@2|{\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|{% \SaveMkHalignConfig |% \MkHalign#{@1}@2\EndMkHalign \RecallMkHalignConfig} \def\h:alignII@1\crcr{\h:alignI@1\cr} \catcode`\#|=6 \catcode`\@|=11 >>> \<<< \Configure{MkHalign}{\hlg:a}{\hlg:b} \hlg:c\hlg:d{\hlg:e\RecallMkHalignConfig}\hlg:f >>> \<<< \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}} >>> \<<< \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?). \<<< | >>> \<<< \HAssign\noalign:N|=0 \def\:tempc#1{|% \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 | >>> 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 \<<< \NewConfigure{noalign-}[2]{\c:def\a:noalign{#1}\c:def\b:noalign{#1}} >>> Any reason left for keeping both cases? \<<< \: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'?.). \<<< \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} \<<< | \ifHtml | \fi | >>> \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} \<<< \def\V:rbatim{\begingroup \begin:Verb \Verb:env } \def\:EndVerbatim{\end:Verb \endgroup } >>> \<<< { \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 \<<< \NewConfigure{tt}[1]{\let\vrb:tt|=#1} \let\vrb:tt|=\tt >>> \<<< \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|=} | | | >>> \<<< { \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} } >>> \<<< { \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} \<<< \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. \<<< \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{}} {\HChar{160}\HCode{}} {\HChar{160}\HCode{
}} \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. \<<< \def\ScriptCommand{\begingroup \catcode`\\|=12 \:DefScript} \def\:DefScript#1{\endgroup \Def:Script#1|} \def\Def:Script#1#2|{% \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}' \<<< \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} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \<<< \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. \<<< \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): \<<< \ht:special{t4ht>\jobname.tmp}{\everyhbox{}\hbox {x\ht:special{t4ht;\a:rootfont:}x}}% \ht:special{t4ht<\jobname.tmp}% >>> \<<< \NewConfigure{Css}[1]{\def\aa:Css{#1}} >>> \<<< \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} \<<< \ifHtml | \fi >>> \Section{Positioned Elements} \<<< \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 \<<< \def\Canvas{\ht:special{t4ht"}} \let\EndCanvas|=\Canvas >>> The attached source tries three renderings for `Ax'. 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 ./\.......} Ax \EndVerbatim \Section{/Picture Comamnd} \<<< \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} >>> \<<< \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 \''' tag. Empty file name is a request for a default name of the form \`'\jobname%\romannumeral \P:ctureCount'. \<<< \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} \<<< \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[...]{...}'. \<<< \def\xim:g[#1]#2{{\cond:pic{% \def\gif:nm{\edef\gif:nm}\gif:name{#2}% \expandafter\get:ext\gif:nm.|% \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 >>> \<<< \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*{...}'. \<<< \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} >>> \<<< \NewConfigure{PictureAlt*+}{2} \NewConfigure{PictureAttr*+}[1]{% \expandafter\def\csname a:PictureAttr*+\endcsname##1{#1}% } \Configure{PictureAttr*+}{\ht:special{t4ht=#1}} >>> \Verbatim flag ){ ` } else switch( get_char() ){ case '+': { ` case '@': { ` break; } case '+': { while( special_n-- > 0 ) (void) get_char(); break; } case '=': Contribution of text (\''\HCode'). case '<': case '>': { ` break; } case '!': { ` 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{
} \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 \`'', 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{
} \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} \<<< \NewConfigure{IMG}{5} >>> The third and forth parameters are separated by user cotributed attr-list. \<<< \NewConfigure{Picture}[1]{\def\PictExt{#1}} \Configure{Picture}{.png} >>> \<<< \let\im:g|=\noim:g >>> \<<< \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) \<<< \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}}} >>> \<<< \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'. \<<< \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} >>> \<<< \NewConfigure{Picture*}{2} >>> \<<< \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} >>> \''
'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.


\<<<
\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*+[...]{...}'.


\<<<
\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}
>>>



\<<<
\NewConfigure{PictureAlt*+[]}{2}
\NewConfigure{PictureAttr*+[]}[1]{%
   \expandafter\def\csname a:PictureAttr*+[]\endcsname##1{#1}%
}
\Configure{PictureAlt*+[]} {\NoFonts} {\EndNoFonts}
\Configure{PictureAttr*+[]} {\ht:special{t4ht=#1}}
>>>



\<<<
\ifx \:DraCatCodes\:UnDef 
   |
\fi
>>>

\<<<
\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

\<<<
\let\:GifText|=\no:GifText
>>>

\<<<
\let\:GifText|=\x:GifText
>>>


\SubSection{File Name}

We have a command of the form \''\gif:name{file-name attributes}'



\<<<
\def\gif:name#1{\edef\at:IMG{\noexpand\get:gfnm#1 |}\at:IMG}
>>>

The material within the if is for eliminating the extra space
introduced before \`'|'.

\<<<
\def\get:gfnm#1 #2|{\def\at:IMG{#2}%
   \ifx \at:IMG\empty\else 
      \expandafter\aT:IMG\at:IMG|%
   \fi
   \gif:nm{#1}}
\def\aT:IMG#1 |{\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 |}\at:IMG}
\def\get:gfnm#1 #2|{\def\at:IMG{#2}\gif:nm{#1}}

\EndVerbatim




\<<<
\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|\P:ctureCount
                        x\Pic:Dm\PictExt}%
      \egroup
   \else
      \expandafter\get:ext\PictureFile.|%
      \ifx\:temp\empty \xdef\PictureFile{\PictureFile\PictExt}\fi
   \fi
   \immediate\write-1{l. \the\inputlineno\space Writing
                 \jobname.idv[\P:ctureCount] (\PictureFile)}%
   }%
>>>

\<<<
\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 \''-->'  expand. Why
the \''\HCode' is not a problem?


\<<<
\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}

\<<<
\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.


\<<<
\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.


\<<<
\def\PictureOff{%
   \expandafter\let\csname Pic:\Pic:On\endcsname|=\EndPicture
   \ifx \EndPicture\:UnDef   \let\EndPicture|=\empty \fi
   |%
   \Advance:\Pic:On |by 1 }
\def\PictureOn{%
   \ifnum \Pic:On>0
     \Advance:\Pic:On |by -1
     \ifnum \Pic:On=0  |%
     \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.

\<<<
\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}


\<<<
\:CheckOption{base}
\if:Option  \else
   |
   |
   |
   |
   |
\fi
>>>


\Section{End Points of Math Environments}


The following become active only when they are being configured.



\<<<
   \NewConfigure{$}[3]{%
      \def\a:mth{\bgroup#1}\def\b:mth{#2\egroup}%
      \def\c:mth{|#3}%
      \everymath{\ifx \EndPicture\:UnDef
          $\a:mth\everymath{}\everydisplay{}$%
                 \aftergroup\b:mth \c:mth \fi}}
>>>




\<<<
   \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'|' into \Verb+\def\c:display{#3}%+
because of cases such as \Verb+$$\halign{#\cr a\cr}$$+


\<<<
{\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}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\<<<
\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}}
>>>


\<<<
\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}}
>>>




\<<<
\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}


\<<<
\def\DviMath{\a:DviMath\leavevmode \MathClass | \DviSend}
\def\EndDviMath{\EndDviSend |\EndMathClass \b:DviMath}
\NewConfigure{DviMath}{2}
>>>



The above need to be boxed to prevent page breaks within the send 
environment  \`'\special{t4ht~}...\special{t4ht~}'..

\<<<
\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 
>>>

\<<<
\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\DviMath} {\EndDviMath\Tg} {}
\Configure{$$} {\Tg\DviMath} {\EndDviMath\Tg} {}

\Configure{()} {\Tg\DviMath$} {$\EndDviMath\Tg} 
\Configure{[]} {\Tg\DviMath$$} {$$\EndDviMath\Tg} 
\EndVerbatim




\SubSection{Positioned Math}



\<<<
\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
\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} \<<< \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 \<<< \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 | | \def\no:restore{\let\no:restore|=\:UnDef} \else \Log:Note{for non active \string_, use the command line option `no\string_'}% | | \catcode`\_|=13 | \def\x:SUBOff{\let_|=\s:b} \def\pr:sb{\ifx \EndPicture\:UnDef \expandafter\Protect\expandafter\S:b \else \expandafter\s:b \fi} | | | | \catcode`\_|=8 \:CheckOption{_13} \if:Option \def\no:restore{\let\no:restore|=\:UnDef \mathcode`\_|="8000 \catcode`\_|=13 } \append:def\SUBOn{\mathcode`\_|="8000 \catcode`\_|=13 |} \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 |} \fi \bgroup \SUBOn \def\:temp{|} \expandafter \egroup \:temp \fi >>> \<<< \let\x:SUBOff|=\empty \let\x:SUBOn|=\empty >>> \<<< \let\SUBOff|=\empty \let\SUBOn|=\empty >>> \<<< \ifx \sys:sb\:UnDef \def\:tempaa{_} \else \def\:tempaa{\noexpand\sys:sb}\fi >>> \<<< \ifx \sys:sb\:UnDef \def\:tempa#1{\append:def\SUBOff{\let#1|=_}} \else \def\:tempa#1{\append:def\SUBOff{|}}\fi >>> \<<< \def#1{% \ifmmode \expandafter\s:b \else \expandafter\sys:sb \fi }% >>> \<<< \edef\:SUBOff{\def\noexpand_{\:tempaa}} >>> \<<< \:tempa_ >>> \<<< \def\x:SUBOn{\def_{\ifmmode \expandafter\pr:sb \else \expandafter\sys:sb\fi}|} \x:SUBOn >>> \<<< \def\SUBOn{\catcode`\_|=8 \def_{\ifmmode \expandafter\pr:sb \else \expandafter\sys:sb\fi}} \SUBOn >>> \<<< \def\SUPOn{} \def\SUBOn{} >>> \<<< \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 >>> \<<< \let\s:p|=\sp \let\:spp|=\sp \def\sp{\m:op\:spp{SUP}} \catcode`\^|=7 | \:CheckOption{no^} \if:Option \let\s:p|=\:UndFi | | \else \Log:Note{for non active \string^, use the command line option `no\string^'}% |% |% \catcode`\^|=13 | \def\x:SUPOff{\let^|=\s:p } \def\pr:sp{\ifx \EndPicture\:UnDef \expandafter\Protect\expandafter\S:p \else \expandafter\s:p \fi} | | | | | \catcode`\^|=7 \:CheckOption{^13} \if:Option | \append:def\no:restore{\mathcode`\^|="8000 \catcode`\^|=13 } \append:def\SUPOn{\mathcode`\^|="8000 \catcode`\^|=13 |} \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 |} \fi \bgroup \SUPOn \def\:temp{|} \expandafter \egroup \:temp \fi >>> \<<< \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}} >>> \<<< \def\:sUp{% \let\:sUp|=^% \def^{\futurelet\:temp\next:hat} \def\next:hat{\ifx ^\:temp \expandafter\:dblhat\else \expandafter\:sUp\fi}% } >>> \<<< \: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}} >>> \<<< \let\x:SUPOff|=\empty \let\x:SUPOn|=\empty >>> \<<< \let\SUPOff|=\empty \let\SUPOn|=\empty >>> \<<< \ifx \sys:sp\:UnDef \def\:tempbb{^} \else \def\:tempbb{\noexpand\sys:sp}\fi >>> \<<< \ifx \sys:sp\:UnDef \def\:tempb#1{\append:def\SUPOff{\let#1|=^}} \else \def\:tempb#1{\append:def\SUPOff{|}}\fi >>> \<<< \def#1{% \ifmmode \expandafter\s:p \else \expandafter\sys:sp \fi }% >>> \<<< \edef\:SUPOff{\def\noexpand^{\:tempbb}} >>> \<<< \:tempb^ >>> \<<< \def\x:SUPOn{\def^{\ifmmode \expandafter\pr:sp \else \expandafter\sys:sp\fi}|} \x:SUPOn >>> \<<< \def\SUPOn{% \def^{\ifmmode \expandafter\pr:sp \else \expandafter\sys:sp\fi}} \SUPOn >>> \<<< \let\sp=^ >>> \<<< \let\sb=_ >>> \<<< \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 >>> \<<< \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} | \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} \<<< \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'$+. \<<< \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? \<<< \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} >>> \<<< \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 \''' 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. \<<< \: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} \<<< \ifx \config:opt\:UnDef \else | \fi >>> \<<< \append:def\:RestoreCatcodes{\early:sub\early:sup} \let\:IfFileExists\IfFileExists % I am not sure why we used this declaration. It is from the original % TeX4ht sources, so it probably had some reason. The problem is that it % inserts extra tokens after \:IfFileExists, and if some package uses % something like \IfFileExists{foo.sty}{\@firstoftwo}{\@secondoftwo}{aa}{bb}, % then it fails. I've found this issue with the Standalone class. % See https://tex.stackexchange.com/a/638965/2891 for example where it fails. % \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 >>> \<<< \csname recall:sub\endcsname \csname recall:sup\endcsname >>> \<<< \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 } | \let\:CheckOption|=\:UnDef >>> \<<< \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 >>> \<<< \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. \<<< \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. \<<< \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 >>> \<<< \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~}|% /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. \<<< \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. \<<< \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. \<<< \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 >>> \<<< \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. \<<< \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*}{*}{}{}{\Configure{FormulaClass}{0}{}{}{}} \mathop{\fam0#1}}'. \<<< \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}} >>> \<<< \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. \<<< \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 \''
's  within
formulas in visual browsers.

\<<<
\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}


\<<<
\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}
>>>

\<<<
\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~<}\HCode
     {}}
   {\special{t4ht\string~>}}'


   
   Beware of nested formulas for proper arrangments of
   \`'\special{t4ht\string~...}'






\SubSection{Radical's}

\<<<
\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.


\<<<
\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}{...}'.

\<<<
\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}


\<<<
\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}

\<<<
\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.



\<<<
\NewConfigure{FontCss}[2]{\def\a:FontCss:{#1}\def\a:FontCssPlus:{#2}}
>>>

\<<<
\NewConfigure{htf-css}[2]{{%
   \def\:temp##1|{\def\:tempa{##1}}%
   \afterassignment\:temp\tmp:cnt|=0#1|%
   \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}{}{}{}
$\leq$
\Configure{htf}{6}{+b}{}{}{}
$\leq$

\Needs{a .......}
\Needs{b .......}
\EndVerbatim

produces

\Verbatim
Font class 6 a: 
Font class 6 b: 
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,""): 
Font_Class(3,"mva"): 
Font_Class(6,"ul"): 
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}
%%%%%%%%%%%%%%%%%%%%%%

\<<<
\:CheckOption{new-accents}     \if:Option
   |
\else
   |
   | 
\fi
>>>





Some accents of TeX are defined through commands of the form
\`'\accent  ', and some throught macros (e.g., \''\b',
\''\c', and \''\d').  Moreover,the \`'\accent  ' reduces
to \`'\char ', whenever \''' doesn't immediately follows
\''' (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+).

\<<<
\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.




\<<<
\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|}%
   \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.

\<<<
\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|#2#3#4{%    
   #3\nopic:accent|{#2}{}{}#4}
\def\nopic:accent#1|#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}




\<<<
\NewConfigure{accent}[5]{%
   \expandafter\ifx \csname x:\string#2\endcsname\relax
      \expandafter\edef
         \csname x:\string#2\endcsname{\accent:cnt}%
      |%
      |%
      \Advance:\accent:cnt by 1  
   \fi
   \edef\:tempa{\csname x:\string#2\endcsname}%
   |%
   }
\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.


\<<<
\expandafter\let\csname t:\accent:cnt\endcsname|=#1%
\expandafter\let\csname m:\accent:cnt\endcsname|=#2%
>>>


\<<<
\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
   |}%
\: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'.

\<<<
\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}'



\<<<
\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).


\<<<
\def\ac:pc{\Protect\csname acp:c\endcsname}
\def\acp:c#1#2{{\def\acn:no{#1}\def\:temp{#2}\ifx \:temp\empty
      |% 
   \else |%
      \def\ac:pc{\ac:nt{#2}}\a:cpc{#1}\fi }}
\def\ac:nt{\csname \ifmmode m\else t\fi :\acn:no\endcsname}
>>>

\<<<
\ac:nt{}%
>>>

\<<<
\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.


\<<<
\def\a:cpc#1{%
  \ifx \EndPicture\:UnDef  
     \def\AC:PC{|%
     }%
     \: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'.

\<<<
\def\end:accent#1\empty{}
\def\:accnts#1{}
>>>







The :tabacckludge is undefined, so it doesn't make sense to redefine the
original command with this non existent command.

\<<<
%\let\@tabacckludge|=\:tabacckludge
>>>

\SubSection{Getting the Html Replacement}


\<<<
\def\acpc:#1#2{%
   \def\:tempa{#1}\ifx \:tempa\empty  
      |%
   \else \ifx \:tempa\:temp  \let\AC:PC|=\empty  
             |\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.

\<<<
\ifx \:temp\empty
   \def\:tempa{#2}\ifx \:tempa\empty  \AC:PC
   \else |\fi
\else \AC:PC \fi
>>>


\<<<
\csname \ifmmode m\else t\fi :\acn:no\endcsname{#2}%
>>>


\<<<
\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.


\<<<
{\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}}$'.


\<<<
                   \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}

\<<<
\def\Hnewline{\:newlnch}
>>>

Without the following, we get in toc things like \`'^^J' 
that don't go together with catcode 13 for \`'^'.

\<<<
\let\:newlnch|=\space
>>>


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Symbols}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Check that all the symbols belong to TeX and LaTeX


\<<<
\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 |

%   |    |%after |%

% \<<<
% \ifHtml
%   \let\:copyright|=\copyright
%   \def\::copyright{\gt:ch\:copyright{copy}}
%   \def\copyright{\Protect\::copyright}
%   \def\gt:ch#1#2{\ifx \EndPicture\:Undef \HCode{}\else #1\fi }
% \fi
% >>>
% 


\<<<
\NewConfigure{@Picture}[1]{\def\a:@Picture{#1}}
\let\a:@Picture|=\:gobble
>>>





\Chapter{Dvi-Based Hooks}

\<<<
|
|
>>>



\Section{Tracing Dvi}

\<<<
\def\HTrace#1{\csname #1:T\endcsname}
\def\EndHTrace#1{\csname #1:t\endcsname}
>>>

\<<<
\def\RULE:T{\ht:special{t4ht@\%R}}  \def\RULE:t{\ht:special{t4ht@\%r}}
>>>

\<<<
\NewConfigure{RULE}[5]{\ht:special{t4ht@\%\%R#1#2#1#3}
  \ht:special{t4ht@\%\%r#1#4#1#5}}
>>>

\<<<
\def\GROUP:T{\ht:special{t4ht@\%P}}  \def\GROUP:t{\ht:special{t4ht@\%p}}
>>>


\<<<
\NewConfigure{GROUP}[5]{\ht:special{t4ht@\%\%P#1#2#1#3}
  \ht:special{t4ht@\%\%p#1#4#1#5}}
>>>


\<<<
\def\CHAR:T{\ht:special{t4ht@\%C}}  \def\CHAR:t{\ht:special{t4ht@\%c}}
>>>

\<<<
\NewConfigure{CHAR}[5]{\ht:special{t4ht@\%\%C#1#2#1#3}
  \ht:special{t4ht@\%\%c#1#4#1#5}}
>>>

\<<<
\def\HSPACE:T{\ht:special{t4ht@\%H}}  \def\HSPACE:t{\ht:special{t4ht@\%h}}
>>>

\<<<
\NewConfigure{HSPACE}[3]{\ht:special{t4ht@\%\%H#1#2#1#3}}
>>>


\<<<
\def\VSPACE:T{\ht:special{t4ht@\%V}}  \def\VSPACE:t{\ht:special{t4ht@\%v}}
>>>

\<<<
\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.

\<<<
\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~<+}}
>>>

\<<<
\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}
%%%%%%%%%%%%%%%%%%

\<<<
\def\hyphenation#1{}
>>>








%%%%%%%%%%%%%
\Section{String Encode}
%%%%%%%%%%%%%

\<<<
\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|{%
      \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|%
   }
   \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|{}
>>>


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 ! " # $ % & ' ( ) + , < > |

\Configure{urlEncoder}{}{}

\urlEncoder ! " # $ % & ' ( ) + , < > |
\EndVerbatim



%%%%%%%%%%%%%
\Section{Moveright}
%%%%%%%%%%%%%

\<<<
\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}


\<<<      
\:CheckOption{debug}
\if:Option |
\else      | \fi   
>>>









              






\Chapter{e tex/latex}


\Link[http://www.vms.rhbnc.ac.uk/e-TeX/v1/etex\string
  _ref.html]{}{}e-TeX\EndLink

\<<<
\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'?

\<<<
\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...?????????????????????


\<<<
\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:'.

\<<<
\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}
>>>



\<<<
\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}
>>>

\<<<
\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}

\<<<
\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}

\<<<
\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 }
>>>

\<<<
\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}
>>>


\<<<
\def\PushConfigure#1{\def\cf:name{#1}\expandafter
   \expandafter\expandafter\Push:Configure\expandafter
   \meaning\csname c:#1:\endcsname|}
\def\PopConfigure#1{\def\cf:name{#1}\expandafter
   \expandafter\expandafter\Pop:Configure\expandafter
   \meaning\csname c:#1:\endcsname|}
\def\do:undef#1->#2|{%
   \if :#2:\:warning{\string\PushConfigure{\cf:name}?}\fi
}
\catcode`\@=6
\catcode`\#=12
\def\Push:Configure@1|{%
   \do:undef@1->|%
   \do:para@1#1|\push:config
   \do:parb@1#2|\push:config
   \do:parc@1#3|\push:config
   \do:pard@1#4|\push:config
   \do:pare@1#5|\push:config
   \do:parf@1#6|\push:config
   \do:parg@1#7|\push:config
   \do:parh@1#8|\push:config
   \do:pari@1#9|\push:config
}
\def\Pop:Configure@1|{%
   \do:pari@1#9|\pop:config
   \do:parh@1#8|\pop:config
   \do:parg@1#7|\pop:config
   \do:parf@1#6|\pop:config
   \do:pare@1#5|\pop:config
   \do:pard@1#4|\pop:config
   \do:parc@1#3|\pop:config
   \do:parb@1#2|\pop:config
   \do:para@1#1|\pop:config
}
\def\do:para@1#1@2|@3{@3{a}{@2}}
\def\do:parb@1#2@2|@3{@3{b}{@2}}
\def\do:parc@1#3@2|@3{@3{c}{@2}}
\def\do:pard@1#4@2|@3{@3{d}{@2}}
\def\do:pare@1#5@2|@3{@3{e}{@2}}
\def\do:parf@1#6@2|@3{@3{f}{@2}}
\def\do:parg@1#7@2|@3{@3{g}{@2}}
\def\do:parh@1#8@2|@3{@3{h}{@2}}
\def\do:pari@1#9@2|@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-'.

\<<<
\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.

\<<<
\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}
>>>

\<<<
\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}

\<<<
\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}

\<<<
\def\Log:Needs#1{{\escapechar=`\\\immediate\write-1{\:Neds{#1}}}}
>>>

\<<<
\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.

\<<<
\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}'




\<<<
\def\LinkCommand#1#2{\L:Com#1#2,,,,,,|{#1}}
\let\:Link|=\Link
\def\L:Com#1#2,#3,#4,#5,#6,#7,#8|#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}\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
   |%
  }
>>>


\<<<
\expandafter\let\csname \string#1 :\endcsname|=#1
\def#1{\bgroup\LD:Link{#1}\futurelet#1\M:link}
>>>

\<<<
\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}
>>>

\<<<
\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}+
% 
% \<<<
% \def\Attribute#1{%
%    \def#1{\expandafter\noexpand\csname\string#1\endcsname}%
%    \expandafter\def\csname\string#1\endcsname="##1"}
% >>>




\Section{Loose Ends}



\<<<
\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}
>>>


\<<<
\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



\<<<
\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.

\<<<
\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.

This is a variant of \`'\protected@edef' from LaTeX. We cannot use it directly here, so I've made a copy.

\<<<
\def\:unexpand:protect{\noexpand\protect\noexpand}
\def\:restore:protect{\let\protect\orig:protect}
\def\protected:edef{%
  \let\:orig:protect\protect%
  \let\protect\:unexpand:protect%
  \afterassignment\:restore:protect%
  \edef%
}

>>>

\Section{Tags}

\SubSection{Html}


The following create \`'.........' in the table of contents and 
\`'..........' 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. 



\<<<
Q>>>


The prefix \`'\' is required for distinguishing the tocs tags
from other tags to allow for selective loading of cross references
when communicating toc info.





\ file id\><<<
 FN >>>




\SubSection{Standard}


\FreeCode\  % to avoid duplication

\<<<
 cw:>>>









\<<<
(L >>>




\<<<
|N >>>



\<<<
|B >>>



\SubSection{Internal}

\<<<
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.  




\<<<
\def\:warning#1{\writesixteen{l.\the\inputlineno\space
            --- TeX4ht warning --- #1 ---}}
\ifx \:ShowCode\:UnDeF \else 
   \:warning{|.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 \`'' coomands, because we don't need now Ref/Tag intermediates.

\<<<
\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{|#1} \fi
>>>

\`'make:addr' may already be defined from AlProTex. It had\''\space' after \`'#1' that has been removed (see AlProTex).


\<<<
\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

\<<<
\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
>>>

\<<<
\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>>>




%-------------------------------------------------------
\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\


\bye