From 1a5dd5c87c60f28fd799397e2aa0081f9b6c58ed Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Mon, 26 Dec 2016 08:58:40 -0500 Subject: Updated markup language support doco. Modified parseIdentityAwareHTML BBcode parsing to support the BBcode reference which is now in /help/member/bbcode.html. Add Bootstrap classes to tables for BBcode tables that have the border=0 or border=1 options set. --- include/bbcode.php | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'include/bbcode.php') diff --git a/include/bbcode.php b/include/bbcode.php index c7bee6f97..f0cf861f3 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -530,7 +530,17 @@ function bb_fixtable_lf($match) { } function parseIdentityAwareHTML($Text) { - + + // Hide all [noparse] contained bbtags by spacefying them + if (strpos($Text,'[noparse]') !== false) { + $Text = preg_replace_callback("/\[noparse\](.*?)\[\/noparse\]/ism", 'bb_spacefy',$Text); + } + if (strpos($Text,'[nobb]') !== false) { + $Text = preg_replace_callback("/\[nobb\](.*?)\[\/nobb\]/ism", 'bb_spacefy',$Text); + } + if (strpos($Text,'[pre]') !== false) { + $Text = preg_replace_callback("/\[pre\](.*?)\[\/pre\]/ism", 'bb_spacefy',$Text); + } // process [observer] tags before we do anything else because we might // be stripping away stuff that then doesn't need to be worked on anymore @@ -568,9 +578,21 @@ function parseIdentityAwareHTML($Text) { $Text = str_replace('[observer.photo]','', $Text); } - $Text = str_replace(array('[baseurl]','[sitename]'),array(z_root(),get_config('system','sitename')),$Text); + $Text = str_replace(array('[baseurl]','[sitename]'),array(z_root(),get_config('system','sitename')),$Text); - return $Text; + + // Unhide all [noparse] contained bbtags unspacefying them + // and triming the [noparse] tag. + if (strpos($Text,'[noparse]') !== false) { + $Text = preg_replace_callback("/\[noparse\](.*?)\[\/noparse\]/ism", 'bb_unspacefy_and_trim', $Text); + } + if (strpos($Text,'[nobb]') !== false) { + $Text = preg_replace_callback("/\[nobb\](.*?)\[\/nobb\]/ism", 'bb_unspacefy_and_trim', $Text); + } + if (strpos($Text,'[pre]') !== false) { + $Text = preg_replace_callback("/\[pre\](.*?)\[\/pre\]/ism", 'bb_unspacefy_and_trim', $Text); + } + return $Text; } // BBcode 2 HTML was written by WAY2WEB.net @@ -891,8 +913,8 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false) } 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); + $Text = preg_replace("/\[table border=1\](.*?)\[\/table\]/sm", '$1
', $Text); + $Text = preg_replace("/\[table border=0\](.*?)\[\/table\]/sm", '$1
', $Text); } $Text = str_replace('
', "\n", $Text); $Text = str_replace('[hr]', '
', $Text); -- cgit v1.2.3