diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index 027d5798..e19c3fb6 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -136,6 +136,7 @@ class Html 'ul' => array('List', null, null, $styles, $data, 3, null), 'ol' => array('List', null, null, $styles, $data, 7, null), 'li' => array('ListItem', $node, $element, $styles, $data, null, null), + 'br' => array('LineBreak', null, $element, $styles, null, null, null), ); $newElement = null; @@ -523,4 +524,14 @@ class Html return 'single'; } } -} + + /** + * Parse line break + * + * @param \PhpOffice\PhpWord\Element\AbstractContainer $element + */ + private static function parseLineBreak($element) + { + $element->addTextBreak(); + } +} \ No newline at end of file diff --git a/tests/PhpWord/Shared/HtmlTest.php b/tests/PhpWord/Shared/HtmlTest.php index 58b0d977..bfe24c58 100644 --- a/tests/PhpWord/Shared/HtmlTest.php +++ b/tests/PhpWord/Shared/HtmlTest.php @@ -234,4 +234,22 @@ class HtmlTest extends \PHPUnit\Framework\TestCase $this->assertEquals('list item1', $doc->getElement('/w:document/w:body/w:p[1]/w:r/w:t')->nodeValue); $this->assertEquals('list item2', $doc->getElement('/w:document/w:body/w:p[2]/w:r/w:t')->nodeValue); } + + /** + * Tests parsing of br + */ + public function testParseLineBreak() + { + $phpWord = new \PhpOffice\PhpWord\PhpWord(); + $section = $phpWord->addSection(); + $html = '
This is some text
with a linebreak.