<..non-html TeX4ht divs..>
\headline={\:HeaderNumFont \botmark
\ifodd\pageno \:rightheader \else \:leftheader \fi }
\footline={\:HeaderNumFont \hfil \:footer \hfil}
\gdef\:leftheader{\hfil}
\gdef\:rightheader{\hfil}
\gdef\:footer{\folio}
\let\::uppercase=\uppercase
\def\:uppercase#1{{\:HeaderTitleFont \::uppercase{#1}}}
-_-_-
We don’t know under what condition \mark and \topinsert will expand.
<..headline and footline from ch..>
\:HeaderFonts
\gdef\:ChHeader{\noexpand\folio\hfil \:uppercase{#1}}%
\xdef\:StrtChNo{\the\pageno}%
\xdef\:leftheader{\noexpand\ifnum \:StrtChNo=\pageno\hfil
\noexpand\else\:ChHeader\noexpand\fi}%
\xdef\:footer{\noexpand\ifnum \:StrtChNo=\pageno\folio
\noexpand\fi}%
\xdef\:rightheader{\noexpand\ifnum \:StrtChNo=\pageno \hfil
\noexpand\else \:uppercase{#1}\hfil\noexpand\folio
\noexpand\fi}%
\mark{}%
-_-_-
First mark for current HPage. The second is for the following HPages, until we get a section header.
The empty \mark ensures that the ones from a sections will not change the definition of \:rightheader in first HPage of the chapter (when \firtmark is the choice) and that nothing will propogate from previous HPages.
The \write, and \mark(?), commands introduce whatsis so we want them in horizontal mode to avoid extra spaces. Also, for correct HPage numbers, and for correct timing of headers, we want the \:toc and \mark to be inserted after we get to horizontal mode.
<..headline from section..>
\:HeaderFonts
\if:chapters \mark{%
\gdef\noexpand\:rightheader{%
\noexpand\ifnum \:StrtChNo=\pageno \hfil \noexpand\else
\ifnum \SectionCounter>0
\:uppercase{\theSectionCounter}\space\space \fi
\:uppercase{#1}\hfil\noexpand\folio
\noexpand\fi}%
}%
\fi
-_-_-
We also have to take into consideration that sections present with no chapters. Hence, the following definition, and in the above \:rightheader is defined before \:leftheader.
<..headers and footers..>
\gdef\:ChHeader{\:rightheader}-_-_-
‘\:HeaderFonts{cmr8}{cmr10}’—first font to sections and chapters fonts, and seconf font for HPage numbers.
We want ‘\:HeaderNumFont’ and ‘\:HeaderTitleFont’ to be hard wired to a specific font because otherwise fonts taht are in effect when the HPages are submitted will take effect (\rm, for instance, is not a font).
<..non-html TeX4ht divs..>+
\ifx \:HeaderNumFont\:UnDef
\font\eightrm=cmr8
\font\eighttt=cmtt8
\def\HeaderFonts#1#2#3{%
\let\:HeaderNumFont=#1
\let\:HeaderTitleFont=#2
\def\:HeaderFonts{#3}}
\HeaderFonts\tenrm\eightrm{\def\tt{\eighttt}}
\fi
-_-_-