diff --git a/src/Html/HtmlFormatter.php b/src/Html/HtmlFormatter.php index ac2b987..4d04aba 100644 --- a/src/Html/HtmlFormatter.php +++ b/src/Html/HtmlFormatter.php @@ -46,11 +46,8 @@ public function Format(Document $document) // Begin format $this->ProcessGroup($document->root); // Remove any final unclosed 'p' tag and return result: - if (substr($this->output, -3) == "

") { - return substr($this->output, 0, -3); - } else { - return $this->output; - } + return $this->openedTags['p'] ? substr($this->output, 0, -3) : $this->output; + } protected function LoadFont(\RtfHtmlPhp\Group $fontGroup) { @@ -431,8 +428,8 @@ protected function CloseTag($tag) } } else { $this->output .= ""; - $this->openedTags[$tag] = false; } + $this->openedTags[$tag] = false; } }