@@ -14,24 +14,19 @@ ini_set('highlight.html', 'html');
14
14
// Highlight PHP code
15
15
function highlight_php ($ code , $ return = FALSE )
16
16
{
17
- // Using OB, as highlight_string() only supports
18
- // returning the result from 4.2.0
19
- ob_start ();
20
- highlight_string ($ code );
21
- $ highlighted = ob_get_contents ();
22
- ob_end_clean ();
17
+ $ highlighted = highlight_string ($ code , TRUE );
23
18
24
- // This should eventually be a php_syntax_check() call when we move to PHP5
25
- // But use this ugly hack for now to avoid code snippets with bad syntax screwing up the highlighter
26
- if (strstr ($ highlighted ,"include/layout.inc</b> " )) $ highlighted = '<span class="html"> ' .nl2br (htmlentities ($ code ))."</span> " ;
19
+ // Use this ugly hack for now to avoid code snippets with bad syntax screwing up the highlighter
20
+ if (strstr ($ highlighted , "include/layout.inc</b> " )) {
21
+ $ highlighted = '<span class="html"> ' . nl2br (htmlentities ($ code , ENT_HTML5 ), FALSE ) ."</span> " ;
22
+ }
27
23
28
24
// Fix output to use CSS classes and wrap well
29
25
$ highlighted = '<div class="phpcode"> ' . str_replace (
30
26
array (
31
27
' ' ,
32
28
'<br> ' ,
33
- '<font color=" ' , // for PHP 4
34
- '<span style="color: ' , // from PHP 5.0.0RC1
29
+ '<span style="color: ' ,
35
30
'</font> ' ,
36
31
"\n " ,
37
32
' ' ,
@@ -41,7 +36,6 @@ function highlight_php($code, $return = FALSE)
41
36
' ' ,
42
37
"<br> \n" ,
43
38
'<span class=" ' ,
44
- '<span class=" ' ,
45
39
'</span> ' ,
46
40
"\n " ,
47
41
' ' ,
@@ -62,7 +56,6 @@ function commonHeader($title) { site_header($title); }
62
56
function commonFooter () { site_footer (); }
63
57
64
58
// Resize the image using the output of make_image()
65
- // (considering possible HTML/XHTML image tag endings)
66
59
function resize_image ($ img , $ width = 1 , $ height = 1 )
67
60
{
68
61
// Drop width and height values from image if available
0 commit comments