Hello,
You need to enable the useHTMLExtended option, that is available in Premium packages.
For example:
$html = '<p>A math equation using MathML:</p><math xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>A</mi><mo>=</mo></mrow></math><p>Paragraph after the math equation.</p>';
$docx->embedHTML($html, array('useHTMLExtended' => true));
HTML Extended and CSS Extended requires enabling this option.
Also please avoid escaping " when adding HTML contents. Instead of:
$htmlString = '<p>A math equation using MathML:</p><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><mrow><mi>A</mi><mo>=</mo></mrow></math><p>Paragraph after the math equation.</p>';
use:
$htmlString = '<p>A math equation using MathML:</p><math xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>A</mi><mo>=</mo></mrow></math><p>Paragraph after the math equation.</p>';
On https://www.phpdocx.com/documentation/introduction/html-extended-to-word-PHP you can read more information this feature.
We also recommend you check the samples included in the package. In the Core/embedHTML folder you can find many sample scripts using HTML Extended and CSS Extended.
Regards.