From 00bc15e39db35b78950b0e8afe73126e0692b947 Mon Sep 17 00:00:00 2001 From: Patrick Brouwers Date: Tue, 14 Mar 2017 15:42:41 +0100 Subject: [PATCH] Support em/bold in line-items --- src/PhpWord/Shared/Html.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index 13b5375e13..72a8e23838 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -341,13 +341,23 @@ private static function parseListItem($node, $element, &$styles, $data) { $cNodes = $node->childNodes; if (count($cNodes) > 0) { - $text = ''; + $text = []; + + $listItemRun = $element->addListItemRun($data['listdepth'], $styles['list'], $styles['paragraph']); + + $fontStyle = $styles['font']; foreach ($cNodes as $cNode) { if ($cNode->nodeName == '#text') { - $text = $cNode->nodeValue; + $listItemRun->addText($cNode->nodeValue, $fontStyle); + } elseif($cNode->nodeName == 'em') { + $fontStyle['italic'] = true; + $listItemRun->addText($cNode->nodeValue, $fontStyle); + } + elseif($cNode->nodeName == 'strong') { + $fontStyle['bold'] = true; + $listItemRun->addText($cNode->nodeValue, $fontStyle); } } - $element->addListItem($text, $data['listdepth'], $styles['font'], $styles['list'], $styles['paragraph']); } return null;