Skip to content

Commit

Permalink
Support em/bold in line-items
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickbrouwers authored Mar 14, 2017
1 parent bf37cae commit 00bc15e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/PhpWord/Shared/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 00bc15e

Please sign in to comment.