====== Syntax highlighting by Geshi ====== DokuWiki includes GeSHi - Generic Syntax Highlighter - for formatting ''%%%%'' and ''%%%%'' blocks. Please refer to the documentation at http://qbnz.com/highlighter/documentation.php for more information about how to use its class. Please refer to the [[xref>GeSHi]] class documentation for implementation details. ===== Example usage ===== Example how DokuWiki applies the highlighter for its code and file blocks. It is embedded in a wrapper method [[xref>p_xhtml_cached_geshi()]] that caches the output to reduce the server load. $code = '... syntax to higlight ...'; $geshi = new GeSHi($code, $language); $geshi->set_encoding('utf-8'); $geshi->enable_classes(); $geshi->set_header_type(GESHI_HEADER_PRE); $geshi->set_link_target($conf['target']['extern']); //when you like to use your own wrapper, remove GeSHi's wrapper element //we need to use a GeSHi wrapper to avoid
throughout the highlighted text $highlighted_code = trim( preg_replace('!^]*>|$!', '', $geshi->parse_code()), "\n\r" );
===See also=== * [[wiki:syntax#syntax_highlighting|Syntax highlighting]] in ''%%%%'' and ''%%%%'' blocks * [[tips:GeSHi style builder]] for generating smaller css files by using similar colors for the different languages. * [[tips:code css|CSS to extend syntax highlighting ]]