From 5bc9250cccf45492a2003303c66ae762689e2e7a Mon Sep 17 00:00:00 2001 From: troosan Date: Wed, 2 Jan 2019 09:28:51 +0100 Subject: [PATCH] Fix unit tests --- src/PhpWord/Shared/Html.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index a92d9047..ff13c35d 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -70,6 +70,9 @@ class Html $html = '' . $html . ''; } + //need to remove whitespaces between tags, as loadHTML seems to take those into account + $html = preg_replace('/(\>)\s*(\<)/m', '$1$2', $html); + // Load DOM libxml_disable_entity_loader(true); $dom = new \DOMDocument(); @@ -77,6 +80,7 @@ class Html $dom->loadHTML($html, LIBXML_NOWARNING); self::$xpath = new \DOMXPath($dom); $node = $dom->getElementsByTagName('body'); + self::parseNode($node->item(0), $element); }