Skip to content

Commit

Permalink
Merge pull request #482 from magefan/8199-fix-end-character-view
Browse files Browse the repository at this point in the history
fixed part of tag show in short content
  • Loading branch information
magefan authored Apr 3, 2023
2 parents 5b85089 + 768ae0e commit fd939ef
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Model/ShortContentExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,16 @@ public function execute($content, $len = null, $endCharacters = null)
}

/* Do not cut words */
while ($len < strlen($content)
&& !in_array($content[$len], [' ', '<', "\t", "\r", "\n"])) {
while ($len < mb_strlen($content)
&& !in_array(mb_substr($content, $len, 1), [' ', '<', "\t", "\r", "\n"])) {
$len++;
}

$content = mb_substr($content, 0, $len);
try {
$previousErrorState = libxml_use_internal_errors(true);
$dom = new \DOMDocument();
$dom->loadHTML('<?xml encoding="UTF-8">' . $content);
$dom->loadHTML('<?xml encoding="UTF-8">' . '<body>' . $content . '</body>');
libxml_use_internal_errors($previousErrorState);

$body = $dom->getElementsByTagName('body');
Expand Down

0 comments on commit fd939ef

Please sign in to comment.