Skip to content

Commit

Permalink
Add empty input checks to fix deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
bobvandevijver committed Mar 20, 2024
1 parent 640567d commit 948030c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Helper/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ public function __construct() {
* @param bool $removeGreek If set, any greek character will be replaced by their LaTeX math equivalent (default false)
*/
public function parseText(?string $text, bool $checkTable = true, bool $removeLatex = false, bool $parseNewLines = false, bool $removeGreek = false): string {
if ($text === NULL || $text === '') {
return '';
}

// Try to replace HTML entities
preg_match_all('/&[a-zA-Z]+;/iu', $text, $matches);
Expand Down Expand Up @@ -228,6 +231,10 @@ public function parseText(?string $text, bool $checkTable = true, bool $removeLa
* Parse the html input and create latex code of it
*/
public static function parseHtml(?string $text): ?string {
if ($text === NULL || $text === '') {
// BC compatible return value
return "\n\n";
}

// Replace NO-BREAK-SPACE with normal space
$text = str_replace("\xc2\xa0", ' ', $text);
Expand Down

0 comments on commit 948030c

Please sign in to comment.