diff --git a/src/Html2Text.php b/src/Html2Text.php index d3b5462..e33caa4 100644 --- a/src/Html2Text.php +++ b/src/Html2Text.php @@ -352,7 +352,11 @@ protected function doConvert() { $this->linkList = array(); - $text = trim($this->html ?? ''); + if ($this->html === null) { + $text = ''; + } else { + $text = trim($this->html); + } $this->converter($text); @@ -390,7 +394,10 @@ protected function converter(&$text) $text = preg_replace("/[\n]{3,}/", "\n\n", $text); // remove leading empty lines (can be produced by eg. P tag on the beginning) - $text = ltrim($text ?? '', "\n"); + if ($text === null) { + $text = ''; + } + $text = ltrim($text, "\n"); if ($this->options['width'] > 0) { $text = wordwrap($text, $this->options['width']);