DokuWiki

It's better when it's simple

User Tools

Site Tools


devel:geshi

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
devel:geshi [2013-05-04 21:30] – [Example usage] Klap-indevel:geshi [2023-09-16 00:44] (current) Klap-in
Line 1: Line 1:
- 
 ====== Syntax highlighting by Geshi ====== ====== Syntax highlighting by Geshi ======
 DokuWiki includes GeSHi - Generic Syntax Highlighter - for formatting ''%%<code>%%'' and ''%%<file>%%'' blocks.  DokuWiki includes GeSHi - Generic Syntax Highlighter - for formatting ''%%<code>%%'' and ''%%<file>%%'' blocks. 
Line 5: Line 4:
  
 Please refer to the [[xref>GeSHi]] class documentation for implementation details. Please refer to the [[xref>GeSHi]] class documentation for implementation details.
 + 
 ===== Example usage ===== ===== 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.+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 php> <code php>
-$code = '...syntax to higlight...'; +$code = '... syntax to higlight ...'; 
-$geshi = new GeSHi($code, $language, DOKU_INC . 'inc/geshi');+$geshi = new GeSHi($code, $language);
 $geshi->set_encoding('utf-8'); $geshi->set_encoding('utf-8');
 $geshi->enable_classes(); $geshi->enable_classes();
Line 17: Line 16:
 $geshi->set_link_target($conf['target']['extern']); $geshi->set_link_target($conf['target']['extern']);
  
-// when you like to use your own wrapper, remove GeSHi's wrapper element +//when you like to use your own wrapper, remove GeSHi's wrapper element 
-// we need to use a GeSHi wrapper to avoid <BR> throughout the highlighted text+//we need to use a GeSHi wrapper to avoid <BR> throughout the highlighted text
 $highlighted_code = trim( $highlighted_code = trim(
-    preg_replace('!^<pre[^>]*>|</pre>$!','',$geshi->parse_code()),+    preg_replace('!^<pre[^>]*>|</pre>$!', '', $geshi->parse_code()),
     "\n\r"     "\n\r"
 ); );
devel/geshi.1367695856.txt.gz · Last modified: 2013-05-04 21:30 by Klap-in

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki