plugins/GeSHi.php
author Dan
Fri, 29 May 2009 20:17:54 -0400
changeset 7 86f0dc4ca29d
parent 6 aeecc46f11c6
permissions -rwxr-xr-x
Updated URL and version
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
     1
<?php
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
     2
/*
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
     3
Plugin Name: GeSHi syntax highlighting
7
86f0dc4ca29d Updated URL and version
Dan
parents: 6
diff changeset
     4
Plugin URI: http://enanocms.org/plugin/geshi
1
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
     5
Description: Adds syntax highlighting support using the GeSHi engine.
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
     6
Author: Dan Fuhry
7
86f0dc4ca29d Updated URL and version
Dan
parents: 6
diff changeset
     7
Version: 0.2
1
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
     8
Author URI: http://enanocms.org/
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
     9
*/
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    10
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    11
/*
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    12
 * GeSHi highlighting plugin for Enano
7
86f0dc4ca29d Updated URL and version
Dan
parents: 6
diff changeset
    13
 * Version 0.2
1
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    14
 * Copyright (C) 2007 Dan Fuhry
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    15
 *
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    16
 * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    17
 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    18
 *
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    19
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    20
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    21
 */
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    22
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    23
global $db, $session, $paths, $template, $plugins; // Common objects
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    24
$GLOBALS['geshi_supported_formats'] = array(
2
9e3258dfae15 Updated GeSHi. w00t.
Dan
parents: 1
diff changeset
    25
    'abap', 'actionscript3', 'actionscript', 'ada', 'apache', 'applescript', 'apt_sources', 'asm', 'asp', 'autoit', 'avisynth', 'bash', 'basic4gl', 'bf', 'blitzbasic', 'bnf', 'boo', 'caddcl', 'cadlisp', 'cfdg', 'cfm', 'cil', 'c_mac', 'cobol', 'c', 'cpp', 'cpp-qt', 'csharp', 'css', 'delphi', 'diff', 'div', 'dos', 'dot', 'd', 'eiffel', 'email', 'fortran', 'freebasic', 'genero', 'gettext', 'glsl', 'gml', 'gnuplot', 'groovy', 'haskell', 'hq9plus', 'html', 'idl', 'ini', 'inno', 'intercal', 'io', 'java5', 'java', 'javascript', 'kixtart', 'klonec', 'klonecpp', 'latex', 'lisp', 'lolcode', 'lotusformulas', 'lotusscript', 'lscript', 'lua', 'm68k', 'make', 'matlab', 'mirc', 'mpasm', 'mxml', 'mysql', 'nsis', 'objc', 'ocaml-brief', 'ocaml', 'oobas', 'oracle11', 'oracle8', 'pascal', 'perl', 'per', 'php-brief', 'php', 'pic16', 'pixelbender', 'plsql', 'povray', 'powershell', 'progress', 'prolog', 'providex', 'python', 'qbasic', 'rails', 'reg', 'robots', 'ruby', 'sas', 'scala', 'scheme', 'scilab', 'sdlbasic', 'smalltalk', 'smarty', 'sql', 'tcl', 'teraterm', 'text', 'thinbasic', 'tsql', 'typoscript', 'vbnet', 'vb', 'verilog', 'vhdl', 'vim', 'visualfoxpro', 'visualprolog', 'whitespace', 'winbatch', 'xml', 'xorg_conf', 'xpp', 'z80'
1
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    26
  );
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    27
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    28
// Knock out the existing <code> tag support
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    29
$plugins->attachHook('text_wiki_construct', 'geshi_disable_tw_code($this);');
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    30
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    31
function geshi_disable_tw_code($tw)
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    32
{
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    33
  $tw->disable[] = 'Code';
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    34
  foreach ( $tw->rules as $i => $rule )
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    35
  {
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    36
    if ( $rule == 'Code' )
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    37
    {
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    38
      unset($tw->rules[$i]);
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    39
      return true;
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    40
    }
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    41
  }
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    42
}
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    43
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    44
// Prevent <code> tags from being stripped or sanitized (the plugin will handle all sanitation)
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    45
$plugins->attachHook('render_sanitize_pre', 'geshi_strip_code($text, $geshi_code_blocks, $random_id);');
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    46
$plugins->attachHook('render_sanitize_post', 'geshi_restore_code($text, $geshi_code_blocks, $random_id);');
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    47
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    48
function geshi_strip_code(&$text, &$codeblocks, $random_id)
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    49
{
4
97d85c22ced7 Fixed incorrect treatment of <nowiki>.
Dan
parents: 2
diff changeset
    50
  // remove nowiki
97d85c22ced7 Fixed incorrect treatment of <nowiki>.
Dan
parents: 2
diff changeset
    51
  $nw = preg_match_all('#<nowiki>(.*?)<\/nowiki>#is', $text, $nowiki);
6
aeecc46f11c6 Worked more on nowiki stuff.
Dan
parents: 5
diff changeset
    52
  
4
97d85c22ced7 Fixed incorrect treatment of <nowiki>.
Dan
parents: 2
diff changeset
    53
  for ( $i = 0; $i < $nw; $i++ )
97d85c22ced7 Fixed incorrect treatment of <nowiki>.
Dan
parents: 2
diff changeset
    54
  {
6
aeecc46f11c6 Worked more on nowiki stuff.
Dan
parents: 5
diff changeset
    55
    $text = str_replace($nowiki[0][$i], '{NOWIKI:'.$random_id.':'.$i.'}', $text);
4
97d85c22ced7 Fixed incorrect treatment of <nowiki>.
Dan
parents: 2
diff changeset
    56
  }
97d85c22ced7 Fixed incorrect treatment of <nowiki>.
Dan
parents: 2
diff changeset
    57
  
1
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    58
  global $geshi_supported_formats;
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    59
  $codeblocks = array();
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    60
  $sf = '(' . implode('|', $geshi_supported_formats) . ')';
2
9e3258dfae15 Updated GeSHi. w00t.
Dan
parents: 1
diff changeset
    61
  $regexp = '/<(code|source) (?:type|lang)="?' . $sf . '"?>(.*?)<\/\\1>/s';
6
aeecc46f11c6 Worked more on nowiki stuff.
Dan
parents: 5
diff changeset
    62
  $count = preg_match_all($regexp, $text, $matches);
1
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    63
  
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    64
  // for debug
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    65
  /*
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    66
  if ( strstr($text, '<code type') )
2
9e3258dfae15 Updated GeSHi. w00t.
Dan
parents: 1
diff changeset
    67
    die('processing codes: <pre>' . htmlspecialchars(print_r($matches, true)) . '</pre><pre>' . htmlspecialchars($text) . '</pre>' . htmlspecialchars($regexp));
1
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    68
  */
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    69
  
6
aeecc46f11c6 Worked more on nowiki stuff.
Dan
parents: 5
diff changeset
    70
  if ( $count > 0 )
aeecc46f11c6 Worked more on nowiki stuff.
Dan
parents: 5
diff changeset
    71
    foreach ( $matches[0] as $i => $match )
aeecc46f11c6 Worked more on nowiki stuff.
Dan
parents: 5
diff changeset
    72
    {
aeecc46f11c6 Worked more on nowiki stuff.
Dan
parents: 5
diff changeset
    73
      $codeblocks[$i] = array(
aeecc46f11c6 Worked more on nowiki stuff.
Dan
parents: 5
diff changeset
    74
          'match' => $match,
aeecc46f11c6 Worked more on nowiki stuff.
Dan
parents: 5
diff changeset
    75
          'lang' => $matches[2][$i],
aeecc46f11c6 Worked more on nowiki stuff.
Dan
parents: 5
diff changeset
    76
          'code' => $matches[3][$i]
aeecc46f11c6 Worked more on nowiki stuff.
Dan
parents: 5
diff changeset
    77
        );
aeecc46f11c6 Worked more on nowiki stuff.
Dan
parents: 5
diff changeset
    78
      $text = str_replace_once($match, "{GESHI_BLOCK:$i:$random_id}", $text);
aeecc46f11c6 Worked more on nowiki stuff.
Dan
parents: 5
diff changeset
    79
    }
4
97d85c22ced7 Fixed incorrect treatment of <nowiki>.
Dan
parents: 2
diff changeset
    80
  
6
aeecc46f11c6 Worked more on nowiki stuff.
Dan
parents: 5
diff changeset
    81
  // restore nowiki
4
97d85c22ced7 Fixed incorrect treatment of <nowiki>.
Dan
parents: 2
diff changeset
    82
  for ( $i = 0; $i < $nw; $i++ )
97d85c22ced7 Fixed incorrect treatment of <nowiki>.
Dan
parents: 2
diff changeset
    83
  {
6
aeecc46f11c6 Worked more on nowiki stuff.
Dan
parents: 5
diff changeset
    84
    $text = str_replace('{NOWIKI:'.$random_id.':'.$i.'}', $nowiki[0][$i], $text);
4
97d85c22ced7 Fixed incorrect treatment of <nowiki>.
Dan
parents: 2
diff changeset
    85
  }
1
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    86
}
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    87
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    88
function geshi_restore_code(&$text, &$codeblocks, $random_id)
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    89
{
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    90
  foreach ( $codeblocks as $i => $match )
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    91
  {
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    92
    $text = str_replace_once("{GESHI_BLOCK:$i:$random_id}", $match['match'], $text);
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    93
  }
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    94
}
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    95
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    96
// Formatter hook - where the actual highlighting is performed
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    97
$plugins->attachHook('render_wikiformat_veryearly', 'geshi_strip_code($text, $codeblocks, $random_id);');
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    98
$plugins->attachHook('render_wikiformat_post', 'geshi_perform_highlight($result, $codeblocks, $random_id);');
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
    99
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   100
function geshi_perform_highlight(&$text, &$codeblocks, $random_id)
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   101
{
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   102
  static $did_header_tweak = false;
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   103
  if ( !$did_header_tweak )
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   104
  {
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   105
    $did_header_tweak = true;
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   106
    global $template;
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   107
    $template->add_header('<style type="text/css">
2
9e3258dfae15 Updated GeSHi. w00t.
Dan
parents: 1
diff changeset
   108
      .geshi_highlighted a {
1
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   109
        background-image: none !important;
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   110
        padding-right: 0 !important;
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   111
      }
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   112
      </style>
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   113
      ');
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   114
  }
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   115
  if ( !defined('GESHI_ROOT') )
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   116
    define('GESHI_ROOT', ENANO_ROOT . '/plugins/geshi/');
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   117
  
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   118
  require_once ( GESHI_ROOT . '/base.php' );
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   119
  
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   120
  foreach ( $codeblocks as $i => $match )
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   121
  {
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   122
    $lang =& $match['lang'];
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   123
    $code =& $match['code'];
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   124
    
5
bfe00fc686f2 Improved trim behavior; removed that dumb side-scrolling hack (it borked up some stuff on enanocms.org)
Dan
parents: 4
diff changeset
   125
    $geshi = new GeSHi(trim($code, "\r\n"), $lang, null);
1
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   126
    $geshi->set_header_type(GESHI_HEADER_PRE);
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   127
    // $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   128
    $geshi->set_overall_class('geshi_highlighted');
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   129
    $parsed = $geshi->parse_code();
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   130
    
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   131
    $text = str_replace_once("{GESHI_BLOCK:$i:$random_id}", $parsed, $text);
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   132
  }
c715631f809a First working commit. Works using <code type="whatvever">...</code>. Supports all languages supported by default in GeSHi
Dan
parents: 0
diff changeset
   133
}