Forum


Replies: 2   Views: 655
Importing html with more than 10 mathml/equation equations
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by rjharrison  · 24-10-2022 - 16:28

        $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;

 

 

Posted by admin  · 24-10-2022 - 16:36

Hello,

Thanks for your feedback. The same change has been added in the testing branch to be included in the stable release.

As you details, it only happens in Premium licenses with HTML Extended set as true when the same HTML to be imported includes more than 10 equations.

Regards.

Posted by peteruser1  · 29-10-2022 - 16:37

Deleted by admin · 30-10-2022 - 08:19