com web/php: Drop support for < 5.3 from highlight_php() : include/layout.inc
| From: | Hannes Magnusson | Date: | Thu, 05 Jun 2014 17:57:40 +0000 |
| Subject: | com web/php: Drop support for < 5.3 from highlight_php() : include/layout.inc | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-19314@lists.php.net to get a copy of this message | ||
Commit: d766dd3c67416faf53ff3f79e5710e1e889efc4c
Author: Michael <git@rvapps.org> Thu, 5 Jun 2014 19:57:40 +0200
Parents: d5c8c1d7eb66ce830846d88cd2bdad94f2234d62
Branches: master
Link: http://git.php.net/?p=web/php.git;a=commitdiff;h=d766dd3c67416faf53ff3f79e5710e1e889efc4c
Log:
Drop support for < 5.3 from highlight_php()
..to use HTML5
Changed paths:
M include/layout.inc
Diff:
diff --git a/include/layout.inc b/include/layout.inc
index d6095c6...c851a3c 100644
--- a/include/layout.inc
+++ b/include/layout.inc
@@ -14,24 +14,19 @@ ini_set('highlight.html', 'html');
// Highlight PHP code
function highlight_php($code, $return = FALSE)
{
- // Using OB, as highlight_string() only supports
- // returning the result from 4.2.0
- ob_start();
- highlight_string($code);
- $highlighted = ob_get_contents();
- ob_end_clean();
+ $highlighted = highlight_string($code, TRUE);
- // This should eventually be a php_syntax_check() call when we move to PHP5
- // But use this ugly hack for now to avoid code snippets with bad syntax screwing up the
highlighter
- if(strstr($highlighted,"include/layout.inc</b>")) $highlighted = '<span
class="html">'.nl2br(htmlentities($code))."</span>";
+ // Use this ugly hack for now to avoid code snippets with bad syntax screwing up the highlighter
+ if(strstr($highlighted, "include/layout.inc</b>")) {
+ $highlighted = '<span class="html">'. nl2br(htmlentities($code,
ENT_HTML5), FALSE) ."</span>";
+ }
// Fix output to use CSS classes and wrap well
$highlighted = '<div class="phpcode">' .. str_replace(
array(
' ',
'<br>',
- '<font color="', // for PHP 4
- '<span style="color: ', // from PHP 5.0.0RC1
+ '<span style="color: ',
'</font>',
"\n ",
' ',
@@ -41,7 +36,6 @@ function highlight_php($code, $return = FALSE)
' ',
"<br>\n",
'<span class="',
- '<span class="',
'</span>',
"\n ",
' ',
@@ -62,7 +56,6 @@ function commonHeader($title) { site_header($title); }
function commonFooter() { site_footer(); }
// Resize the image using the output of make_image()
-// (considering possible HTML/XHTML image tag endings)
function resize_image($img, $width = 1, $height = 1)
{
// Drop width and height values from image if available