summaryrefslogtreecommitdiff
path: root/inc/geshi.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2013-02-03 22:57:45 +0100
committerAndreas Gohr <andi@splitbrain.org>2013-02-03 22:57:45 +0100
commit3da7921f08ecdda929466921ecc50698f1adf99e (patch)
tree0e179e504399e874bfd785d0a95eec44b76d5952 /inc/geshi.php
parent6cf2bbfa12b776cf47cb69ae40fb8862f715ad01 (diff)
parentcc4bb766fdac23358d7b586aa3830b9650eed7a8 (diff)
downloadrpg-3da7921f08ecdda929466921ecc50698f1adf99e.tar.gz
rpg-3da7921f08ecdda929466921ecc50698f1adf99e.tar.bz2
Merge branch 'master' into future
* master: (162 commits) fixed revision JS for images upgraded SimplePie to 1.3.1 FS#2708 removed obsolete browser plugin (migrate does it) adjust spacing to match standard 1.4em grid added comment on use of whitelist vs blacklist Updated idfilter() function for IIS use var and remove suggestions when needed Use variable for maximum number of suggestions for quicksearch. And hide suggestions when search field is emptied, or when no suggestion are found. added 'home' class to first link in hierarchical breadcrumbs reduced required max width to go into tablet mode re-added linear gradients for firefox added missing styling for disabled form elements (FS#2705) fixed acronyms in italics (FS#2684) improved print styles (includes fixes for FS#2645 and FS#2707) basic styles improvements Greek language update Use list in acl help text, for more structure Galician language update touch the config on save, even if no changes were made unwind the width narrowing commit put some whitespace between form submit button and fieldset bottom border ... Conflicts: lib/plugins/config/admin.php lib/plugins/config/settings/config.class.php
Diffstat (limited to 'inc/geshi.php')
-rw-r--r--inc/geshi.php68
1 files changed, 44 insertions, 24 deletions
diff --git a/inc/geshi.php b/inc/geshi.php
index aedc64f84..c6ff9ef77 100644
--- a/inc/geshi.php
+++ b/inc/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')) {
@@ -605,6 +605,17 @@ class GeSHi {
}
/**
+ * 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
@@ -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 {