Skip to content

Commit

Permalink
Merge pull request #124 from andrewnicols/php54fix
Browse files Browse the repository at this point in the history
Remove php8 nullsafe operator
  • Loading branch information
andrewnicols authored Aug 20, 2024
2 parents 31cc1af + 406933c commit f5066a5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Html2Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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']);
Expand Down

0 comments on commit f5066a5

Please sign in to comment.