I would base the code on the newer answer. The second seems obsolete. It just needs a fix for equations, they cause the compilation error. Other than that, it mostly works. Except for $$ ... $$
math, I cannot find a correct solution.
Here is the updated config file:
\Preamble{xhtml,mathml,mathjax}
\newtoks\mmleqtoks
\ExplSyntaxOn
\cs_new_protected:Npn \mmlalteqtoks #1
{
% save tokens, but preserve spaces
% https://tex.stackexchange.com/a/44444/2891
\tl_set:Nn \l_tmpa_tl {#1}
\regex_replace_all:nnN { . } { \c{string} \0 } \l_tmpa_tl
\tl_set:Nx \l_tmpa_tl { \l_tmpa_tl }
% % replace < > and & with xml entities
\regex_replace_all:nnN { \x{26} } { & } \l_tmpa_tl
\regex_replace_all:nnN { \x{3C} } { < } \l_tmpa_tl
\regex_replace_all:nnN { \x{3E} } { > } \l_tmpa_tl
% \regex_replace_all:nnN { \n } {\HCode{ \Hnewline }} \l_tmpa_tl
% replace \par command with blank lines
\regex_replace_all:nnN { \x{5C}par\b } {\x{A}\x{A}} \l_tmpa_tl
\tl_set:Nx \mmleqtoks{ \l_tmpa_tl }
%\HCode{\l_tmpb_tl}
}
\ExplSyntaxOff
\catcode`\:=11
\def\AltMath#1${\mmlalteqtoks{#1}%
#1\HCode{</\a:mathml mrow><\a:mathml annotation encoding="application/x-tex">\mmleqtoks</\a:mathml annotation>}$}
\Configure{$}{\Configure{@math}{display="inline"}\DviMath\HCode{<\a:mathml semantics><\a:mathml mrow>}}{\HCode{</\a:mathml semantics>}\EndDviMath}{\expandafter\AltMath}
\def\AltMathParen#1\){\mmlalteqtoks{#1}%
#1\HCode{</\a:mathml mrow><a\a:mathml nnotation encoding="application/x-tex">\mmleqtoks</\a:mathml annotation>}$}
\def\AltMathParen#1\){\mmlalteqtoks{#1}#1\HCode{</\a:mathml mrow><\a:mathml annotation encoding="application/x-tex">\mmleqtoks</\a:mathml annotation>}\)}
%\Configure{()}{\Configure{@math}{display="inline"}\DviMath\HCode{<\a:mathml semantics><\a:mathml mrow>}\AltMathParen$}{\EndDviMath\HCode{</\a:mathml semantics>}}
\Configure{()}
{\Configure{@math}{%\a:mathml
display="inline"
}\csname a:mathml()\endcsname
\DviMath\HCode{<\a:mathml semantics><\a:mathml mrow>}$\expandafter\AltMathParen}
{$\HCode{</\a:mathml semantics>}\EndDviMath\csname b:mathml()\endcsname}
\long\def\AltDisplay#1\]{\mmlalteqtoks{#1}#1\HCode{</\a:mathml mrow><\a:mathml annotation encoding="application/x-tex">\mmleqtoks</\a:mathml annotation></\a:mathml semantics>}\]}
\Configure{[]}{\Configure{@math}{display="block"}\DviMath$$\DisplayMathtrue\HCode{<\a:mathml semantics><\a:mathml mrow>}\AltDisplay}{$$\EndDviMath}
\long\def\AltlDisplayDollars#1$${\mmlalteqtoks{\[#1\]}#1\HCode{</\a:mathml mrow><\a:mathml annotation encoding="application/x-tex">\mmleqtoks</\a:mathml annotation>}$$}
\Configure{$$}
{\Configure{@math}{%\a:mathml
display="block"
}\IgnorePar
\ifvmode\else \HCode{<!--tex4ht:inline-->}\fi
\EndP\DviMath\HCode{<\a:mathml semantics><\a:mathml mrow>}}
{\HCode{</\a:mathml semantics>}\EndDviMath\ShowPar\par{\csname HCondtrue\endcsname\noindent}}
{\DisplayMathtrue\expandafter\AltlDisplayDollars}
\renewcommand\eqannotate[1]{\mmlalteqtoks{#1}\HCode{<\a:mathml semantics><\a:mathml mrow>}#1\HCode{</\a:mathml mrow><\a:mathml annotation encoding="application/x-tex">\mmleqtoks</\a:mathml annotation></\a:mathml semantics>}}
% environment support
\newcommand\MMLVerbMathToks[2]{%
\mmlalteqtoks{\begin{#2}
#1
\end{#2}}%
\begingroup%
\ifvmode\IgnorePar\fi\EndP\Configure{@math}{display="block"}\DviMath\DisplayMathtrue\HCode{<\a:mathml semantics><\a:mathml mrow>}
\Configure{$$}{}{}{}
\begin{old#2}
#1
\end{old#2}
\HCode{</\a:mathml mrow><\a:mathml annotation encoding="application/x-tex">}
\HCode{\mmleqtoks}
\HCode{</\a:mathml annotation></\a:mathml semantics>}
\EndDviMath
\endgroup
}
\makeatletter
% we must handle equations separatelly.
% it is a bit messy
\newcommand\MMLVerbMathToksEquation[2]{%
\mmlalteqtoks{\begin{#2}
#1
\end{#2}}%
\begingroup%
\def\@tempa{#2}%
\def\@equationname{equation}%
\def\mlabeledtr{mtr}
\ifx\@equationname\@tempa%
\def\mlabeledtr{mlabeledtr} % this element can be used to print the equation number, but it is supported only by MathJax
\fi
\ifvmode\IgnorePar\fi\EndP\Configure{@math}{display="block"}\DviMath\DisplayMathtrue\HCode{<\a:mathml semantics><\a:mathml mrow><\a:mathml mtable><\a:mathml \mlabeledtr><\a:mathml mtd>}%
\ifx\@equationname\@tempa%
\incr@eqnum%
\print@eqnum%
\HCode{</\a:mathml mtd><\a:mathml mtd>}%
\fi
#1%
\HCode{</\a:mathml mtd></\a:mathml \mlabeledtr></\a:mathml mtable></\a:mathml mrow><\a:mathml annotation encoding="application/x-tex">}%
\HCode{\mmleqtoks}%
\HCode{</\a:mathml annotation></\a:mathml semantics>}%
\EndDviMath%
\endgroup%
}
\makeatother
\catcode`\:=12
\ExplSyntaxOn
\newcommand\MMLVerbMath[1]{%
\cs_if_exist:cTF{#1}{
\expandafter\let\csname old#1\expandafter\endcsname\csname #1\endcsname
\expandafter\let\csname endold#1\expandafter\endcsname\csname end#1\endcsname
\RenewDocumentEnvironment{#1}{+!b}{%
\NoFonts\expandafter\MMLVerbMathToks\expandafter{##1}{#1}\EndNoFonts%
}{}
}{}%
}
\newcommand\MMLVerbEquation[1]{%
\cs_if_exist:cTF{#1}{
\expandafter\let\csname old#1\expandafter\endcsname\csname #1\endcsname
\expandafter\let\csname endold#1\expandafter\endcsname\csname end#1\endcsname
\RenewDocumentEnvironment{#1}{+!b}{%
\NoFonts\expandafter\MMLVerbMathToksEquation\expandafter{##1}{#1}\EndNoFonts%
}{}
}{}%
}
\ExplSyntaxOff
\begin{document}
\MMLVerbMath{subarray}
\MMLVerbMath{smallmatrix}
\MMLVerbMath{matrix}
\MMLVerbMath{pmatrix}
\MMLVerbMath{bmatrix}
\MMLVerbMath{Bmatrix}
\MMLVerbMath{vmatrix}
\MMLVerbMath{Vmatrix}
\MMLVerbMath{cases}
\MMLVerbMath{subequations}
\MMLVerbMath{aligned}
\MMLVerbMath{alignedat}
\MMLVerbMath{gathered}
\MMLVerbMath{gather}
\MMLVerbMath{gather*}
\MMLVerbMath{alignat}
\MMLVerbMath{alignat*}
\MMLVerbMath{xalignat}
\MMLVerbMath{xalignat*}
\MMLVerbMath{xxalignat}
\MMLVerbMath{align}
\MMLVerbMath{align*}
\MMLVerbMath{flalign}
\MMLVerbMath{flalign*}
\MMLVerbMath{split}
\MMLVerbMath{multline}
\MMLVerbMath{multline*}
\MMLVerbEquation{equation}
\MMLVerbEquation{equation*}
\MMLVerbMath{math}
\MMLVerbMath{displaymath}
\MMLVerbMath{eqnarray}
\MMLVerbMath{eqnarray*}
\EndPreamble
This is the result:
<!DOCTYPE html>
<html lang='en-US' xml:lang='en-US'>
<head> <title></title>
<meta charset='utf-8' />
<meta content='TeX4ht (https://tug.org/tex4ht/)' name='generator' />
<meta content='width=device-width,initial-scale=1' name='viewport' />
<link href='sample.css' rel='stylesheet' type='text/css' />
<meta content='sample.tex' name='src' />
<script async='async' id='MathJax-script' src='https://cdn.jsdelivr.net/npm/mathjax@3/es5/mml-chtml.js' type='text/javascript'></script>
</head><body>
<!-- l. 10 --><p class='noindent'>Inline math <!-- l. 10 --><math display='inline' xmlns='http://www.w3.org/1998/Math/MathML'><semantics><mrow><mi>a</mi> <mo class='MathClass-bin' stretchy='false'>+</mo> <mi>b</mi> <mo class='MathClass-rel' stretchy='false'>=</mo> <mi>c</mi></mrow><annotation encoding='application/x-tex'>a+b=c</annotation></semantics></math>
</p><!-- l. 12 --><p class='indent'> Display equation with doble dollar
<!-- tex4ht:inline --></p><!-- l. 13 --><math display='block' xmlns='http://www.w3.org/1998/Math/MathML'><mrow>
<mi>a</mi> <mo class='MathClass-bin' stretchy='false'>+</mo> <mi>b</mi> <mo class='MathClass-rel' stretchy='false'>=</mo> <mi>c</mi>
</mrow></math>
<!-- l. 15 --><p class='nopar'>
</p><!-- l. 18 --><p class='indent'> <!-- l. 18 --><math display='block' xmlns='http://www.w3.org/1998/Math/MathML'><mrow>
<semantics><mrow><mi>a</mi> <mo class='MathClass-bin' stretchy='false'>+</mo> <mi>b</mi> <mo class='MathClass-rel' stretchy='false'>=</mo> <mi>c</mi></mrow><annotation encoding='application/x-tex'> a+b=c </annotation></semantics>
</mrow></math>
</p><!-- l. 22 --><p class='indent'> Display equation (equation env) </p><!-- l. 25 --><math display='block' xmlns='http://www.w3.org/1998/Math/MathML'><semantics><mrow><mtable><mlabeledtr><mtd><mstyle class='label' id='x1-2r1'></mstyle><!-- endlabel --><mstyle class='maketag'><mtext>(1)</mtext></mstyle><mspace class='nbsp' width='0.33em'></mspace></mtd><mtd> <mi>x</mi><mo class='MathClass-bin' stretchy='false'>+</mo><mi>y</mi><mo class='MathClass-rel' stretchy='false'>=</mo><mn>1</mn> </mtd></mlabeledtr></mtable></mrow><annotation encoding='application/x-tex'>\begin {equation} x+y=1 \end {equation}</annotation></semantics></math>
<!-- l. 27 --><p class='indent'> Display equation (equation* env) </p><!-- l. 30 --><math display='block' xmlns='http://www.w3.org/1998/Math/MathML'><semantics><mrow><mtable><mtr><mtd> <mi>x</mi><mo class='MathClass-bin' stretchy='false'>+</mo><mi>y</mi><mo class='MathClass-rel' stretchy='false'>=</mo><mi>z</mi> </mtd></mtr></mtable></mrow><annotation encoding='application/x-tex'>\begin {equation*} x+y=z \end {equation*}</annotation></semantics></math>
<!-- l. 32 --><p class='indent'> eqnarray environment </p><!-- l. 35 --><math display='block' xmlns='http://www.w3.org/1998/Math/MathML'><mrow><semantics><mrow>
<mtable class='eqnarray' columnalign='right center left' displaystyle='true'>
<mtr><mtd class='eqnarray-1'> <mi>x</mi> <mo class='MathClass-bin' stretchy='false'>+</mo> <mi>y</mi> <mo class='MathClass-rel' stretchy='false'>=</mo> <mn>1</mn></mtd><mtd class='eqnarray-2'> </mtd><mtd class='eqnarray-3'> </mtd><mtd class='eqnarray-4'> <mtext class='eqnarray'>(2)</mtext><mtext class='label' id='x1-3r'></mtext><mtext class='endlabel'></mtext></mtd> </mtr></mtable>
</mrow><annotation encoding='application/x-tex'> \begin {eqnarray} x+y=1 \end {eqnarray} </annotation></semantics> </mrow></math>
<!-- l. 37 --><p class='indent'> display equation <!-- l. 38 --><math display='block' xmlns='http://www.w3.org/1998/Math/MathML'><mrow>
<semantics><mrow><mi>d</mi> <mo class='MathClass-bin' stretchy='false'>+</mo> <mi>f</mi> <mo class='MathClass-rel' stretchy='false'>=</mo> <mi>g</mi></mrow><annotation encoding='application/x-tex'> d+f=g </annotation></semantics>
</mrow></math>
</p><!-- l. 42 --><p class='indent'> we revealed a universal physical behaviour in the
experimentally observed binding of two well-characterized NTRs,
</p><!-- l. 46 --><math display='block' xmlns='http://www.w3.org/1998/Math/MathML'><mrow><semantics><mrow>
<!-- tex4ht:inline --><mrow><mtable class='align' columnalign='left' displaystyle='true'>
<mtr><mtd class='align-odd' columnalign='right'><msup><mrow><mi>W</mi></mrow><mrow><mo class='MathClass-open' stretchy='false'>(</mo><mi>i</mi><mo class='MathClass-close' stretchy='false'>)</mo></mrow></msup><mo class='MathClass-open' stretchy='false'>(</mo><mi>z</mi><mo class='MathClass-close' stretchy='false'>)</mo></mtd> <mtd class='align-even'> <mo class='MathClass-rel' stretchy='false'>=</mo> <msup><mrow><mi>c</mi></mrow><mrow><mo class='MathClass-open' stretchy='false'>(</mo><mi>i</mi><mo class='MathClass-close' stretchy='false'>)</mo></mrow></msup><mo class='MathClass-open' stretchy='false'>(</mo><mi>z</mi><mo class='MathClass-close' stretchy='false'>)</mo> <mo class='MathClass-bin' stretchy='false'>+</mo> <msubsup><mrow><mi>V</mi> </mrow><mrow>
<mi mathvariant='italic'>ext</mi></mrow><mrow><mo class='MathClass-open' stretchy='false'>(</mo><mi>i</mi><mo class='MathClass-close' stretchy='false'>)</mo></mrow></msubsup><mo class='MathClass-open' stretchy='false'>(</mo><mi>z</mi><mo class='MathClass-close' stretchy='false'>)</mo> <mo class='MathClass-bin' stretchy='false'>+</mo><mo> ∫
<!-- nolimits --></mo><!-- nolimits --><msup><mrow><mi>ρ</mi></mrow><mrow><mo class='MathClass-open' stretchy='false'>(</mo><mn>3</mn><mo class='MathClass-close' stretchy='false'>)</mo></mrow></msup><mo class='MathClass-open' stretchy='false'>(</mo><mi>z</mi><mo class='MathClass-close' stretchy='false'>)</mo><msup><mrow><mi>u</mi></mrow><mrow><mo class='MathClass-open' stretchy='false'>(</mo><mi>i</mi><mo class='MathClass-close' stretchy='false'>)</mo></mrow></msup><mo class='MathClass-open' stretchy='false'>(</mo><mi>z</mi> <mo class='MathClass-bin' stretchy='false'>−</mo> <msup><mrow><mi>z</mi></mrow><mrow><mi>′</mi></mrow></msup><mo class='MathClass-close' stretchy='false'>)</mo><mstyle class='text'><mtext class='textrm' mathvariant='normal'>d</mtext></mstyle><msup><mrow><mi>z</mi></mrow><mrow><mi>′</mi></mrow></msup><mo class='MathClass-bin' stretchy='false'>−</mo> <msup><mrow><mi>μ</mi></mrow><mrow><mo class='MathClass-open' stretchy='false'>(</mo><mi>i</mi><mo class='MathClass-close' stretchy='false'>)</mo></mrow></msup><mo class='MathClass-punc' stretchy='false'>,</mo><mspace width='2em'></mspace></mtd> <mtd class='align-label' columnalign='right'></mtd> <mtd class='align-label'>
<mspace width='2em'></mspace></mtd></mtr><mtr><mtd class='align-odd' columnalign='right'></mtd> <mtd class='align-even'> <mo class='MathClass-rel' stretchy='false'>≈</mo><mo class='MathClass-bin' stretchy='false'>−</mo><msub><mrow><mi>k</mi></mrow><mrow><mstyle class='text'><mtext class='textrm' mathvariant='normal'>B</mtext></mstyle></mrow></msub><mi>T</mi><mi class='qopname'>ln</mi><mo> <!-- FUNCTION APPLICATION --> </mo><!-- nolimits --> <mrow><mo fence='true' form='prefix'> (</mo><mrow> <mfrac><mrow><msup><mrow><mi>ρ</mi></mrow><mrow><mo class='MathClass-open' stretchy='false'>(</mo><mi>i</mi><mo class='MathClass-close' stretchy='false'>)</mo></mrow></msup><mo class='MathClass-open' stretchy='false'>(</mo><mi>z</mi><mo class='MathClass-close' stretchy='false'>)</mo></mrow>
<mrow><msubsup><mrow><mi>ρ</mi></mrow><mrow><mstyle class='text'><mtext class='textrm' mathvariant='normal'>bulk</mtext></mstyle></mrow><mrow><mo class='MathClass-open' stretchy='false'>(</mo><mi>i</mi><mo class='MathClass-close' stretchy='false'>)</mo></mrow></msubsup></mrow></mfrac> </mrow><mo fence='true' form='postfix'>)</mo></mrow> <mo class='MathClass-punc' stretchy='false'>,</mo><mspace width='2em'></mspace></mtd> <mtd class='align-label' columnalign='right'><mstyle class='label' id='x1-4r3'></mstyle><!-- endlabel --><mstyle class='maketag'><mtext>(3)</mtext></mstyle><mspace class='nbsp' width='0.33em'></mspace> </mtd></mtr></mtable></mrow>
</mrow><annotation encoding='application/x-tex'> \begin {align} W^{(i)}(z) &= c^{(i)}(z) + V_{ext}^{(i)}(z) + \int \rho ^{(3)}(z) u^{(i)}(z-z')\textrm {d}z' - \mu ^{(i)} \nonumber , \\ & \approx - k_{\textrm {B}}T \ln \left ( \frac {\rho ^{(i)}(z)}{\rho ^{(i)}_{\textrm {bulk}}} \right ), \end {align} </annotation></semantics> </mrow></math>
<!-- l. 48 --><p class='noindent'>Was Further validated by a minimal physical model that treated the FG
Nups as flexible homopolymers the NTRs as uniformly cohesive spheres.
</p><!-- l. 52 --><math display='block' xmlns='http://www.w3.org/1998/Math/MathML'><mrow><semantics><mrow>
<!-- tex4ht:inline --><mrow><mtable class='align-star' columnalign='left' displaystyle='true'>
<mtr><mtd class='align-odd' columnalign='right'><msup><mrow><mi>W</mi></mrow><mrow><mo class='MathClass-open' stretchy='false'>(</mo><mi>i</mi><mo class='MathClass-close' stretchy='false'>)</mo></mrow></msup><mo class='MathClass-open' stretchy='false'>(</mo><mi>z</mi><mo class='MathClass-close' stretchy='false'>)</mo></mtd> <mtd class='align-even'> <mo class='MathClass-rel' stretchy='false'>=</mo> <msup><mrow><mi>c</mi></mrow><mrow><mo class='MathClass-open' stretchy='false'>(</mo><mi>i</mi><mo class='MathClass-close' stretchy='false'>)</mo></mrow></msup><mo class='MathClass-open' stretchy='false'>(</mo><mi>z</mi><mo class='MathClass-close' stretchy='false'>)</mo> <mo class='MathClass-bin' stretchy='false'>+</mo> <msubsup><mrow><mi>V</mi> </mrow><mrow>
<mi mathvariant='italic'>ext</mi></mrow><mrow><mo class='MathClass-open' stretchy='false'>(</mo><mi>i</mi><mo class='MathClass-close' stretchy='false'>)</mo></mrow></msubsup><mo class='MathClass-open' stretchy='false'>(</mo><mi>z</mi><mo class='MathClass-close' stretchy='false'>)</mo> <mo class='MathClass-bin' stretchy='false'>+</mo><mo> ∫
<!-- nolimits --></mo><!-- nolimits --><msup><mrow><mi>ρ</mi></mrow><mrow><mo class='MathClass-open' stretchy='false'>(</mo><mn>3</mn><mo class='MathClass-close' stretchy='false'>)</mo></mrow></msup><mo class='MathClass-open' stretchy='false'>(</mo><mi>z</mi><mo class='MathClass-close' stretchy='false'>)</mo><msup><mrow><mi>u</mi></mrow><mrow><mo class='MathClass-open' stretchy='false'>(</mo><mi>i</mi><mo class='MathClass-close' stretchy='false'>)</mo></mrow></msup><mo class='MathClass-open' stretchy='false'>(</mo><mi>z</mi> <mo class='MathClass-bin' stretchy='false'>−</mo> <msup><mrow><mi>z</mi></mrow><mrow><mi>′</mi></mrow></msup><mo class='MathClass-close' stretchy='false'>)</mo><mstyle class='text'><mtext class='textrm' mathvariant='normal'>d</mtext></mstyle><msup><mrow><mi>z</mi></mrow><mrow><mi>′</mi></mrow></msup><mo class='MathClass-bin' stretchy='false'>−</mo> <msup><mrow><mi>μ</mi></mrow><mrow><mo class='MathClass-open' stretchy='false'>(</mo><mi>i</mi><mo class='MathClass-close' stretchy='false'>)</mo></mrow></msup><mo class='MathClass-punc' stretchy='false'>,</mo><mspace width='2em'></mspace></mtd> <mtd class='align-label' columnalign='right'></mtd> <mtd class='align-label'>
<mspace width='2em'></mspace></mtd></mtr><mtr><mtd class='align-odd' columnalign='right'></mtd> <mtd class='align-even'> <mo class='MathClass-rel' stretchy='false'>≈</mo><mo class='MathClass-bin' stretchy='false'>−</mo><msub><mrow><mi>k</mi></mrow><mrow><mstyle class='text'><mtext class='textrm' mathvariant='normal'>B</mtext></mstyle></mrow></msub><mi>T</mi><mi class='qopname'>ln</mi><mo> <!-- FUNCTION APPLICATION --> </mo><!-- nolimits --> <mrow><mo fence='true' form='prefix'> (</mo><mrow> <mfrac><mrow><msup><mrow><mi>ρ</mi></mrow><mrow><mo class='MathClass-open' stretchy='false'>(</mo><mi>i</mi><mo class='MathClass-close' stretchy='false'>)</mo></mrow></msup><mo class='MathClass-open' stretchy='false'>(</mo><mi>z</mi><mo class='MathClass-close' stretchy='false'>)</mo></mrow>
<mrow><msubsup><mrow><mi>ρ</mi></mrow><mrow><mstyle class='text'><mtext class='textrm' mathvariant='normal'>bulk</mtext></mstyle></mrow><mrow><mo class='MathClass-open' stretchy='false'>(</mo><mi>i</mi><mo class='MathClass-close' stretchy='false'>)</mo></mrow></msubsup></mrow></mfrac> </mrow><mo fence='true' form='postfix'>)</mo></mrow> <mo class='MathClass-punc' stretchy='false'>,</mo><mspace width='2em'></mspace></mtd> <mtd class='align-label' columnalign='right'></mtd> <mtd class='align-label'><mspace width='2em'></mspace></mtd></mtr></mtable></mrow>
</mrow><annotation encoding='application/x-tex'> \begin {align*} W^{(i)}(z) &= c^{(i)}(z) + V_{ext}^{(i)}(z) + \int \rho ^{(3)}(z) u^{(i)}(z-z')\textrm {d}z' - \mu ^{(i)} \nonumber , \\ & \approx - k_{\textrm {B}}T \ln \left ( \frac {\rho ^{(i)}(z)}{\rho ^{(i)}_{\textrm {bulk}}} \right ), \end {align*} </annotation></semantics> </mrow></math>
</body>
</html>