>> while there certainly can/will be problems, this error here seems to be >> unrelated to \DocumentMetadata. I get an error with make4ht also for this: >>
> thanks for this example. You are right. It seems that packages added > in \AddToHook{begindocument/before} or \AtBeginDocument are ignored > too. It is strange because I thought .4ht files captured them, but > they are not. > I was able to fix these hooks issues by manually calling: > \ifdefined\UseHook > \UseHook {begindocument/before} > \UseHook {begindocument} > \RemoveFromHook{begindocument/before} > \RemoveFromHook{begindocument} > \fi This won't fix the error with \DocumentMetadata as the testphase code loads there amsmath not with the standard hooks but in our own hook: \tl_gput_right:Nn \@kernel@before@begindocument { \RequirePackage { amsmath } } (which doesn't look right, but moving it to \@kernel@after@begindocument@before doesn't work either). We could probably load amsmath earlier, but naturally the problem could reappear with other packages or code. > in redefinition of the \document command in tex4ht.sty. I wonder if it > wouldn't break something else, as in the original version of > \document, the begindocument hook is called much later, after setting > various variables. It can break some things in theory. However, the > variables are mainly related to line width and similar stuff, which > don't matter much in the conversion process. Well I know that rewriting such patches is hard, but this \document redefinition looks very fragile. Sadly I can't make a concrete suggestion how to change it as I have no idea what all the code is doing and what should come before and after other things. Ulrike