Skip to content

Commit

Permalink
Fix problem with linebreaks
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickbrouwers committed Feb 23, 2016
1 parent 2944c21 commit d97f9c8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/PhpWord/Shared/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ protected static function parseNode($node, $element, $styles = array(), $data =
$nodes = array(
// $method $node $element $styles $data $argument1 $argument2
'p' => array('Paragraph', $node, $element, $styles, null, null, null),
'br' => array('Linebreak', $node, $element, $styles, null, null, null),
'h1' => array('Heading', null, $element, $styles, null, 'Heading1', null),
'h2' => array('Heading', null, $element, $styles, null, 'Heading2', null),
'h3' => array('Heading', null, $element, $styles, null, 'Heading3', null),
Expand Down Expand Up @@ -197,10 +198,26 @@ private static function parseParagraph($node, $element, &$styles)
{
$styles['paragraph'] = self::parseInlineStyle($node, $styles['paragraph']);
$newElement = $element->addTextRun($styles['paragraph']);
$newElement->addTextBreak(1);

return $newElement;
}

/**
* Parse paragraph node
*
* @param \DOMNode $node
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
* @param array &$styles
* @return \PhpOffice\PhpWord\Element\TextRun
*/
private static function parseLinebreak($node, $element, &$styles)
{
$element->addTextBreak(1);

return $element;
}

/**
* Parse heading node
*
Expand Down

0 comments on commit d97f9c8

Please sign in to comment.