% $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#2|{#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{#2>}}}
\def\:tagempty#1/>{\hbox{\HCode{<#1/>}}}
\expandafter\def\csname c:<:\endcsname#1>{\:gobbleII}
>>>
The \`'\hbox' above is to avoid creating extra paragraphs with
extra tags, which can also introduce extra paragraph ends.
The definiions of \''\c:<...>:' are broken into two parts
to avoid the spaces after the closing angular bracket \''>'.
\<<<
\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{#2>}}}
\def\:tagempty#1/>{\VerifyEmpty{#1}\hbox{\HCode{<#1/>}}}
\expandafter\def\csname c:<:\endcsname#1>{\:gobbleII}
>>>
The \`'\hbox' above is to avoid creating extra paragraphs with
extra tags, which can also introduce extra paragraph ends.
\<<<
\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{\get:tag{#1}>}}
\long\def\InlineElementStart#1#2{\InsertTagStart{#1}{#2}}
\long\def\InlineElementEnd#1{\InsertTagEnd{#1}}
\long\def\BlockElementStart#1#2{\ifvmode\IgnorePar\fi\EndP\InsertTagStart{#1}{#2}}
\long\def\BlockElementEnd#1{\ifvmode\IgnorePar\fi\EndP\InsertTagEnd{#1}}
% define default values for a new logical block
\def\NewLogicalBlock#1{%
\SetTag{#1}{span}%
\expandafter\def\csname #1:properties\endcsname{}
}
\def\SetTag#1#2{\expandafter\xdef\csname #1:tagname\endcsname{#2}}
\def\get:tag#1{\expandafter\expandafter\csname #1:tagname\endcsname}
\def\SetBlockProperty#1#2#3{%
\expandafter\ifcsname #1:property:#2\endcsname\else%
\expandafter\edef\csname #1:properties\endcsname{\csname #1:properties\endcsname\space\csname #1:property:#2\endcsname }
\fi%
\expandafter\def\csname #1:property:#2\endcsname{#2="#3"}
}
\def\get:block:properties#1{%
\expandafter\csname #1:properties\endcsname%
}
>>>
\Section{Verify Elements}
\<<<
\: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 --- #1> witout <#1>}%
\expandafter\gHAssign\csname #1Level:\endcsname|=0
\else
\expandafter\gHAdvance\csname #1Level:\endcsname |by -1
\gHAdvance\:ChkLevel |by -1
\PopStack\:CHK\:temp
\edef\:tempa{#1}%
\ifx \:temp\:tempa
\PopStack\:CHK\:CurrentChk
\PushStack\:CHK\:CurrentChk
\else
\writesixteen{\the\inputlineno.
--- warning --- \:temp> instead of #1>}%
\fi
\fi
}
\def\VerifyEmpty#1{\Protect\trace:emptychk#1 |}
\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.
\<<<
|