Forum


Replies: 2   Views: 563
Mathml in html code via embedhtml
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 apack  · 24-05-2023 - 13:12

Dear all,

I have Premium version 14 and want to embed HTML code that contains MathML via embedHMTL (actually upgraded only because of this MathML functionality). According to the documentation, this is included in the version 14 Premium package. My code is:

require_once '../phpdocx/classes/CreateDocx.php';
    $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>';    
    $docx = new CreateDocx();
    $docx->embedHTML($htmlString);

It inserts HTML code without problems, just the MathML is rendered as text. I tried with other MathML, which rendered correctly when displayed within website. Same with this MathML

require_once '../phpdocx/classes/CreateDocx.php';
    $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>';    
    $htmlString = '<p>This is now the equation</p><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"> <munderover> <mo data-mjx-texclass="OP">&#x2211;</mo> <mrow data-mjx-texclass="ORD"> <mi>i</mi> </mrow> <mrow data-mjx-texclass="ORD"></mrow> </munderover> <msub> <mi>F</mi> <mi>i</mi> </msub> <mo>&#x22C5;</mo> <mo stretchy="false">(</mo> <msup> <mi>&#x3B4;</mi> <mrow data-mjx-texclass="ORD"> <mn>18</mn> </mrow> </msup> <msubsup> <mtext>O</mtext> <mtext>VSMOW</mtext> <mi>i</mi> </msubsup> <mo>&#x2212;</mo> <msup> <mi>&#x3B4;</mi> <mrow data-mjx-texclass="ORD"> <mn>18</mn> </mrow> </msup> <msubsup> <mtext>O</mtext> <mtext>VSMOW</mtext> <mtext>air</mtext> </msubsup> <mo stretchy="false">)</mo> <mo>=</mo> <mn>0</mn> </math>';
    $docx = new CreateDocx();
    $docx->embedHTML($htmlString);

Has anyone the same experience?

Andy