From 0378f35b07aa9a713545d9bd4cafbb066b2d84f4 Mon Sep 17 00:00:00 2001 From: Michael Ochmann Date: Thu, 18 Aug 2022 12:04:27 +0200 Subject: [PATCH] now preventing empty lines from gettin parsed into paragraphs --- src/Parser.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Parser.php b/src/Parser.php index 1a2f7be..aba5809 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -301,9 +301,19 @@ class Parser { } private function buildParagraph(array $elms) : void { + if (count($elms) < 1) + return; + $elm = $this->document->createElement("p"); - foreach ($elms as $node) + $i = 0; + foreach ($elms as $node) { + if (trim($node->textContent) === "") + continue; $elm->appendChild($node); + $i++; + } + if ($i < 1) + return; $this->document->appendChild($elm); }