Source for file geshi.php
Documentation is available at geshi.php
* @package Mambo Open Source
* @copyright (C) 2005 - 2006 Mambo Foundation Inc.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* Mambo was originally developed by Miro (www.miro.com.au) in 2000. Miro assigned the copyright in Mambo to The Mambo Foundation in 2005 to ensure
* that Mambo remained free Open Source software owned and managed by the community.
/** ensure this file is being included by a parent file */
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
$startfunc =
array (&$this, 'start_element');
$endfunc =
array (&$this, 'end_element');
$charfunc =
array (&$this, 'character_data');
function parse ($arguments) {
function start_element ($parser, $element_name, $element_attrs) {
if ($element_name ==
'PRE') $pattrs =
$element_attrs;
$_MAMBOTS->registerFunction( 'onPrepareContent', 'botGeshi' );
* Code Highlighting Mambot
* Replaces <pre>...</pre> tags with highlighted text
function botGeshi( $published, &$row, &$params, $page=
0 ) {
// define the regular expression for the bot
$regex =
"#<pre\s*(.*?)>(.*?)</pre>#s";
if (is_callable(array($row, 'getText'))) $localtext =
$row->getText();
else $localtext =
$row->text;
if (is_callable(array($row, 'saveText'))) $row->saveText($localtext);
else $row->text =
$localtext;
$GLOBALS['_MAMBOT_GESHI_PARAMS'] =
& $params;
// perform the replacement
if (is_callable(array($row, 'saveText'))) $row->saveText($localtext);
else $row->text =
$localtext;
* Replaces the matched tags an image
* @param array An array of matches (see preg_match_all)
$params =
& $GLOBALS['_MAMBOT_GESHI_PARAMS'];
include_once( dirname( __FILE__
) .
'/geshi/geshi.php' );
$args =
$parser->parse($matches[1]);
$html_entities_match =
array( "|\<br \/\>|", "#<#", "#>#", "|'|", '#"#', '# #' );
$html_entities_replace =
array( "\n", '<', '>', "'", '"', ' ' );
$text =
preg_replace( $html_entities_match, $html_entities_replace, $text );
// Replace 2 spaces with " " so non-tabbed code indents without making huge long lines.
$text = str_replace(" ", " ", $text);
// now Replace 2 spaces with " " to catch odd #s of spaces.
$text = str_replace(" ", " ", $text);
// Replace tabs with " " so tabbed code indents sorta right without making huge long lines.
//$text = str_replace("\t", " ", $text);
$geshi =
new GeSHi( $text, $lang, dirname( __FILE__
) .
'/geshi/geshi' );
$text =
$geshi->parse_code();
Documentation generated on Mon, 05 May 2008 16:20:00 +0400 by phpDocumentor 1.4.0