|
|
Line 1: |
Line 1: |
| <?php
| |
| if (!function_exists('geshi_highlight')) {
| |
| /**
| |
| * Easy way to highlight stuff. Behaves just like highlight_string
| |
| *
| |
| * @param string The code to highlight
| |
| * @param string The language to highlight the code in
| |
| * @param string The path to the language files. You can leave this blank if you need
| |
| * as from version 1.0.7 the path should be automatically detected
| |
| * @param boolean Whether to return the result or to echo
| |
| * @return string The code highlighted (if $return is true)
| |
| * @since 1.0.2
| |
| */
| |
| function geshi_highlight ($string, $language, $path, $return = false)
| |
| {
| |
| $geshi = new GeSHi($string, $language, $path);
| |
| $geshi->set_header_type(GESHI_HEADER_NONE);
| |
| if ($return) {
| |
| return '<code>' . $geshi->parse_code() . '</code>';
| |
| }
| |
| echo '<code>' . $geshi->parse_code() . '</code>';
| |
| if ($geshi->error()) {
| |
| return false;
| |
| }
| |
| return true;
| |
| }
| |
| }
| |
|
| |
|
| ?>
| |