[Pmwiki-users] Highlighting <?php?
Jonathan Scott Duff
duff
Thu Mar 4 12:29:56 CST 2004
On Thu, Mar 04, 2004 at 05:22:57PM +0100, Thomas -Balu- Walter wrote:
> One caveat is source where HTML and PHP are mixed:
>
> <?php
> doSomePHP();
> print('Hello World');
> ?>
> a big HTML-only part
> <?php
> doMorePHP();
> ?>
That and it would be nice if we had a syntax for highlighting other
languages too makes me lean towards something like this:
$BrowseDirectives['/^=HL\\s+(\\w+)(.*?)^=HL/esm'] =
"Keep(syntax_highlight('$1',str_replace('\\\"','\"','$2')))";
function syntax_highlight($language,$string) {
$func = $language . "_highlight";
if (function_exists($func)) { return call_user_func($func,$string); }
return "<code>$string</code>";
}
function php_highlight($string) { return highlight_string($string,TRUE); }
So that you could say:
=HL php
<?php
doSomePHP();
print('Hello World');
?>
a big HTML-only part
<?php
doMorePHP();
?>
=HL
and also extend it to other languages simply by adding the appropriate
<language>_highlight routine.
-Scott
--
Jonathan Scott Duff
duff at pobox.com
More information about the pmwiki-users
mailing list