$html = '
<p>Work out the vector <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle displaystyle="true"><mover><mrow><mi>A</mi><mi>D</mi></mrow><mo>→</mo></mover></mstyle></math></p>
<p>Work out the vector <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle displaystyle="true"><mover><mrow><mi>B</mi><mi>D</mi></mrow><mo>→</mo></mover></mstyle></math></p>
<p>Work out the vector <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle displaystyle="true"><mover><mrow><mi>C</mi><mi>D</mi></mrow><mo>→</mo></mover></mstyle></math></p>
<p>Work out the vector <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle displaystyle="true"><mover><mrow><mi>D</mi><mi>D</mi></mrow><mo>→</mo></mover></mstyle></math></p>
<p>Work out the vector <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle displaystyle="true"><mover><mrow><mi>E</mi><mi>D</mi></mrow><mo>→</mo></mover></mstyle></math></p>
<p>Work out the vector <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle displaystyle="true"><mover><mrow><mi>F</mi><mi>D</mi></mrow><mo>→</mo></mover></mstyle></math></p>
<p>Work out the vector <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle displaystyle="true"><mover><mrow><mi>G</mi><mi>D</mi></mrow><mo>→</mo></mover></mstyle></math></p>
<p>Work out the vector <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle displaystyle="true"><mover><mrow><mi>H</mi><mi>D</mi></mrow><mo>→</mo></mover></mstyle></math></p>
<p>Work out the vector <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle displaystyle="true"><mover><mrow><mi>I</mi><mi>D</mi></mrow><mo>→</mo></mover></mstyle></math></p>
<p>Work out the vector <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle displaystyle="true"><mover><mrow><mi>J</mi><mi>D</mi></mrow><mo>→</mo></mover></mstyle></math></p>
<p>Work out the vector <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle displaystyle="true"><mover><mrow><mi>K</mi><mi>D</mi></mrow><mo>→</mo></mover></mstyle></math></p>
<p>Work out the vector <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle displaystyle="true"><mover><mrow><mi>L</mi><mi>D</mi></mrow><mo>→</mo></mover></mstyle></math></p>';
$docx = new CreateDocx();
$docx->embedHTML($html, ['useHTMLExtended' => true]);
$docx->createDocx('output');
The bug is line 6436 of CreateDocx.php:
The str_replace for PHPDOCX_HTML_EQUATION_1 is also matching PHPDOCX_HTML_EQUATION11 and PHPDOCX_HTML_EQUAITON12 and so on.
I fixed it by adding a non-numerical suffix to the key, so that the searched for string is now "PHPDOCX_HTML_EQUATION_1_".
Lines 6267/8:
$html = str_replace($equation, 'PHPDOCX_HTML_EQUATION_'.$i_mathml.'_', $html); $nodesMathEquation['PHPDOCX_HTML_EQUATION_'.$i_mathml.'_'] = $equation;