summaryrefslogtreecommitdiff
path: root/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/SyntaxHighlight_GeSHi/geshi/geshi.php')
-rw-r--r--extensions/SyntaxHighlight_GeSHi/geshi/geshi.php76
1 files changed, 48 insertions, 28 deletions
diff --git a/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php b/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php
index aedc64f8..60741577 100644
--- a/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php
+++ b/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php
@@ -41,7 +41,7 @@
//
/** 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
if (!defined('GESHI_ROOT')) {
@@ -595,16 +595,27 @@ class GeSHi {
* @since 1.0.0
*/
function GeSHi($source = '', $language = '', $path = '') {
- if (!empty($source)) {
+ if ($source !== '') {
$this->set_source($source);
}
- if (!empty($language)) {
+ if ($language !== '') {
$this->set_language($language);
}
$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,
* or false if no error has occured
*
@@ -808,7 +819,7 @@ class GeSHi {
}
// 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);
return false;
}
@@ -1437,6 +1448,8 @@ class GeSHi {
* @todo static?
*/
function get_language_name_from_extension( $extension, $lookup = array() ) {
+ $extension = strtolower($extension);
+
if ( !is_array($lookup) || empty($lookup)) {
$lookup = array(
'6502acme' => array( 'a', 's', 'asm', 'inc' ),
@@ -1470,6 +1483,7 @@ class GeSHi {
'gnuplot' => array('plt'),
'groovy' => array('groovy'),
'haskell' => array('hs'),
+ 'haxe' => array('hx'),
'html4strict' => array('html', 'htm'),
'ini' => array('ini', 'desktop'),
'java' => array('java'),
@@ -1504,6 +1518,7 @@ class GeSHi {
'smalltalk' => array('st'),
'smarty' => array(),
'tcl' => array('tcl'),
+ 'text' => array('txt'),
'vb' => array('bas'),
'vbnet' => array(),
'visualfoxpro' => array(),
@@ -1518,7 +1533,8 @@ class GeSHi {
return $lang;
}
}
- return '';
+
+ return 'text';
}
/**
@@ -1555,6 +1571,9 @@ class GeSHi {
* @since 1.0.0
*/
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])) {
$this->language_data['KEYWORDS'][$key][] = $word;
@@ -1816,7 +1835,7 @@ class GeSHi {
//Decide on which style to use
if ($style === null) { //Check if we should use default style
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_styles[$lines]);
} else {
@@ -1988,7 +2007,7 @@ class GeSHi {
$this->language_data['SYMBOL_DATA'][$symbols] = 0;
if (isset($symbols[1])) { // multiple chars
$symbol_preg_multi[] = preg_quote($symbols, '/');
- } else if ($symbols == '-') {
+ } elseif ($symbols == '-') {
// don't trigger range out of order error
$symbol_preg_single[] = '\-';
} else { // single char
@@ -2113,7 +2132,7 @@ class GeSHi {
}
$this->language_data['NUMBERS_RXCACHE'][$key] =
- "/(?<!<\|\/)(?<!<\|!REG3XP)(?<!<\|\/NUM!)(?<!\d\/>)($regexp)(?!(?:<DOT>|(?>[^\<]))+>)(?![^<]*>)(?!\|>)(?!\/>)/i"; //
+ "/(?<!<\|\/)(?<!<\|!REG3XP)(?<!<\|\/NUM!)(?<!\d\/>)($regexp)(?!(?:<DOT>|(?>[^\<]+))+>)(?![^<]*>)(?!\|>)(?!\/>)/i"; //
}
if(!isset($this->language_data['PARSER_CONTROL']['NUMBERS']['PRECHECK_RX'])) {
@@ -2392,7 +2411,7 @@ class GeSHi {
foreach ($this->language_data['QUOTEMARKS'] as $quotemark) {
if (!isset($is_string_starter[$quotemark[0]])) {
$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]],
$quotemark);
@@ -2478,7 +2497,7 @@ class GeSHi {
continue;
}
$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
(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))
@@ -2586,7 +2605,7 @@ class GeSHi {
continue;
}
$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
(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))
@@ -2656,13 +2675,13 @@ class GeSHi {
// don't put a newline around newlines
$string .= "</span>\n";
$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 code tries to work around SF#2037598 ...
if(function_exists('mb_substr')) {
$es_char_m = mb_substr(substr($part, $es_pos+1, 16), 0, 1, $this->encoding);
$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]".
"|\xE0[\xA0-\xBF][\x80-\xBF]".
"|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}".
@@ -2684,7 +2703,7 @@ class GeSHi {
$string .= $this->hsc($es_char) . '</span>';
$start = $es_pos + 2;
}
- } else if ($next_escape_regexp_pos < $length &&
+ } elseif ($next_escape_regexp_pos < $length &&
$next_escape_regexp_pos < $close_pos) {
$es_pos = $next_escape_regexp_pos;
//Add the stuff not in the string yet ...
@@ -2728,7 +2747,7 @@ class GeSHi {
$string = '';
$i = $start - 1;
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)) {
// The start of a hard quoted string
if (!$this->use_classes) {
@@ -2886,7 +2905,7 @@ class GeSHi {
continue;
}
$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;
} else {
$comment_multi_cache_per_key[$open] = false;
@@ -2983,7 +3002,7 @@ class GeSHi {
continue;
}
$match_i = $comment_single_cache_per_key[$comment_key];
- } else if (
+ } elseif (
// case sensitive comments
($this->language_data['CASE_SENSITIVE'][GESHI_COMMENTS] &&
($match_i = stripos($part, $comment_mark, $i)) !== false) ||
@@ -3140,10 +3159,10 @@ class GeSHi {
$IN_TAG = false;
}
$lines[$key] .= $char;
- } else if ('<' == $char) {
+ } elseif ('<' == $char) {
$IN_TAG = true;
$lines[$key] .= '<';
- } else if ('&' == $char) {
+ } elseif ('&' == $char) {
$substr = substr($line, $i + 3, 5);
$posi = strpos($substr, ';');
if (false === $posi) {
@@ -3152,7 +3171,7 @@ class GeSHi {
$pos -= $posi+2;
}
$lines[$key] .= $char;
- } else if ("\t" == $char) {
+ } elseif ("\t" == $char) {
$str = '';
// OPTIMISE - move $strs out. Make an array:
// $tabs = array(
@@ -3173,7 +3192,7 @@ class GeSHi {
$lines[$key] .= substr($line, $i + 1);
break;
}
- } else if (0 == $pos && ' ' == $char) {
+ } elseif (0 == $pos && ' ' == $char) {
$lines[$key] .= '&nbsp;';
++$pos;
} else {
@@ -3231,6 +3250,7 @@ class GeSHi {
function handle_keyword_replace($match) {
$k = $this->_kw_replace_group;
$keyword = $match[0];
+ $keyword_match = $match[1];
$before = '';
$after = '';
@@ -3248,12 +3268,12 @@ class GeSHi {
if (!$this->language_data['CASE_SENSITIVE'][$k] &&
strpos($this->language_data['URLS'][$k], '{FNAME}') !== false) {
foreach ($this->language_data['KEYWORDS'][$k] as $word) {
- if (strcasecmp($word, $keyword) == 0) {
+ if (strcasecmp($word, $keyword_match) == 0) {
break;
}
}
} else {
- $word = $keyword;
+ $word = $keyword_match;
}
$before = '<|UR1|"' .
@@ -3367,7 +3387,7 @@ class GeSHi {
foreach (array_keys($this->language_data['KEYWORDS']) as $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];
$modifiers = $case_sensitive ? '' : 'i';
@@ -3991,7 +4011,7 @@ class GeSHi {
$parsed_code .= $this->line_numbers_start + $i;
if ($close) {
$parsed_code .= str_repeat('</span>', $close);
- } else if ($i != $n) {
+ } elseif ($i != $n) {
$parsed_code .= "\n";
}
}
@@ -4123,10 +4143,10 @@ class GeSHi {
if ($this->line_numbers != GESHI_NO_LINE_NUMBERS) {
if ($this->header_type == GESHI_HEADER_PRE) {
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) {
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\">";
}
} else {
@@ -4752,4 +4772,4 @@ if (!function_exists('geshi_highlight')) {
}
}
-?> \ No newline at end of file
+?>