From 064c843119576c1345a61a531dfaa1076a54f3f0 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 19 Feb 2012 21:07:45 +0100 Subject: Handling nested bbcodes. Some small design changes in html2bbcode. Change in poller.php is just for testing purposes. --- include/bbcode.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'include/bbcode.php') diff --git a/include/bbcode.php b/include/bbcode.php index 528df33ec..d639b0c39 100755 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -149,15 +149,20 @@ function bbcode($Text,$preserve_nl = false) { $Text = str_replace("[*]", "
  • ", $Text); $Text = preg_replace("/\[li\](.*?)\[\/li\]/ism", '
  • $1
  • ' ,$Text); - $Text = preg_replace("/\[list\](.*?)\[\/list\]/ism", '' ,$Text); + // handle nested lists + $endlessloop = 0; + while (strpos($Text, "[/list]") and strpos($Text, "[list") and (++$endlessloop < 20)) { + $Text = preg_replace("/\[list\](.*?)\[\/list\]/ism", '' ,$Text); + $Text = preg_replace("/\[list=\](.*?)\[\/list\]/ism", '' ,$Text); + $Text = preg_replace("/\[list=1\](.*?)\[\/list\]/ism", '' ,$Text); + $Text = preg_replace("/\[list=((?-i)i)\](.*?)\[\/list\]/ism",'' ,$Text); + $Text = preg_replace("/\[list=((?-i)I)\](.*?)\[\/list\]/ism", '' ,$Text); + $Text = preg_replace("/\[list=((?-i)a)\](.*?)\[\/list\]/ism", '' ,$Text); + $Text = preg_replace("/\[list=((?-i)A)\](.*?)\[\/list\]/ism", '' ,$Text); + } + $Text = preg_replace("/\[ul\](.*?)\[\/ul\]/ism", '' ,$Text); - $Text = preg_replace("/\[list=\](.*?)\[\/list\]/ism", '' ,$Text); - $Text = preg_replace("/\[list=1\](.*?)\[\/list\]/ism", '' ,$Text); $Text = preg_replace("/\[ol\](.*?)\[\/ol\]/ism", '' ,$Text); - $Text = preg_replace("/\[list=((?-i)i)\](.*?)\[\/list\]/ism",'' ,$Text); - $Text = preg_replace("/\[list=((?-i)I)\](.*?)\[\/list\]/ism", '' ,$Text); - $Text = preg_replace("/\[list=((?-i)a)\](.*?)\[\/list\]/ism", '' ,$Text); - $Text = preg_replace("/\[list=((?-i)A)\](.*?)\[\/list\]/ism", '' ,$Text); $Text = preg_replace("/\[th\](.*?)\[\/th\]/sm", '$1' ,$Text); $Text = preg_replace("/\[td\](.*?)\[\/td\]/sm", '$1' ,$Text); -- cgit v1.2.3