update genshi to 1.0.8.11

This commit is contained in:
XhmikosR 2012-09-19 21:09:59 +03:00 committed by PKEuS
parent 9cbeb3f4a1
commit a30d49a919
3 changed files with 46 additions and 26 deletions

View File

@ -41,7 +41,7 @@
// //
/** The version of this GeSHi file */ /** The version of this GeSHi file */
define('GESHI_VERSION', '1.0.8.10'); define('GESHI_VERSION', '1.0.8.11');
// Define the root directory for the GeSHi code tree // Define the root directory for the GeSHi code tree
if (!defined('GESHI_ROOT')) { if (!defined('GESHI_ROOT')) {
@ -604,6 +604,17 @@ class GeSHi {
$this->set_language_path($path); $this->set_language_path($path);
} }
/**
* Returns the version of GeSHi
*
* @return string
* @since 1 0.8.11
*/
function get_version()
{
return GESHI_VERSION;
}
/** /**
* Returns an error message associated with the last GeSHi operation, * Returns an error message associated with the last GeSHi operation,
* or false if no error has occured * or false if no error has occured
@ -808,7 +819,7 @@ class GeSHi {
} }
// match the langname // match the langname
if (!preg_match('/\'LANG_NAME\'\s*=>\s*\'((?:[^\']|\\\')+)\'/', $data, $matches)) { if (!preg_match('/\'LANG_NAME\'\s*=>\s*\'((?:[^\']|\\\')+?)\'/', $data, $matches)) {
$this->error = sprintf('Geshi::get_lang_fullname(%s): Regex can not detect language', $language); $this->error = sprintf('Geshi::get_lang_fullname(%s): Regex can not detect language', $language);
return false; return false;
} }
@ -1437,6 +1448,8 @@ class GeSHi {
* @todo static? * @todo static?
*/ */
function get_language_name_from_extension( $extension, $lookup = array() ) { function get_language_name_from_extension( $extension, $lookup = array() ) {
$extension = strtolower($extension);
if ( !is_array($lookup) || empty($lookup)) { if ( !is_array($lookup) || empty($lookup)) {
$lookup = array( $lookup = array(
'6502acme' => array( 'a', 's', 'asm', 'inc' ), '6502acme' => array( 'a', 's', 'asm', 'inc' ),
@ -1470,6 +1483,7 @@ class GeSHi {
'gnuplot' => array('plt'), 'gnuplot' => array('plt'),
'groovy' => array('groovy'), 'groovy' => array('groovy'),
'haskell' => array('hs'), 'haskell' => array('hs'),
'haxe' => array('hx'),
'html4strict' => array('html', 'htm'), 'html4strict' => array('html', 'htm'),
'ini' => array('ini', 'desktop'), 'ini' => array('ini', 'desktop'),
'java' => array('java'), 'java' => array('java'),
@ -1504,6 +1518,7 @@ class GeSHi {
'smalltalk' => array('st'), 'smalltalk' => array('st'),
'smarty' => array(), 'smarty' => array(),
'tcl' => array('tcl'), 'tcl' => array('tcl'),
'text' => array('txt'),
'vb' => array('bas'), 'vb' => array('bas'),
'vbnet' => array(), 'vbnet' => array(),
'visualfoxpro' => array(), 'visualfoxpro' => array(),
@ -1518,7 +1533,8 @@ class GeSHi {
return $lang; return $lang;
} }
} }
return '';
return 'text';
} }
/** /**
@ -1555,6 +1571,9 @@ class GeSHi {
* @since 1.0.0 * @since 1.0.0
*/ */
function add_keyword($key, $word) { function add_keyword($key, $word) {
if (!is_array($this->language_data['KEYWORDS'][$key])) {
$this->language_data['KEYWORDS'][$key] = array();
}
if (!in_array($word, $this->language_data['KEYWORDS'][$key])) { if (!in_array($word, $this->language_data['KEYWORDS'][$key])) {
$this->language_data['KEYWORDS'][$key][] = $word; $this->language_data['KEYWORDS'][$key][] = $word;
@ -1816,7 +1835,7 @@ class GeSHi {
//Decide on which style to use //Decide on which style to use
if ($style === null) { //Check if we should use default style if ($style === null) { //Check if we should use default style
unset($this->highlight_extra_lines_styles[$lines]); unset($this->highlight_extra_lines_styles[$lines]);
} else if ($style === false) { //Check if to remove this line } elseif ($style === false) { //Check if to remove this line
unset($this->highlight_extra_lines[$lines]); unset($this->highlight_extra_lines[$lines]);
unset($this->highlight_extra_lines_styles[$lines]); unset($this->highlight_extra_lines_styles[$lines]);
} else { } else {
@ -1988,7 +2007,7 @@ class GeSHi {
$this->language_data['SYMBOL_DATA'][$symbols] = 0; $this->language_data['SYMBOL_DATA'][$symbols] = 0;
if (isset($symbols[1])) { // multiple chars if (isset($symbols[1])) { // multiple chars
$symbol_preg_multi[] = preg_quote($symbols, '/'); $symbol_preg_multi[] = preg_quote($symbols, '/');
} else if ($symbols == '-') { } elseif ($symbols == '-') {
// don't trigger range out of order error // don't trigger range out of order error
$symbol_preg_single[] = '\-'; $symbol_preg_single[] = '\-';
} else { // single char } else { // single char
@ -2392,7 +2411,7 @@ class GeSHi {
foreach ($this->language_data['QUOTEMARKS'] as $quotemark) { foreach ($this->language_data['QUOTEMARKS'] as $quotemark) {
if (!isset($is_string_starter[$quotemark[0]])) { if (!isset($is_string_starter[$quotemark[0]])) {
$is_string_starter[$quotemark[0]] = (string)$quotemark; $is_string_starter[$quotemark[0]] = (string)$quotemark;
} else if (is_string($is_string_starter[$quotemark[0]])) { } elseif (is_string($is_string_starter[$quotemark[0]])) {
$is_string_starter[$quotemark[0]] = array( $is_string_starter[$quotemark[0]] = array(
$is_string_starter[$quotemark[0]], $is_string_starter[$quotemark[0]],
$quotemark); $quotemark);
@ -2478,7 +2497,7 @@ class GeSHi {
continue; continue;
} }
$match_i = $comment_regexp_cache_per_key[$comment_key]['pos']; $match_i = $comment_regexp_cache_per_key[$comment_key]['pos'];
} else if ( } elseif (
//This is to allow use of the offset parameter in preg_match and stay as compatible with older PHP versions as possible //This is to allow use of the offset parameter in preg_match and stay as compatible with older PHP versions as possible
(GESHI_PHP_PRE_433 && preg_match($regexp, substr($part, $i), $match, PREG_OFFSET_CAPTURE)) || (GESHI_PHP_PRE_433 && preg_match($regexp, substr($part, $i), $match, PREG_OFFSET_CAPTURE)) ||
(!GESHI_PHP_PRE_433 && preg_match($regexp, $part, $match, PREG_OFFSET_CAPTURE, $i)) (!GESHI_PHP_PRE_433 && preg_match($regexp, $part, $match, PREG_OFFSET_CAPTURE, $i))
@ -2586,7 +2605,7 @@ class GeSHi {
continue; continue;
} }
$match_i = $escape_regexp_cache_per_key[$escape_key]['pos']; $match_i = $escape_regexp_cache_per_key[$escape_key]['pos'];
} else if ( } elseif (
//This is to allow use of the offset parameter in preg_match and stay as compatible with older PHP versions as possible //This is to allow use of the offset parameter in preg_match and stay as compatible with older PHP versions as possible
(GESHI_PHP_PRE_433 && preg_match($regexp, substr($part, $start), $match, PREG_OFFSET_CAPTURE)) || (GESHI_PHP_PRE_433 && preg_match($regexp, substr($part, $start), $match, PREG_OFFSET_CAPTURE)) ||
(!GESHI_PHP_PRE_433 && preg_match($regexp, $part, $match, PREG_OFFSET_CAPTURE, $start)) (!GESHI_PHP_PRE_433 && preg_match($regexp, $part, $match, PREG_OFFSET_CAPTURE, $start))
@ -2656,13 +2675,13 @@ class GeSHi {
// don't put a newline around newlines // don't put a newline around newlines
$string .= "</span>\n"; $string .= "</span>\n";
$start = $es_pos + 2; $start = $es_pos + 2;
} else if (ord($es_char) >= 128) { } elseif (ord($es_char) >= 128) {
//This is an non-ASCII char (UTF8 or single byte) //This is an non-ASCII char (UTF8 or single byte)
//This code tries to work around SF#2037598 ... //This code tries to work around SF#2037598 ...
if(function_exists('mb_substr')) { if(function_exists('mb_substr')) {
$es_char_m = mb_substr(substr($part, $es_pos+1, 16), 0, 1, $this->encoding); $es_char_m = mb_substr(substr($part, $es_pos+1, 16), 0, 1, $this->encoding);
$string .= $es_char_m . '</span>'; $string .= $es_char_m . '</span>';
} else if (!GESHI_PHP_PRE_433 && 'utf-8' == $this->encoding) { } elseif (!GESHI_PHP_PRE_433 && 'utf-8' == $this->encoding) {
if(preg_match("/[\xC2-\xDF][\x80-\xBF]". if(preg_match("/[\xC2-\xDF][\x80-\xBF]".
"|\xE0[\xA0-\xBF][\x80-\xBF]". "|\xE0[\xA0-\xBF][\x80-\xBF]".
"|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}". "|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}".
@ -2684,7 +2703,7 @@ class GeSHi {
$string .= $this->hsc($es_char) . '</span>'; $string .= $this->hsc($es_char) . '</span>';
$start = $es_pos + 2; $start = $es_pos + 2;
} }
} else if ($next_escape_regexp_pos < $length && } elseif ($next_escape_regexp_pos < $length &&
$next_escape_regexp_pos < $close_pos) { $next_escape_regexp_pos < $close_pos) {
$es_pos = $next_escape_regexp_pos; $es_pos = $next_escape_regexp_pos;
//Add the stuff not in the string yet ... //Add the stuff not in the string yet ...
@ -2728,7 +2747,7 @@ class GeSHi {
$string = ''; $string = '';
$i = $start - 1; $i = $start - 1;
continue; continue;
} else if ($this->lexic_permissions['STRINGS'] && $hq && $hq[0] == $char && } elseif ($this->lexic_permissions['STRINGS'] && $hq && $hq[0] == $char &&
substr($part, $i, $hq_strlen) == $hq && ($i != $next_comment_regexp_pos)) { substr($part, $i, $hq_strlen) == $hq && ($i != $next_comment_regexp_pos)) {
// The start of a hard quoted string // The start of a hard quoted string
if (!$this->use_classes) { if (!$this->use_classes) {
@ -2886,7 +2905,7 @@ class GeSHi {
continue; continue;
} }
$match_i = $comment_multi_cache_per_key[$open]; $match_i = $comment_multi_cache_per_key[$open];
} else if (($match_i = stripos($part, $open, $i)) !== false) { } elseif (($match_i = stripos($part, $open, $i)) !== false) {
$comment_multi_cache_per_key[$open] = $match_i; $comment_multi_cache_per_key[$open] = $match_i;
} else { } else {
$comment_multi_cache_per_key[$open] = false; $comment_multi_cache_per_key[$open] = false;
@ -2983,7 +3002,7 @@ class GeSHi {
continue; continue;
} }
$match_i = $comment_single_cache_per_key[$comment_key]; $match_i = $comment_single_cache_per_key[$comment_key];
} else if ( } elseif (
// case sensitive comments // case sensitive comments
($this->language_data['CASE_SENSITIVE'][GESHI_COMMENTS] && ($this->language_data['CASE_SENSITIVE'][GESHI_COMMENTS] &&
($match_i = stripos($part, $comment_mark, $i)) !== false) || ($match_i = stripos($part, $comment_mark, $i)) !== false) ||
@ -3140,10 +3159,10 @@ class GeSHi {
$IN_TAG = false; $IN_TAG = false;
} }
$lines[$key] .= $char; $lines[$key] .= $char;
} else if ('<' == $char) { } elseif ('<' == $char) {
$IN_TAG = true; $IN_TAG = true;
$lines[$key] .= '<'; $lines[$key] .= '<';
} else if ('&' == $char) { } elseif ('&' == $char) {
$substr = substr($line, $i + 3, 5); $substr = substr($line, $i + 3, 5);
$posi = strpos($substr, ';'); $posi = strpos($substr, ';');
if (false === $posi) { if (false === $posi) {
@ -3152,7 +3171,7 @@ class GeSHi {
$pos -= $posi+2; $pos -= $posi+2;
} }
$lines[$key] .= $char; $lines[$key] .= $char;
} else if ("\t" == $char) { } elseif ("\t" == $char) {
$str = ''; $str = '';
// OPTIMISE - move $strs out. Make an array: // OPTIMISE - move $strs out. Make an array:
// $tabs = array( // $tabs = array(
@ -3173,7 +3192,7 @@ class GeSHi {
$lines[$key] .= substr($line, $i + 1); $lines[$key] .= substr($line, $i + 1);
break; break;
} }
} else if (0 == $pos && ' ' == $char) { } elseif (0 == $pos && ' ' == $char) {
$lines[$key] .= '&nbsp;'; $lines[$key] .= '&nbsp;';
++$pos; ++$pos;
} else { } else {
@ -3231,6 +3250,7 @@ class GeSHi {
function handle_keyword_replace($match) { function handle_keyword_replace($match) {
$k = $this->_kw_replace_group; $k = $this->_kw_replace_group;
$keyword = $match[0]; $keyword = $match[0];
$keyword_match = $match[1];
$before = ''; $before = '';
$after = ''; $after = '';
@ -3248,12 +3268,12 @@ class GeSHi {
if (!$this->language_data['CASE_SENSITIVE'][$k] && if (!$this->language_data['CASE_SENSITIVE'][$k] &&
strpos($this->language_data['URLS'][$k], '{FNAME}') !== false) { strpos($this->language_data['URLS'][$k], '{FNAME}') !== false) {
foreach ($this->language_data['KEYWORDS'][$k] as $word) { foreach ($this->language_data['KEYWORDS'][$k] as $word) {
if (strcasecmp($word, $keyword) == 0) { if (strcasecmp($word, $keyword_match) == 0) {
break; break;
} }
} }
} else { } else {
$word = $keyword; $word = $keyword_match;
} }
$before = '<|UR1|"' . $before = '<|UR1|"' .
@ -3367,7 +3387,7 @@ class GeSHi {
foreach (array_keys($this->language_data['KEYWORDS']) as $k) { foreach (array_keys($this->language_data['KEYWORDS']) as $k) {
if (!isset($this->lexic_permissions['KEYWORDS'][$k]) || if (!isset($this->lexic_permissions['KEYWORDS'][$k]) ||
$this->lexic_permissions['KEYWORDS'][$k]) { $this->lexic_permissions['KEYWORDS'][$k]) {
$case_sensitive = $this->language_data['CASE_SENSITIVE'][$k]; $case_sensitive = $this->language_data['CASE_SENSITIVE'][$k];
$modifiers = $case_sensitive ? '' : 'i'; $modifiers = $case_sensitive ? '' : 'i';
@ -3991,7 +4011,7 @@ class GeSHi {
$parsed_code .= $this->line_numbers_start + $i; $parsed_code .= $this->line_numbers_start + $i;
if ($close) { if ($close) {
$parsed_code .= str_repeat('</span>', $close); $parsed_code .= str_repeat('</span>', $close);
} else if ($i != $n) { } elseif ($i != $n) {
$parsed_code .= "\n"; $parsed_code .= "\n";
} }
} }
@ -4123,10 +4143,10 @@ class GeSHi {
if ($this->line_numbers != GESHI_NO_LINE_NUMBERS) { if ($this->line_numbers != GESHI_NO_LINE_NUMBERS) {
if ($this->header_type == GESHI_HEADER_PRE) { if ($this->header_type == GESHI_HEADER_PRE) {
return "<pre$attributes>$header<ol$ol_attributes>"; return "<pre$attributes>$header<ol$ol_attributes>";
} else if ($this->header_type == GESHI_HEADER_DIV || } elseif ($this->header_type == GESHI_HEADER_DIV ||
$this->header_type == GESHI_HEADER_PRE_VALID) { $this->header_type == GESHI_HEADER_PRE_VALID) {
return "<div$attributes>$header<ol$ol_attributes>"; return "<div$attributes>$header<ol$ol_attributes>";
} else if ($this->header_type == GESHI_HEADER_PRE_TABLE) { } elseif ($this->header_type == GESHI_HEADER_PRE_TABLE) {
return "<table$attributes>$header<tbody><tr class=\"li1\">"; return "<table$attributes>$header<tbody><tr class=\"li1\">";
} }
} else { } else {

View File

@ -7,7 +7,7 @@
* - Jack Lloyd (lloyd@randombit.net) * - Jack Lloyd (lloyd@randombit.net)
* - Michael Mol (mikemol@gmail.com) * - Michael Mol (mikemol@gmail.com)
* Copyright: (c) 2004 Nigel McNie (http://qbnz.com/highlighter/) * Copyright: (c) 2004 Nigel McNie (http://qbnz.com/highlighter/)
* Release Version: 1.0.8.10 * Release Version: 1.0.8.11
* Date Started: 2004/06/04 * Date Started: 2004/06/04
* *
* C language file for GeSHi. * C language file for GeSHi.

View File

@ -7,7 +7,7 @@
* - M. Uli Kusterer (witness.of.teachtext@gmx.net) * - M. Uli Kusterer (witness.of.teachtext@gmx.net)
* - Jack Lloyd (lloyd@randombit.net) * - Jack Lloyd (lloyd@randombit.net)
* Copyright: (c) 2004 Dennis Bayer, Nigel McNie (http://qbnz.com/highlighter) * Copyright: (c) 2004 Dennis Bayer, Nigel McNie (http://qbnz.com/highlighter)
* Release Version: 1.0.8.10 * Release Version: 1.0.8.11
* Date Started: 2004/09/27 * Date Started: 2004/09/27
* *
* C++ language file for GeSHi. * C++ language file for GeSHi.