diff options
author | Derek Jones <derek.jones@ellislab.com> | 2008-01-22 20:51:03 +0100 |
---|---|---|
committer | Derek Jones <derek.jones@ellislab.com> | 2008-01-22 20:51:03 +0100 |
commit | e352549535beda0ba2be97a437c694d9f794fd4b (patch) | |
tree | 3f1cc643579f06d7bc1bbfe499a618dbc382ffb4 | |
parent | 1487f8c96493cac4aa8fb440fb829e20231a6053 (diff) |
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
-rw-r--r-- | system/helpers/text_helper.php | 9 |
1 files changed, 4 insertions, 5 deletions
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 = '<?php //tempstart'."\n".$str.'//tempend ?>';
+ $str = '<?php tempstart'."\n".$str.'tempend ?>';
// 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("#\<code\>.+?//tempstart\<br />\</span\>#is", "<code>\n", $str);
- $str = preg_replace("#\<code\>.+?//tempstart\<br />#is", "<code>\n", $str);
- $str = preg_replace("#//tempend.+#is", "</span>\n</code>", $str);
- $str = preg_replace("#\<span style=\"color: \#FF8000\"\></span>\n</code>#is", "\n</code>", $str);
+ $str = preg_replace("#\<code\>.+?tempstart\<br />\</span\>#is", "<code>\n", $str);
+ $str = preg_replace("#\<code\>.+?tempstart\<br />#is", "<code>\n", $str);
+ $str = preg_replace("#tempend.+#is", "</span>\n</code>", $str);
// Replace our markers back to PHP tags.
$str = str_replace(array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'),
|