Forum


Replies: 2   Views: 339
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 admin  · 24-05-2023 - 13:23

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.