Sectioning commands can be called directly through their default definitions, or indirectly throught \rdef:sec.
The latter invocation calls a corresponding tex4ht command: \:likefoo in case of a starred commands, and \no:foo in case of non-starred commands. Then it invokes the original definition, without a title, to extract the native changes in the environment, such as counter numbers.
ltsect.dtx
\let\no:ssect=\@ssect
\def#1#2#3{\no:ssect{#1}{#2}{0ex}}
\let\no:sect=\@sect
\def\no@sect#1#2#3#4#5{\no:sect{#1}{#2}{#3}{#4}{0ex}}
-_-_-
<..latex ltsect..>
\let\no@ssect=\@ssect
\def\@ssect#1#2#3#4#5{\:Sc3
\no@ssect{#1}{#2}{#3}{#4}{\:Sc4#5\:Sc2}\HtmlEnv}
\let\no@sect=\@sect
\def\@sect#1#2#3#4#5#6[#7]#8{%
\xdef\c:secnumdepth{#2}\:Sc3
\no@sect{#1}{#2}{#3}{#4}{#5}{#6}[#7]{\:Sc4#8\:Sc2}\HtmlEnv}
\let\:startsection=\@startsection
\def\@startsection#1{\@ifstar{\Configure{secType}{like#1}}%
{\Configure{secType}{#1}}%
\:Sc1\:startsection{#1}}
\NewConfigure{secType}[1]{\def\sec:typ{#1}}
-_-_-
\@sec and \@ssec are redefined in tex4ht.4ht to be based on building-blocks of tex4ht.sty. The section- option resestablish the default setting.
<..latex ltsect..>+
\NewConfigure{@sec @ssect}[1]{%
\def\rdef:sec##1{#1\csname no@##1\endcsname}}
\:CheckOption{sections-} \if:Option
\Configure{@sec @ssect}{}
\else
\Configure{@sec @ssect}{%
<.sv Sc, sec, ssec.>\let\:Sc=\:gobble
<.redf sec.>%
<.redf ssec.>\IgnorePar}
\fi
-_-_-
The following is need for \@seccntformat.
<..disable @seccntformat..>
\ifx \o:@seccntformat:\:UnDef
\let\o:@seccntformat:=\@seccntformat
\fi
\let\@seccntformat=\:gobble
-_-_-
<..restore @seccntformat..>
\let\@seccntformat=\o:@seccntformat:
-_-_-
<..redf sec..>
\def\@sect##1##2##3##4##5##6[##7]##8{%
<.disable @seccntformat.>%
\let\@sect=\no@sect \xdef\c:secnumdepth{##2}%
{\SkipRefstepAnchor \let\addcontentsline=\:gobbleIII \let\mark=\:gobble
\no@sect{##1}{##2}{##3}{##4}{##5}{##6}[{##7}]{}}%
<.recall Sc, sec, ssec.>%
<.restore @seccntformat.>%
\HtmlEnv \Toc:Title{##7}\csname no:#1\endcsname{##8}}%
-_-_-
In the above we want ‘[{##7}]’ instead of ‘[##7]’, in case ‘]’ is included in the parameter.
The following is for the star option.
<..redf ssec..>
\def\@ssect##1##2##3##4##5{%
<.star sec title.>%
\let\@ssect=\no@ssect
{\def\addcontentsline####1####2####3{}%
\no@ssect{##1}{##2}{##3}{##4}{}}%
<.recall Sc, sec, ssec.>%
\HtmlEnv \csname :like#1\endcsname{##5}}%
-_-_-
<..sv Sc, sec, ssec..>
\let\sv:Sc=\:Sc \let\sv:sect=\@sect \let\sv:ssect=\@ssect
-_-_-
<..recall Sc, sec, ssec..>
\let\:Sc=\sv:Sc \let\@sect=\sv:sect \let\@ssect=\sv:ssect
-_-_-
<..latex ltsect..>+
\pend:defI\@hangfrom{\a:@hangfrom}
\append:defI\@hangfrom{\b:@hangfrom}
\NewConfigure{@hangfrom}{2}
-_-_-