Location: PHPKode > projects > Pieforms > pieforms-php5-0.2.2/doc/highlighter.php
<?php
/**
 * Highlights the given source using GeSHi
 */

if (!isset($argv[1])) {
    die('oops: no source passed!');
}
$source = $argv[1];
if (!isset($argv[2])) {
    die('oops: no language passed!');
}
$language = $argv[2];

// Remove the two leading lines
$source = substr($source, strpos($source, "\n") + 1);
$source = trim($source);

$phphack = false;
if (substr($language, 0, 3) == 'php' && substr($source, 0, 5) != '<?php') {
    $phphack = true;
    $source = '<?php' . $source . '?>';
}

$source = preg_replace('/^    /m', '', $source);

require_once('geshi/class.geshi.php');
$geshi = new GeSHi($source, $language);
$result = $geshi->parseCode();

if ($phphack) {
    $result = preg_replace('/<span[^>]*>&lt;\?php<\/span>/', '', $result);
    $result = preg_replace('/<span[^>]*>\?&gt;<\/span>/', '', $result);
}

echo $result;

?>
Return current item: Pieforms