Skip to content

Commit

Permalink
fix: MD\Util\Helper->getTextBetweenTags(): return empty array if inpu…
Browse files Browse the repository at this point in the history
…t string is empty + do not throw error
  • Loading branch information
e-picas committed Feb 24, 2024
1 parent 7f101f6 commit 0a122ae
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/MarkdownExtended/Util/Helper.php
Expand Up @@ -166,12 +166,17 @@ public static function isSingleLine($str = '')
*/
public static function getTextBetweenTags($string, $tagname)
{
$d = new \DOMDocument();
$d->loadHTML($string);
$return = [];
foreach($d->getElementsByTagName($tagname) as $item) {
$return[] = $item->textContent;
if (empty($string)) {
return $return;
}
$d = new \DOMDocument();
try{
$d->loadHTML($string);
foreach($d->getElementsByTagName($tagname) as $item) {
$return[] = $item->textContent;
}
} catch (\ErrorException $e) {}
return $return;
}

Expand Down

0 comments on commit 0a122ae

Please sign in to comment.