From acfe79f3c4e86e14171c408f2ea80fe6c8b935f4 Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Mon, 8 Jul 2024 18:42:22 +1000 Subject: [PATCH] hande summary in code blocks correctly --- src/Module/Item.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Module/Item.php b/src/Module/Item.php index 86b33a49c..8dcd089fb 100644 --- a/src/Module/Item.php +++ b/src/Module/Item.php @@ -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, '')) { + $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>/ism", $body, $match); + if ($cnt) { + $summary .= $match[1]; + } + $body = preg_replace("/^(.*?)\[summary](.*?)\[\/summary]/ism", '', $body); + $body = preg_replace("/^(.*?)\(.*?)\<\/summary>/ism", '', $body); + $body = trim($body); + $body = unwrap_code($body); } $summary = wrap_code($summary);