diff options
author | Andreas Gohr <andi@splitbrain.org> | 2006-07-23 22:32:32 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2006-07-23 22:32:32 +0200 |
commit | 850d6bf6605add7df9c86492766d6427b48ef994 (patch) | |
tree | 8fee9520e2652ac723356e6abc6c70e1d9d2202f /inc/geshi.php | |
parent | f29dc969d01ee203ff62ce2fd38ba3d7d66935a9 (diff) | |
download | rpg-850d6bf6605add7df9c86492766d6427b48ef994.tar.gz rpg-850d6bf6605add7df9c86492766d6427b48ef994.tar.bz2 |
GeSHi update to 1.0.7.12
darcs-hash:20060723203232-7ad00-a675d33962148272e5dd13ac2190ef259f8eaad2.gz
Diffstat (limited to 'inc/geshi.php')
-rw-r--r-- | inc/geshi.php | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/inc/geshi.php b/inc/geshi.php index ee7b94269..4e709fe22 100644 --- a/inc/geshi.php +++ b/inc/geshi.php @@ -2,11 +2,12 @@ /** * GeSHi - Generic Syntax Highlighter * - * The GeSHi class for Generic Syntax Highlighting. Please refer to the documentation - * at http://qbnz.com/highlighter/documentation.php for more information about how to - * use this class. + * The GeSHi class for Generic Syntax Highlighting. Please refer to the + * documentation at http://qbnz.com/highlighter/documentation.php for more + * information about how to use this class. * - * For changes, release notes, TODOs etc, see the relevant files in the docs/ directory + * For changes, release notes, TODOs etc, see the relevant files in the docs/ + * directory. * * This file is part of GeSHi. * @@ -28,7 +29,7 @@ * @author Nigel McNie <nigel@geshi.org> * @copyright Copyright © 2004, 2005, Nigel McNie * @license http://gnu.org/copyleft/gpl.html GNU GPL - * @version $Id: geshi.php,v 1.40.2.1 2006/06/21 10:35:33 oracleshinoda Exp $ + * @version $Id: geshi.php,v 1.40.2.5 2006/07/22 11:30:40 oracleshinoda Exp $ * */ @@ -40,7 +41,7 @@ // /** The version of this GeSHi file */ -define('GESHI_VERSION', '1.0.7.11'); +define('GESHI_VERSION', '1.0.7.12'); /** Set the correct directory separator */ define('GESHI_DIR_SEPARATOR', ('WIN' != substr(PHP_OS, 0, 3)) ? '/' : '\\'); @@ -1414,11 +1415,11 @@ class GeSHi return $this->finalise($result); } - // Add spaces for regular expression matching and line numbers - $code = ' ' . $this->source . ' '; // Replace all newlines to a common form. - $code = str_replace("\r\n", "\n", $code); + $code = str_replace("\r\n", "\n", $this->source); $code = str_replace("\r", "\n", $code); + // Add spaces for regular expression matching and line numbers + $code = "\n" . $code . "\n"; // Initialise various stuff $length = strlen($code); @@ -2264,6 +2265,11 @@ class GeSHi $parsed_code = $this->indent($parsed_code); } + // purge some unnecessary stuff + $parsed_code = preg_replace('#<span[^>]+>(\s*)</span>#', '\\1', $parsed_code); + $parsed_code = preg_replace('#<div[^>]+>(\s*)</div>#', '\\1', $parsed_code); + + // If we're using line numbers, we insert <li>s and appropriate // markup to style them (otherwise we don't need to do anything) if ($this->line_numbers != GESHI_NO_LINE_NUMBERS) { @@ -2278,8 +2284,10 @@ class GeSHi $attrs = array(); // Foreach line... - foreach ($code as $line) { - $line = ( $line ) ? $line : ' '; + foreach ($code as $line) {//echo "LINE:|".htmlspecialchars($line)."| ".strlen($line)."<br />\n"; + if ('' == $line || ' ' == $line) { + $line = ' '; + } // If this is a "special line"... if ($this->line_numbers == GESHI_FANCY_LINE_NUMBERS && $i % $this->line_nth_row == ($this->line_nth_row - 1)) { @@ -2342,10 +2350,11 @@ class GeSHi $code = explode("\n", $parsed_code); $parsed_code = ''; $i = 0; - foreach ($code as $line) - { + foreach ($code as $line) { // Make lines have at least one space in them if they're empty - $line = ($line) ? $line : ' '; + if ('' == $line || ' ' == $line) { + $line = ' '; + } if (in_array(++$i, $this->highlight_extra_lines)) { if ($this->use_classes) { $parsed_code .= '<div class="ln-xtra">'; @@ -2359,11 +2368,7 @@ class GeSHi } } } - - // purge some unnecessary stuff - $parsed_code = preg_replace('#<span[^>]+>(\s*)</span>#', '\\1', $parsed_code); - $parsed_code = preg_replace('#<div[^>]+>(\s*)</div>#', '\\1', $parsed_code); - + if ($this->header_type == GESHI_HEADER_PRE) { // enforce line numbers when using pre $parsed_code = str_replace('<li></li>', '<li> </li>', $parsed_code); |