Failed
"; echo "
    \n"; foreach($error_cache as $error_msg) { echo "
  1. "; switch($error_msg['t']) { case TYPE_NOTICE: echo "NOTICE:"; break; case TYPE_WARNING: echo "WARNING:"; break; case TYPE_ERROR: echo "ERROR:"; break; } echo " " . $error_msg['m'] . "
  2. "; } echo "
\n"; } else { echo "OK
"; } echo "\n"; $error_cache = array(); } function report_error($type, $message) { global $error_cache, $error_abort; $error_cache[] = array('t' => $type, 'm' => $message); if(TYPE_ERROR == $type) { $error_abort = true; } } ?> GeSHi Language File Generator Script

GeSHi Language File Generator Script

To use this script, make sure that geshi.php is in the parent directory or in your include_path, and that the language files are in a subdirectory of GeSHi's directory called geshi/.

If not already done, select a language file below that will be used as base for the language file to generate or create a blank one. Following this you can do whatever you like to edit your language file. But note that not all features are made available through this script.

Checking GeSHi installation ... 'example', 'name' => 'Example' ); $ai = array( 'name' => 'Benny Baumann', 'email' => 'BenBE@geshi.org', 'web' => 'http://qbnz.com/highlighter/' ); $ld = array( 'cmt' => array( 'sl' => array( 1 => array( 'start' => '//', 'style' => 'font-style: italic; color: #666666;' ), 2 => array( 'start' => '#', 'style' => 'font-style: italic; color: #666666;' ) ), 'ml' => array( 1 => array( 'start' => '/*', 'end' => '*/', 'style' => 'font-style: italic; color: #666666;' ), 2 => array( 'start' => '/**', 'end' => '*/', 'style' => 'font-style: italic; color: #006600;' ) ), 'rxc' => array( 1 => array( 'rx' => '/Hello RegExp/', 'style' => 'font-style: italic; color: #666666;' ) ) ), 'str' => array( 'qm' => array( 1 => array( 'delim' => "'", 'style' => 'color: #0000FF;' ), 2 => array( 'delim' => """, 'style' => 'color: #0000FF;' ) ), 'ec' => array( 'char' => '\\', 'style' => 'font-weight: bold; color: #000080;' ), 'erx' => array( 1 => array( 'rx' => '/\{\\\\$\w+\}/', 'style' => 'font-weight: bold; color: #008080;' ), 2 => array( 'rx'=> '/\{\\\\$\w+\}/', 'style' => 'font-weight: bold; color: #008080;' ) ) ), 'kw_case' => 'GESHI_CAPS_NO_CHANGE', 'kw' => array( 1 => array( 'list' => '', 'case' => '0', 'style' => 'color: #0000FF; font-weight: bold;', 'docs' => '' ) ), 'sy' => array( 0 => array( 'list' => '', 'style' => 'color: #0000FF; font-weight: bold;' ) ) ); $kw_case_sel = array( 'GESHI_CAPS_NO_CHANGE' => '', 'GESHI_CAPS_UPPER' => '', 'GESHI_CAPS_LOWER' => '' ); $kw_cases_sel = array( 1 => array( 0 => '', 1 => '' ) ); // --- empty variables for values of $_POST - end --- echo "

";
//var_dump($languages);

foreach($post_var_names as $varName) { // export wanted variables of $_POST array...
    if(array_key_exists($varName, $_POST)) {
      $$varName = htmlspecialchars_deep($_POST[$varName]);
    }
}

// determine the selected kw_case...
$kw_case_sel[$ld['kw_case']] = ' selected="selected"';

// determine the selected kw_cases...
for($i = 1; $i <= count($kw_cases_sel); $i += 1) {
    $kw_cases_sel[$i][(int) $ld['kw'][$i]['case']] = ' selected="selected"';
}

$lang = validate_lang();
var_dump($lang);
echo "
"; ?>
Generic Information
Author
Comments
Single Line
Comment Group 1
Comment Group 2
Multiple Lines
Comment Group 1
Comment Group 2
Regular Expressions
Comment Group 1
Strings
String \ Quotes (delimiters, parsed)
Quotemark Group 1
Quotemark Group 2
Escape Sequences
Generic Escape Char
Escape Regexp Group 1
Escape Regexp Group 2
Keywords
Case of Keywords
Keyword Group 1
Symbols
Symbols Group 1
Language File Source set_source($langfile_source); echo $G->parse_code(); unset($G); ?>

Operation completed in seconds.

"\\\"", "\\" => "\\\\", "\0" => "\\0", "\n" => "\\n", "\r" => "\\r", "\t" => "\\t", "\$" => "\\\$" ) ) . '"'; } else { return "'" . strtr($str, array( "'" => "\\'", "\\" => "\\\\" ) ) . "'"; } } function validate_lang(){ $ai = array( 'name' => 'Benny Baumann', 'email' => 'BenBE@geshi.org', 'web' => 'http://qbnz.com/highlighter/' ); $li = array( 'file' => 'example', 'desc' => 'Example' ); if(isset($_POST['ld'])) { $ld = $_POST['ld']; } else { $ld = array( 'cmt' => array( 'sl' => array( 1 => array( 'start' => '//', 'style' => 'test' ) ), 'ml' => array( 1 => array( 'start' => '/*', 'end' => '*/', 'style' => 'font-style: italic; color: #666666;' ) ), 'rxc' => array( 1 => array( 'rx' => '/Hello/', 'style' => 'color: #00000' ) ) ), 'str' => array( 'qm' => array(), 'ec' => array( 'char' => '' ), 'erx' => array() ), 'kw' => array(), 'kw_case' => 'GESHI_CAPS_NO_CHANGE', 'sy' => array() ); } return array('ai' => $ai, 'li' => $li, 'ld' => $ld); } function gen_langfile($lang){ $langfile = $lang['li']['file']; $langdesc = $lang['li']['desc']; $langauthor_name = $lang['ai']['name']; $langauthor_email = $lang['ai']['email']; $langauthor_web = $lang['ai']['web']; $langversion = GESHI_VERSION; $langdate = date('Y/m/d'); $langyear = date('Y'); $i = ' '; $i = array('', $i, $i.$i, $i.$i.$i); $src = << ".str_to_phpstring($langdesc).",\n"; //Comments $src .= $i[1] . "'COMMENT_SINGLE' => array(\n"; foreach($lang['ld']['cmt']['sl'] as $idx_cmt_sl => $tmp_cmt_sl) { $src .= $i[2] . ((int)$idx_cmt_sl). " => ". str_to_phpstring($tmp_cmt_sl['start']) . ",\n"; } $src .= $i[2] . "),\n"; $src .= $i[1] . "'COMMENT_MULTI' => array(\n"; foreach($lang['ld']['cmt']['ml'] as $tmp_cmt_ml) { $src .= $i[2] . str_to_phpstring($tmp_cmt_ml['start']). " => ". str_to_phpstring($tmp_cmt_ml['end']) . ",\n"; } $src .= $i[2] . "),\n"; $src .= $i[1] . "'COMMENT_REGEXP' => array(\n"; foreach($lang['ld']['cmt']['rxc'] as $idx_cmt_rxc => $tmp_cmt_rxc) { $src .= $i[2] . ((int)$idx_cmt_rxc). " => ". str_to_phpstring($tmp_cmt_rxc['rx']) . ",\n"; } $src .= $i[2] . "),\n"; //Case Keywords $src .= $i[1] . "'CASE_KEYWORDS' => " . $lang['ld']['kw_case'] . ",\n"; //Quotes \ Strings $src .= $i[1] . "'QUOTEMARKS' => array(\n"; foreach($lang['ld']['str']['qm'] as $idx_str_qm => $tmp_str_qm) { $src .= $i[2] . ((int)$idx_str_qm). " => ". str_to_phpstring($tmp_str_qm['delim']) . ",\n"; } $src .= $i[2] . "),\n"; $src .= $i[1] . "'ESCAPE_CHAR' => " . str_to_phpstring($lang['ld']['str']['ec']['char']) . ",\n"; $src .= $i[1] . "'ESCAPE_REGEXP' => array(\n"; foreach($lang['ld']['str']['erx'] as $idx_str_erx => $tmp_str_erx) { $src .= $i[2] . ((int)$idx_str_erx). " => ". str_to_phpstring($tmp_str_erx['rx']) . ",\n"; } $src .= $i[2] . "),\n"; //HardQuotes $src .= $i[1] . "'HARDQUOTE' => array(\n"; $src .= $i[2] . "),\n"; $src .= $i[1] . "'HARDESCAPE' => array(\n"; $src .= $i[2] . "),\n"; $src .= $i[1] . "'HARDCHAR' => '',\n"; //Numbers $src .= $i[1] . "'NUMBERS' =>\n"; $src .= $i[2] . "GESHI_NUMBER_INT_BASIC | GESHI_NUMBER_OCT_PREFIX | GESHI_NUMBER_HEX_PREFIX |\n"; $src .= $i[2] . "GESHI_NUMBER_FLT_SCI_ZERO,\n"; //Keywords $src .= $i[1] . "'KEYWRODS' => array(\n"; foreach($lang['ld']['kw'] as $idx_kw => $tmp_kw) { $src .= $i[2] . ((int)$idx_kw) . " => array(\n"; if(!is_array($tmp_kw['list'])) { $tmp_kw['list'] = explode("\n", $tmp_kw['list']); } $tmp_kw['list'] = array_map('trim', $tmp_kw['list']); sort($tmp_kw['list']); $kw_esc = array_map('str_to_phpstring', $tmp_kw['list']); $kw_nl = true; $kw_pos = 0; foreach($kw_esc as $kw_data) { if((strlen($kw_data) + $kw_pos > 79) && $kw_pos > strlen($i[3])) { $src .= "\n"; $kw_nl = true; $kw_pos = 0; } if($kw_nl) { $src .= $i[3]; $kw_pos += strlen($i[3]); $kw_nl = false; } $src .= $kw_data . ', '; $kw_pos += strlen($kw_data) + 2; } $src .= "\n"; $src .= $i[3] . "),\n"; } $src .= $i[2] . "),\n"; //Case Sensitivity $src .= $i[1] . "'CASE_SENSITIVE' => array(\n"; foreach($lang['ld']['kw'] as $idx_kw => $tmp_kw) { $src .= $i[2] . ((int)$idx_kw) . " => " . ($tmp_kw['case'] ? 'true' : 'false') . ",\n"; } $src .= $i[2] . "),\n"; //Symbols $src .= $i[1] . "'SYMBOLS' => array(\n"; foreach($lang['ld']['sy'] as $idx_kw => $tmp_kw) { $src .= $i[2] . ((int)$idx_kw) . " => array(\n"; $tmp_kw['list'] = (array)$tmp_kw['list']; sort($tmp_kw['list']); $kw_esc = array_map('str_to_phpstring', $tmp_kw['list']); $kw_nl = true; $kw_pos = strlen($i[3]); foreach($kw_esc as $kw_data) { if((strlen($kw_data) + $kw_pos > 79) && $kw_pos > strlen($i[3])) { $src .= "\n"; $kw_nl = true; $kw_pos = 0; } if($kw_nl) { $src .= $i[3]; $kw_pos += strlen($i[3]); $kw_nl = false; } $src .= $kw_data . ', '; $kw_pos += strlen($kw_data) + 2; } $src .= "\n"; $src .= $i[3] . "),\n"; } $src .= $i[2] . "),\n"; //Styles \ CSS $src .= $i[1] . "'STYLES' => array(\n"; $src .= $i[2] . "'KEYWRODS' => array(\n"; foreach($lang['ld']['kw'] as $idx_kw => $tmp_kw) { $src .= $i[3] . ((int)$idx_kw) . " => " . str_to_phpstring($tmp_kw['style']) . ",\n"; } $src .= $i[3] . "),\n"; $src .= $i[2] . "'COMMENTS' => array(\n"; foreach($lang['ld']['cmt']['sl'] as $idx_cmt_sl => $tmp_cmt_sl) { $src .= $i[3] . ((int)$idx_cmt_sl) . " => " . str_to_phpstring($tmp_cmt_sl['style']) . ",\n"; } foreach($lang['ld']['cmt']['rxc'] as $idx_cmt_rxc => $tmp_cmt_rxc) { $src .= $i[3] . ((int)$idx_cmt_rxc) . " => " . str_to_phpstring($tmp_cmt_rxc['style']) . ",\n"; } $src .= $i[3] . "'MULTI' => " . str_to_phpstring($lang['ld']['cmt']['ml'][1]['style']) . "\n"; $src .= $i[3] . "),\n"; $src .= $i[2] . "'ESCAPE_CHAR' => array(\n"; foreach($lang['ld']['str']['erx'] as $idx_str_erx => $tmp_str_erx) { $src .= $i[3] . ((int)$idx_str_erx). " => ". str_to_phpstring($tmp_str_erx['style']) . ",\n"; } // 'HARD' => 'color: #000099; font-weight: bold;' $src .= $i[3] . "),\n"; $src .= $i[2] . "'BRACKETS' => array(\n"; $src .= $i[3] . "),\n"; $src .= $i[2] . "'STRINGS' => array(\n"; foreach($lang['ld']['str']['qm'] as $idx_str_qm => $tmp_str_qm) { $src .= $i[3] . ((int)$idx_str_qm). " => ". str_to_phpstring($tmp_str_qm['style']) . ",\n"; } // 'HARD' => 'color: #0000ff;' $src .= $i[3] . "),\n"; $src .= $i[2] . "'NUMBERS' => array(\n"; $src .= $i[3] . "),\n"; $src .= $i[2] . "'METHODS' => array(\n"; $src .= $i[3] . "),\n"; $src .= $i[2] . "'SYMBOLS' => array(\n"; foreach($lang['ld']['sy'] as $idx_kw => $tmp_kw) { $src .= $i[3] . ((int)$idx_kw) . " => " . str_to_phpstring($tmp_kw['style']) . ",\n"; } $src .= $i[3] . "),\n"; $src .= $i[2] . "'REGEXPS' => array(\n"; $src .= $i[3] . "),\n"; $src .= $i[2] . "'SCRIPT' => array(\n"; $src .= $i[3] . "),\n"; $src .= $i[2] . "),\n"; //Keyword Documentation $src .= $i[1] . "'URLS' => array(\n"; foreach($lang['ld']['kw'] as $idx_kw => $tmp_kw) { $src .= $i[2] . ((int)$idx_kw) . " => " . str_to_phpstring($tmp_kw['docs']) . ",\n"; } $src .= $i[2] . "),\n"; $src .= $i[1] . "'OOLANG' => false,\n"; $src .= $i[1] . "'OBJECT_SPLITTERS' => array(\n"; $src .= $i[2] . "),\n"; $src .= $i[1] . "'REGEXPS' => array(\n"; $src .= $i[2] . "),\n"; $src .= $i[1] . "'STRICT_MODE_APPLIES' => GESHI_MAYBE,\n"; $src .= $i[1] . "'SCRIPT_DELIMITERS' => array(\n"; $src .= $i[2] . "),\n"; $src .= $i[1] . "'HIGHLIGHT_STRICT_BLOCK' => array(\n"; $src .= $i[2] . "),\n"; $src .= $i[1] . "'TAB_WIDTH' => 4,\n"; $src .= << GESHI_LANGFILE_FOOTER; //Reduce source ... $src = preg_replace('/array\(\s*\)/s', 'array()', $src); $src = preg_replace('/\,(\s*\))/s', '\1', $src); $src = preg_replace('/\s+$/m', '', $src); return $src; } // vim: shiftwidth=4 softtabstop=4 ?>