Hi Franks, thank you for your suggestions and fixes. It seems that it works correctly. > But basically the main issue is that in the old LaTeX \document started > out with \endgroup to cancel the \begingroup issued by \begin > > As \begin now offers hooks this \endgroup has moved into \begin to avoid > that the hook code is not canceled by the end of the group. > > The second issue is that the tex4ht calls \begin{document} inside > \begin{document} again. There is also a call to \end{document} inside > \document which doesn't do much other than breaking now. > > Furthermore LaTeX's enddocument hook is directly modified (and not > through \AtEndDocument and that fails because it is below the official > interfaces. > > %FMi close the group started by \begin{document} on second call > % \let\document\o:document > \def\document{\endgroup\o:document}% Yes, this works for now, thank you. > So without correcting/updating the redefinitions for \begin \end it has > to be > > \AddToHook{enddocument} > {\HtmlEnv\Configure{newpage}{}} > \AddToHook{enddocument/afterlastpage} > {\at:docend \csname export:hook\endcsname} > > > ------------------ > > with that everything seems to be working. > This results in missing HTML footer in the last generated HTML file. Fortunately, \AddToHook{enddocument} {\HtmlEnv\Configure{newpage}{}\at:docend \csname export:hook\endcsname} works. > However, a lot of the lowlevel patching code inside tex4ht seems to be > only necessary because environment hooks are not available, so after > adjusting \begin and \end to use the kernel definitions it should be > possible to simplify a lot by simply using appropriate "env/foo/before" > and "env/foo/after" hooks. I hope it will be relatively easy to adapt our environment patching routine to the new LaTeX hook system. It should definitely simplify lot of the low-level code. Thanks again for all your comments and code. Michal