I am trying to output html to word using phpWord. However, something is weird. It works fine for the following code:
$content = '';
$content .= '<table><tr><th>Header</th><td>Content</td></tr></table>';
$content .= '<ul><li>Bullet</li><ul><li>Bullet</li></ul></ul>';
$content .= '<ol><li>Bullet</li></ol>';
Html::addHtml($newSection, $content);
But does not work for this:
$content = '';
$content .= '<table><tr><th>Header</th><td>Content</td></tr></table>';
$content .= '<p>Bullet</p>';
$content .= '<p>Cat</p>';
Html::addHtml($newSection, $content);
and produces the error mentioned on the title.
UPDATE
This error is generated from this file: \vendor\phpoffice\phpword\src\PhpWord\Shared\Html.php
In this method:
private static function parseChildNodes($node, $element, $styles, $data)
{
if ('li' != $node->nodeName) {
$cNodes = $node->childNodes;
if (count($cNodes) > 0) {
foreach ($cNodes as $cNode) {
if ($element instanceof AbstractContainer) {
self::parseNode($cNode, $element, $styles, $data);
}
}
}
}
}
But it only happens when using the <p>
html tag and it's fine with all other tags.
I also came across this link: addHtml() does not support tags inside list tags. #521