diff options
author | Michael <icarus@dabo.de> | 2012-02-19 21:07:45 +0100 |
---|---|---|
committer | Michael <icarus@dabo.de> | 2012-02-19 21:07:45 +0100 |
commit | 064c843119576c1345a61a531dfaa1076a54f3f0 (patch) | |
tree | a1ebc4daa503ba96be6ee54951414f83aa2ca7df /include/bbcode.php | |
parent | 8c8efbdf644fc645e61ba279ab52617d173cee45 (diff) | |
download | volse-hubzilla-064c843119576c1345a61a531dfaa1076a54f3f0.tar.gz volse-hubzilla-064c843119576c1345a61a531dfaa1076a54f3f0.tar.bz2 volse-hubzilla-064c843119576c1345a61a531dfaa1076a54f3f0.zip |
Handling nested bbcodes. Some small design changes in html2bbcode. Change in poller.php is just for testing purposes.
Diffstat (limited to 'include/bbcode.php')
-rwxr-xr-x | include/bbcode.php | 19 |
1 files changed, 12 insertions, 7 deletions
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("[*]", "<li>", $Text); $Text = preg_replace("/\[li\](.*?)\[\/li\]/ism", '<li>$1</li>' ,$Text); - $Text = preg_replace("/\[list\](.*?)\[\/list\]/ism", '<ul class="listbullet" style="list-style-type: circle;">$1</ul>' ,$Text); + // handle nested lists + $endlessloop = 0; + while (strpos($Text, "[/list]") and strpos($Text, "[list") and (++$endlessloop < 20)) { + $Text = preg_replace("/\[list\](.*?)\[\/list\]/ism", '<ul class="listbullet" style="list-style-type: circle;">$1</ul>' ,$Text); + $Text = preg_replace("/\[list=\](.*?)\[\/list\]/ism", '<ul class="listnone" style="list-style-type: none;">$1</ul>' ,$Text); + $Text = preg_replace("/\[list=1\](.*?)\[\/list\]/ism", '<ul class="listdecimal" style="list-style-type: decimal;">$1</ul>' ,$Text); + $Text = preg_replace("/\[list=((?-i)i)\](.*?)\[\/list\]/ism",'<ul class="listlowerroman" style="list-style-type: lower-roman;">$2</ul>' ,$Text); + $Text = preg_replace("/\[list=((?-i)I)\](.*?)\[\/list\]/ism", '<ul class="listupperroman" style="list-style-type: upper-roman;">$2</ul>' ,$Text); + $Text = preg_replace("/\[list=((?-i)a)\](.*?)\[\/list\]/ism", '<ul class="listloweralpha" style="list-style-type: lower-alpha;">$2</ul>' ,$Text); + $Text = preg_replace("/\[list=((?-i)A)\](.*?)\[\/list\]/ism", '<ul class="listupperalpha" style="list-style-type: upper-alpha;">$2</ul>' ,$Text); + } + $Text = preg_replace("/\[ul\](.*?)\[\/ul\]/ism", '<ul class="listbullet" style="list-style-type: circle;">$1</ul>' ,$Text); - $Text = preg_replace("/\[list=\](.*?)\[\/list\]/ism", '<ul class="listnone" style="list-style-type: none;">$1</ul>' ,$Text); - $Text = preg_replace("/\[list=1\](.*?)\[\/list\]/ism", '<ul class="listdecimal" style="list-style-type: decimal;">$1</ul>' ,$Text); $Text = preg_replace("/\[ol\](.*?)\[\/ol\]/ism", '<ul class="listdecimal" style="list-style-type: decimal;">$1</ul>' ,$Text); - $Text = preg_replace("/\[list=((?-i)i)\](.*?)\[\/list\]/ism",'<ul class="listlowerroman" style="list-style-type: lower-roman;">$2</ul>' ,$Text); - $Text = preg_replace("/\[list=((?-i)I)\](.*?)\[\/list\]/ism", '<ul class="listupperroman" style="list-style-type: upper-roman;">$2</ul>' ,$Text); - $Text = preg_replace("/\[list=((?-i)a)\](.*?)\[\/list\]/ism", '<ul class="listloweralpha" style="list-style-type: lower-alpha;">$2</ul>' ,$Text); - $Text = preg_replace("/\[list=((?-i)A)\](.*?)\[\/list\]/ism", '<ul class="listupperalpha" style="list-style-type: upper-alpha;">$2</ul>' ,$Text); $Text = preg_replace("/\[th\](.*?)\[\/th\]/sm", '<th>$1</th>' ,$Text); $Text = preg_replace("/\[td\](.*?)\[\/td\]/sm", '<td>$1</td>' ,$Text); |