[Pmwiki-users] Re: Highlighting <?php?
David Jackson
itdoctor
Sat Mar 6 10:51:46 CST 2004
> function php_highlight($string) { return highlight_string($string,TRUE); }
[..]
> and also extend it to other languages simply by adding the appropriate
> <language>_highlight routine.
I like this a lot :-)
While browsing around for other language handling, I came across some
xhtml code substition, so added it:
function php_highlight($string) {
// Get highlighted code
$html_code = highlight_string($string,TRUE);
// Bookmark #1:
// Remove the first "<code>" tag from "$html_code" (if any)
if (substr($html_code, 0, 6) == "<code>") {
$html_code = substr($html_code, 6, strlen($html_code));
}
// Replacement-map to replace deprecated "<font>" tag with "<span>"
$xhtml_convmap = array(
'<font' => '<span',
'</font>' => '</span>',
'color="' => 'style="color:'
);
// Replace "<font>" tags with "<span>" tags,
// to generate a valid XHTML code
$html_code = strtr($html_code, $xhtml_convmap);
return $html_code
}
I then looked about for other languge functions & remembered the
Beautifier Cookbook module.
I have installed that now instead, but added the above code to the end
of the function highlight_text in core.php:
// Replacement-map to replace deprecated "<font>" tag with "<span>"
$xhtml_convmap = array(
'<font' => '<span',
'</font>' => '</span>',
'color="' => 'style="color:'
);
// Replace "<font>" tags with "<span>" tags,
// to generate a valid XHTML code
$out = strtr($out, $xhtml_convmap);
return $out;
This removes the evil font tag :-)
While I'm on, anyone any idea why the beautifier ignores the quote
string colour? I edited the appropiate HFile, added a new colour
("red") to the array, changed the line
$this->quotecolour = "red";
but it still comes out blue?
For completeness, I should also mention that I changed the markup to:
=code sql [=
/* code Here */
=]
to save typing ;-)
Perhaps
=lang [=
[..]
=]
would be beter...
I'm rambling now so I'll just hit send...
Dave Jackson
More information about the pmwiki-users
mailing list