hande summary in code blocks correctly

This commit is contained in:
Mike Macgirvin 2024-07-08 18:42:22 +10:00
parent 5973a166c2
commit acfe79f3c4

View file

@ -1026,14 +1026,21 @@ class Item extends Controller
// and will require alternatives for alternative content-types (text/html, text/markdown, text/plain, etc.)
// we may need virtual or template classes to implement the possible alternatives
if (str_contains($body, '[/summary]')) {
if (str_contains($body, '[/summary]') || str_contains($body, '</summary>')) {
$body = wrap_code($body);
$match = '';
$cnt = preg_match("/\[summary](.*?)\[\/summary]/ism", $body, $match);
if ($cnt) {
$summary .= $match[1];
}
$body_content = preg_replace("/^(.*?)\[summary](.*?)\[\/summary]/ism", '', $body);
$body = trim($body_content);
$cnt = preg_match("/\<summary>(.*?)\<\/summary>/ism", $body, $match);
if ($cnt) {
$summary .= $match[1];
}
$body = preg_replace("/^(.*?)\[summary](.*?)\[\/summary]/ism", '', $body);
$body = preg_replace("/^(.*?)\<summary>(.*?)\<\/summary>/ism", '', $body);
$body = trim($body);
$body = unwrap_code($body);
}
$summary = wrap_code($summary);