Skip to content

Commit 50fbd63

Browse files
committed
fixed part of tag show in short content
1 parent 3e3e021 commit 50fbd63

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Model/ShortContentExtractor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,16 @@ public function execute($content, $len = null, $endCharacters = null)
130130
}
131131

132132
/* Do not cut words */
133-
while ($len < strlen($content)
133+
while ($len < mb_strlen($content)
134134
&& !in_array($content[$len], [' ', '<', "\t", "\r", "\n"])) {
135135
$len++;
136136
}
137137

138-
$content = mb_substr($content, 0, $len);
138+
$content = mb_strcut($content, 0, $len);
139139
try {
140140
$previousErrorState = libxml_use_internal_errors(true);
141141
$dom = new \DOMDocument();
142-
$dom->loadHTML('<?xml encoding="UTF-8">' . $content);
142+
$dom->loadHTML('<?xml encoding="UTF-8">' . '<body>' . $content . '</body>');
143143
libxml_use_internal_errors($previousErrorState);
144144

145145
$body = $dom->getElementsByTagName('body');

0 commit comments

Comments
 (0)