From e352549535beda0ba2be97a437c694d9f794fd4b Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Tue, 22 Jan 2008 19:51:03 +0000 Subject: modified markers in highlight_code() to not introduce unintended highlighting, and to allow code where the first line is a code comment to be styled properly --- system/helpers/text_helper.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'system/helpers') diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index 8b671140d..2a42cba7e 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -267,7 +267,7 @@ function highlight_code($str) // or B) whether the PHP tags enclose the entire string, we will add our // own PHP tags around the string along with some markers to make replacement easier later - $str = ''; + $str = ''; // All the magic happens here, baby! $str = highlight_string($str, TRUE); @@ -281,10 +281,9 @@ function highlight_code($str) } // Remove our artificially added PHP and the empty span that results from our temp markers - $str = preg_replace("#\.+?//tempstart\
\#is", "\n", $str); - $str = preg_replace("#\.+?//tempstart\
#is", "\n", $str); - $str = preg_replace("#//tempend.+#is", "\n", $str); - $str = preg_replace("#\\n
#is", "\n", $str); + $str = preg_replace("#\.+?tempstart\
\#is", "\n", $str); + $str = preg_replace("#\.+?tempstart\
#is", "\n", $str); + $str = preg_replace("#tempend.+#is", "\n", $str); // Replace our markers back to PHP tags. $str = str_replace(array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'), -- cgit v1.2.3-24-g4f1b