Formatter: GeSHi Code Highlighting

Compatible with: R5.5
Current version: 0.2
GeSHi Documentation

1. Variant A

Here is how you can quickly add GeSHi code highlighting to your Wacko installation:

  1. cd formatter/highlight/
  2. wget
  3. tar xzvf GeSHi-
  4. rm GeSHi-
  5. mkdir old; mv {css,html,java,pascal,php,sql}.php old/ Get rid of older support.
  6. Build a list of names of GeSHi files, I did this with ls geshi/geshi -1 | awk -F. '{print $1}' > names
  7. You might want to open up names and change html4strict to just html.
  8. Run the below script in that directory, change as needed.
  9. You can then do things like %%(perl) %% and it will work more or less as expected.
  10. This is intended to get you there quickly, you may want to extend this further on your own.


for x in `cat names`; do

cat < $x.php
echo "";
echo "<div class="\"code\"">";
echo \$geshi->parse_code();
echo "</div>";
echo "";


2. Variant B

Call via (geshi css)

%%(geshi php numbers=1 start=35 lines=37) source%%

  1. place the GeSHi lib under the lib/geshi/ folder
  2. add the GeSHi class to autoload.conf
    lib/geshi/geshi.php 			GeSHi



# require_once 'lib/geshi/geshi.php'; // -> autoload.conf

if ($options['_default'])
$language    $options['_default'];
$lines        = [];
$start        = (int)($options['start'] ?? 1);
$header        GESHI_HEADER_PRE_VALID;

$geshi = new GeSHi($text$language);

    if (!empty(
$lines array_map('intval'explode(','$options['lines']));
$lines array_unique($lines);

    if (!empty(

        switch (
$header false;

$geshi->enable_classes();            // use classes for highlighting (must be first after creating object)
$geshi->set_overall_class('code');    // enables using a single stylesheet for multiple code fragments
$geshi->set_tab_width(4);            // default: 8


$geshi->enable_line_numbers((bool) $numbers); // GESHI_NORMAL_LINE_NUMBERS GESHI_FANCY_LINE_NUMBERS, 2 GESHI_NO_LINE_NUMBERS
$geshi->start_line_numbers_at((int) abs($start));

    // get the stylesheet -> geshi.css
echo '<style type="text/css">';

echo '<!--notypo-->' "\n";
'<!--/notypo-->' "\n";

2.1. External stylesheet

GeSHi comes with a contrib/ directory, which in it contains a “wizard” script for creating a stylesheet.

geshi.css (incomplete)

/* GeSHi – syntax highlighting code */

.code .de1, .code .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align\top;}
.code  {font-family:monospace;}
.code .imp {font-weight: bold; color: red;}
.code li, .code .li1 {font-weight: normal; vertical-align\top;}
.code .ln width:1px;text-align\right;margin:0;padding:0 2px;vertical-align\top;}
.code .li2 {font-weight: bold; vertical-align\top;}
.code .kw2 {color: #000000; font-weight: bold;}
.code .kw3 {color: #000066;}
.code .es0 {color: #000099; font-weight: bold;}
.code .br0 {color: #66cc66;}
.code .sy0 {color: #66cc66;}
.code .st0 {color: #ff0000;}
.code .nu0 {color: #cc66cc;}
.code .sc-2 {color: #404040;}
.code .sc-1 {color: #808080; font-style: italic;}
.code .sc0 {color: #00bbdd;}
.code .sc1 {color: #ddbb00;}
.code .sc2 {color: #009900;}
.code .ln-xtra, .code li.ln-xtra, .code div.ln-xtra {background-color: #ffc;}
.code span.xtra { display:block; } 

// add to theme/_common/_header.php
$this->add_html('header', '<link rel="stylesheet" href="' . $this->db->theme_url . 'css/geshi.css">');