From d27f9df1c8ab18ff8dd14dc5875365cf44e65576 Mon Sep 17 00:00:00 2001 From: Sami Mussbach Date: Thu, 21 Dec 2017 21:39:41 +0100 Subject: [PATCH 01/11] at least do not silently swallow any formatted text in lists (cherry picked from commit 5ceb189) --- src/PhpWord/Shared/Html.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index 38d326c1fa..00c771ff8d 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -396,13 +396,15 @@ private static function parseListItem($node, $element, &$styles, $data) if (!empty($cNodes)) { $text = ''; foreach ($cNodes as $cNode) { - if ($cNode->nodeName == '#text') { - $text = $cNode->nodeValue; + // at least do not silently swallow any formatted text in lists + $types = array('#text', 'strong', 'em', 'span'); + if (in_array($cNode->nodeName, $types)) { + $text .= $cNode->nodeValue; } } //ideally we should be parsing child nodes for any style, for now just take the text if ('' == trim($text) && '' != trim($node->textContent)) { - $text = trim($node->textContent); + $text .= trim($node->textContent); } $element->addListItem($text, $data['listdepth'], $styles['font'], $styles['list'], $styles['paragraph']); } From 812cc5ba3e10328dd8199ceee106f24687002277 Mon Sep 17 00:00:00 2001 From: Sami Mussbach Date: Sat, 6 Jan 2018 22:12:46 +0100 Subject: [PATCH 02/11] provide test for missing text in lists with format (cherry picked from commit f406ad0) --- tests/PhpWord/Shared/HtmlTest.php | 33 ++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/tests/PhpWord/Shared/HtmlTest.php b/tests/PhpWord/Shared/HtmlTest.php index c7d3647010..f72aa93050 100644 --- a/tests/PhpWord/Shared/HtmlTest.php +++ b/tests/PhpWord/Shared/HtmlTest.php @@ -217,10 +217,11 @@ public function testParseList() $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection(); $html = '