@michal.h21 Ok, I can reproduce the same problem, using this now:
make4ht --lua -u -e ./main.mk4 KERNEL.tex
where main.mk4 is the one I showed above, and I am using
\begin{document}
\ifdefined\HCode
\Configure{Picture}{.svg}
\fi
The math starts ok, then it gets corrupted after few pages. I have to make another MWE now which uses main.mk4 as the one I posted did not use it. So need more time.