Skip to content

Commit cd2bca8

Browse files
committed
trim parsed text and add whitespaces between text fragments
1 parent f406ad0 commit cd2bca8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/PhpWord/Shared/Html.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,19 +397,19 @@ private static function parseListItem($node, $element, &$styles, $data)
397397
// at least do not silently swallow any formatted text in lists
398398
$types = array('#text', 'strong', 'em', 'span');
399399
if (in_array($cNode->nodeName, $types)) {
400-
$text .= $cNode->nodeValue;
400+
$text .= ' ' . trim($cNode->nodeValue);
401401
}
402402

403403
//ideally we should be parsing child nodes for any style, for now just take the text
404404
if ('' == trim($text) && '' != trim($node->textContent)) {
405-
$text .= trim($node->textContent);
405+
$text .= ' ' . trim($node->textContent);
406406
}
407407
}
408408
//ideally we should be parsing child nodes for any style, for now just take the text
409409
if ('' == trim($text) && '' != trim($node->textContent)) {
410410
$text = trim($node->textContent);
411411
}
412-
$element->addListItem($text, $data['listdepth'], $styles['font'], $styles['list'], $styles['paragraph']);
412+
$element->addListItem(trim($text), $data['listdepth'], $styles['font'], $styles['list'], $styles['paragraph']);
413413
}
414414
}
415415

0 commit comments

Comments
 (0)