From 239db8407f880be233f011980f1d3e9690bae69d Mon Sep 17 00:00:00 2001 From: nobody Date: Wed, 3 Mar 2021 15:07:34 -0800 Subject: [PATCH] add the bbcode cheatsheet after converting to multicode --- include/bbcode.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/include/bbcode.php b/include/bbcode.php index df36eb6df..a1a2e35fc 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -1779,20 +1779,27 @@ function bbcode($Text, $options = []) { $Text = preg_replace_callback("/\[checklist\](.*?)\[\/checklist\]/ism", 'bb_checklist', $Text); } + + $loop = 0; + while (strpos($Text,'[/table]') !== false && strpos($Text,"[table") !== false && ++$loop < 20) { + $Text = preg_replace("/\[table\](.*?)\[\/table\]/ism", '$1
', $Text); + $Text = preg_replace("/\[table border=1\](.*?)\[\/table\]/ism", '$1
', $Text); + $Text = preg_replace("/\[table border=0\](.*?)\[\/table\]/ism", '$1
', $Text); + } if (strpos($Text,'[th]') !== false) { - $Text = preg_replace("/\[th\](.*?)\[\/th\]/sm", '$1', $Text); + $Text = preg_replace("/\[th\](.*?)\[\/th\]/ism", '$1', $Text); } if (strpos($Text,'[td]') !== false) { - $Text = preg_replace("/\[td\](.*?)\[\/td\]/sm", '$1', $Text); + $Text = preg_replace("/\[td\](.*?)\[\/td\]/ism", '$1', $Text); } if (strpos($Text,'[tr]') !== false) { - $Text = preg_replace("/\[tr\](.*?)\[\/tr\]/sm", '$1', $Text); + $Text = preg_replace("/\[tr\](.*?)\[\/tr\]/ism", '$1', $Text); } - if (strpos($Text,'[/table]') !== false) { - $Text = preg_replace("/\[table\](.*?)\[\/table\]/sm", '$1
', $Text); - $Text = preg_replace("/\[table border=1\](.*?)\[\/table\]/sm", '$1
', $Text); - $Text = preg_replace("/\[table border=0\](.*?)\[\/table\]/sm", '$1
', $Text); + if (strpos($Text,'[tbody]') !== false) { + $Text = preg_replace("/\[tbody\](.*?)\[\/tbody\]/ism", '$1', $Text); } + + $Text = str_replace('
', "\n", $Text); $Text = str_replace('[hr]', '
', $Text); $Text = str_replace('[hr/]', '
', $Text);