I use cprotect package so I can use math in section titles. It works OK in pdf, but tex4ht generates strange characters at end of section title.
If I do not use cprotect, then it will not compile in tex4ht.
Is there a way around this? MWE
\documentclass[12pt,notitlepage]{book}
\usepackage{cprotect}
\usepackage{amsmath}
\begin{document}
\title{my book}
\chapter{Listing of integrals}
\cprotect\section{\quad $\int e^x \left(1-x^3+x^4-x^5+x^6\right) \, dx$}
stuff
\cprotect\section{\quad $\int \frac{e^{\frac{x}{2+x^2}} \left(2-x^2\right)}{2 x+x^3} \, dx$}
text
\end{document}
Compiled using
make4ht -ulm default -a debug t.tex "htm,3,mathjax,notoc*,p-width"
gives
If I do not use \cprotect then it gives compile error.
(/usr/local/texlive/2019/texmf-dist/tex/generic/tex4ht/html5.4ht))
(./report.aux) (/usr/local/texlive/2019/texmf-dist/tex/latex/base/ts1cmr.fd)
[1] [2]
Chapter 1.
(./report.4ct (./report-1.cpt) (./report-2.cpt))
(/usr/local/texlive/2019/texmf-dist/tex/latex/lm/ot1lmtt.fd)
! Argument of \im:g has an extra }.
<inserted text>
\par
l.9 ...nt e^x \left(1-x^3+x^4-x^5+x^6\right) \, dx$}
?
Important Please note that the math itself used in section titles in auto-generated by computer algebra system and I did not write the math. A large program runs which read these math equations and use each for section titles. So editing the math is not possible or practical.
TL 2019



cprotectpackage and your example runs without error in pdflatex, so it doesn't seem to be doing anything in recent latex releases. So I would simplify the markup not to use that and then look to get tex4ht to understand if that fails\cprotect\leftand\right, then it seems to work OK, and be more correct markup.