Date:
Thu, 23 Jul 2020 18:32:04 +0200
MIME-Version:
1.0
Content-Transfer-Encoding:
7bit
Content-Type:
text/plain; charset=utf-8; format=flowed
|
Am 23.07.20 um 09:07 schrieb Michal Hoftich:
> Hi all,
>
>> Inspired by issue #900 on the PGF/TikZ repo [1], I'd like to kick off
>> the discussion on how to correctly integrate the new hook management
>> system into existing LaTeX package codebases.
>
> I've just tested latex-dev with TeX4ht and I can confirm that it
> fatally crashes with latex-dev.
>
so it does, but then this isn't really surprising when looking at what
tex4ht patches and at what level.
I can't claim that I understand the details of what it does, I only
looked very briefly now.
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.
------------
So to get tex4ht back up and running again only a small change to
\document is necessary:
%FMi drop those lines from \document
%
% \expandafter\let\csname enddocument\endcsname\empty
% \end{document}%
Because of the double call to \begin{document} that leaves us with an
open group at the end of the document. So either we need to explicitly
close that group at end document, e.g.
\AddToHook{enddocument/end}{\endgroup}
or probably better make a second change in the \document redefinition
and add it there:
%FMi close the group started by \begin{document} on second call
% \let\document\o:document
\def\document{\endgroup\o:document}%
------------
Concerning the other issue in latex.4ht there is
\let\o:enddocumenthook\@enddocumenthook
\def\@enddocumenthook{\HtmlEnv
\Configure{newpage}{}%
\o:enddocumenthook
\at:docend \csname export:hook\endcsname }
and \@enddocumenthook isn't used any longer. So the redef goes to /dev/null
The idea here seems to be that
\HtmlEnv\Configure{newpage}{}%
should be before the content of \AtEndDocument and
\at:docend \csname export:hook\endcsname
A possible replacement therefore using the hook management would be
\AddToHook{env/document/end}
{\HtmlEnv\Configure{newpage}{}}
\AddToHook{enddocument/afterlastpage}
{\at:docend \csname export:hook\endcsname}
However this fails because tex4ht also overwrites the code for \begin
and \end and therefore the generic hooks env/... lost
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.
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.
frank
|
|
|