Dear Francis,
Thanks for your very prompt reply. Changing the catcode solves the problem. You
have also answered my next question, which was going to be about the right way
to configure MathJax. (I currently post-process the HTML files.)
I am glad it helped you.
In fact, the way I define macros etc. for use in MathJax is like this:
\(
\newcommand{\gc}[1]{\boldsymbol{#1}}
\)%
and I reconfigure MathJax to load the newcommand package. I think that
the TeX4ht code that outputs \(...\) etc. essentially verbatim should
output # verbatim as well instead of doubling it as at present, and
that perhaps modifying \alteqtoks would be the way to do that. I'll
experiment with this.
Yes, it should be possible to replace # in \alteqtoks using the l3regex.
I think you can also use the catcode trick in this case. It is even
simpler, as you can use the groups to limit the catcode change just to
your macro definitions:
\begingroup
\catcode`\#=11
\(
\newcommand{\gc}[1]{\boldsymbol{#1}}
\gc{a}
\)%
\endgroup
Best regards,
Michal