diff options
Diffstat (limited to 'inc')
41 files changed, 2176 insertions, 1425 deletions
diff --git a/inc/geshi.php b/inc/geshi.php index a15d2d813..5e61a44c8 100644 --- a/inc/geshi.php +++ b/inc/geshi.php @@ -1,40 +1,36 @@ <?php -/************************************************************************************* - * geshi.php - * --------- - * Author: Nigel McNie (oracle.shinoda@gmail.com) - * Copyright: (c) 2004 Nigel McNie - * Release Version: 1.0.6 - * CVS Revision Version: $Revision: 1.4 $ - * Date Started: 2004/05/20 - * Last Modified: $Date: 2005/01/29 10:36:06 $ - * +/** + * 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. * * For changes, release notes, TODOs etc, see the relevant files in the docs/ directory * - ************************************************************************************* - * - * This file is part of GeSHi. + * This file is part of GeSHi. * - * GeSHi is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * GeSHi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with GeSHi; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @package core + * @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.9 2005/06/17 10:45:23 oracleshinoda Exp $ * - ************************************************************************************/ - + */ // // GeSHi Constants @@ -43,153 +39,399 @@ // version // -// For the future (though this may never be realised) +/** The version of this GeSHi file */ +define('GESHI_VERSION', '1.0.7'); + +/** For the future (though this may never be realised) */ define('GESHI_OUTPUT_HTML', 0); -// Shouldn't be used by your program -define('GESHI_COMMENTS', 0); +/** Set the correct directory separator */ +define('GESHI_DIR_SEPARATOR', ('WIN' != substr(PHP_OS, 0, 3)) ? '/' : '\\'); + +// Define the root directory for the GeSHi code tree +if (!defined('GESHI_ROOT')) { + /** The root directory for GeSHi */ + define('GESHI_ROOT', dirname(__FILE__) . GESHI_DIR_SEPARATOR); +} +/** The language file directory for GeSHi + @access private */ +define('GESHI_LANG_ROOT', GESHI_ROOT . 'geshi' . GESHI_DIR_SEPARATOR); -// Error detection - use these to analyse faults -define('GESHI_ERROR_NO_INPUT', 1); -define('GESHI_ERROR_NO_SUCH_LANG', 2); -define('GESHI_ERROR_FILE_NOT_READABLE', 3); -// Human error messages - added in 1.0.2 -$_GESHI_ERRORS = array( - GESHI_ERROR_NO_INPUT => 'No source code inputted', - GESHI_ERROR_NO_SUCH_LANG => 'GeSHi could not find the language {LANGUAGE} (using path {PATH})', - GESHI_ERROR_FILE_NOT_READABLE => 'The file specified for load_from_file was not readable' -); // Line numbers - use with enable_line_numbers() +/** Use no line numbers when building the result */ define('GESHI_NO_LINE_NUMBERS', 0); +/** Use normal line numbers when building the result */ define('GESHI_NORMAL_LINE_NUMBERS', 1); +/** Use fancy line numbers when building the result */ define('GESHI_FANCY_LINE_NUMBERS', 2); -// Strict mode - shouldn't be used by your scripts -define('GESHI_NEVER', 0); -define('GESHI_MAYBE', 1); -define('GESHI_ALWAYS', 2); - -// Container HTML type - use these (added in 1.0.1) +// Container HTML type +/** Use a <div> to surround the source */ define('GESHI_HEADER_DIV', 1); +/** Use a <pre> to surround the source */ define('GESHI_HEADER_PRE', 2); -// Capatalisation constants - use these (added in 1.0.1) +// Capatalisation constants +/** Lowercase keywords found */ define('GESHI_CAPS_NO_CHANGE', 0); +/** Uppercase keywords found */ define('GESHI_CAPS_UPPER', 1); +/** Leave keywords found as the case that they are */ define('GESHI_CAPS_LOWER', 2); -// Link style constants - use these (added in 1.0.2) +// Link style constants +/** Links in the source in the :link state */ define('GESHI_LINK', 0); +/** Links in the source in the :hover state */ define('GESHI_HOVER', 1); +/** Links in the source in the :active state */ define('GESHI_ACTIVE', 2); +/** Links in the source in the :visited state */ define('GESHI_VISITED', 3); -// Important string starter/finisher - use these (added in 1.0.2). +// Important string starter/finisher // Note that if you change these, they should be as-is: i.e., don't -// write them as if they had been run through @htmlentities() +// write them as if they had been run through htmlentities() +/** The starter for important parts of the source */ define('GESHI_START_IMPORTANT', '<BEGIN GeSHi>'); +/** The ender for important parts of the source */ define('GESHI_END_IMPORTANT', '<END GeSHi>'); -// Advanced regexp handling - don't use these (added in 1.0.2) +/**#@+ + * @access private + */ +// When strict mode applies for a language +/** Strict mode never applies (this is the most common) */ +define('GESHI_NEVER', 0); +/** Strict mode *might* apply, and can be enabled or + disabled by {@link GeSHi::enable_strict_mode()} */ +define('GESHI_MAYBE', 1); +/** Strict mode always applies */ +define('GESHI_ALWAYS', 2); + +// Advanced regexp handling constants, used in language files +/** The key of the regex array defining what to search for */ define('GESHI_SEARCH', 0); +/** The key of the regex array defining what bracket group in a + matched search to use as a replacement */ define('GESHI_REPLACE', 1); +/** The key of the regex array defining any modifiers to the regular expression */ define('GESHI_MODIFIERS', 2); +/** The key of the regex array defining what bracket group in a + matched search to put before the replacement */ define('GESHI_BEFORE', 3); +/** The key of the regex array defining what bracket group in a + matched search to put after the replacement */ define('GESHI_AFTER', 4); -// Begin Class GeSHi +/** Used in language files to mark comments */ +define('GESHI_COMMENTS', 0); + +// Error detection - use these to analyse faults +/** No sourcecode to highlight was specified */ +define('GESHI_ERROR_NO_INPUT', 1); +/** The language specified does not exist */ +define('GESHI_ERROR_NO_SUCH_LANG', 2); +/** GeSHi could not open a file for reading (generally a language file) */ +define('GESHI_ERROR_FILE_NOT_READABLE', 3); +/** The header type passed to {@link GeSHi::set_header_type()} was invalid */ +define('GESHI_ERROR_INVALID_HEADER_TYPE', 4); +/** The line number type passed to {@link GeSHi::enable_line_numbers()} was invalid */ +define('GESHI_ERROR_INVALID_LINE_NUMBER_TYPE', 5); +/**#@-*/ + + +/** + * The GeSHi Class. + * + * Please refer to the documentation for GeSHi 1.0.X that is available + * at http://qbnz.com/highlighter/documentation.php for more information + * about how to use this class. + * + * @package core + * @author Nigel McNie <nigel@geshi.org> + * @copyright Copyright © 2004, 2005 Nigel McNie + */ class GeSHi { - // - // Data Fields - // - - // Basic fields - var $source = ''; // The source code to highlight - var $language = ''; // The language to use when highlighting - var $language_data = array(); // The data for the language used - var $language_path = 'geshi/'; // The path to the language files - var $error = false; // The error message associated with an error - var $strict_mode = false; // Whether highlighting is strict or not - var $use_classes = false; // Whether to use classes - var $header_type = GESHI_HEADER_PRE; // The type of header to use - var $lexic_permissions = array(); // Array of permissions for which lexics should be highlighted - // Added in 1.0.2 basic fields - var $time = 0; // The time it took to parse the code - var $header_content = ''; // The content of the header block - var $footer_content = ''; // The content of the footer block - var $header_content_style = ''; // The style of the header block - var $footer_content_style = ''; // The style of the footer block - var $link_styles = array(); // The styles for hyperlinks in the code - var $enable_important_blocks = true; // Whether important blocks should be recognised or not + /**#@+ + * @access private + */ + /** + * The source code to highlight + * @var string + */ + var $source = ''; + + /** + * The language to use when highlighting + * @var string + */ + var $language = ''; + + /** + * The data for the language used + * @var array + */ + var $language_data = array(); + + /** + * The path to the language files + * @var string + */ + var $language_path = GESHI_LANG_ROOT; + + /** + * The error message associated with an error + * @var string + * @todo check err reporting works + */ + var $error = false; + + /** + * Possible error messages + * @var array + */ + var $error_messages = array( + GESHI_ERROR_NO_INPUT => 'No source code inputted', + GESHI_ERROR_NO_SUCH_LANG => 'GeSHi could not find the language {LANGUAGE} (using path {PATH})', + GESHI_ERROR_FILE_NOT_READABLE => 'The file specified for load_from_file was not readable', + GESHI_ERROR_INVALID_HEADER_TYPE => 'The header type specified is invalid', + GESHI_ERROR_INVALID_LINE_NUMBER_TYPE => 'The line number type specified is invalid' + ); + + /** + * Whether highlighting is strict or not + * @var boolean + */ + var $strict_mode = false; + + /** + * Whether to use CSS classes in output + * @var boolean + */ + var $use_classes = false; + + /** + * The type of header to use. Can be one of the following + * values: + * + * <ul> + * <li><b>GESHI_HEADER_PRE</b>: Source is outputted in + * a <pre> HTML element.</li> + * <li><b>GESHI_HEADER_DIV</b>: Source is outputted in + * a <div> HTML element.</li> + * </ul> + * + * @var int + */ + var $header_type = GESHI_HEADER_PRE; + + /** + * Array of permissions for which lexics should be highlighted + * @var array + */ + var $lexic_permissions = array( + 'KEYWORDS' => array(), + 'COMMENTS' => array('MULTI' => true), + 'REGEXPS' => array(), + 'ESCAPE_CHAR' => true, + 'BRACKETS' => true, + 'SYMBOLS' => true, + 'STRINGS' => true, + 'NUMBERS' => true, + 'METHODS' => true, + 'SCRIPT' => true + ); + + /** + * The time it took to parse the code + * @var double + */ + var $time = 0; + + /** + * The content of the header block + * @var string + */ + var $header_content = ''; + + /** + * The content of the footer block + * @var string + */ + var $footer_content = ''; + + /** + * The style of the header block + * @var string + */ + var $header_content_style = ''; + + /** + * The style of the footer block + * @var string + */ + var $footer_content_style = ''; + + /** + * The styles for hyperlinks in the code + * @var array + */ + var $link_styles = array(); + + /** + * Whether important blocks should be recognised or not + * @var boolean + * @todo REMOVE THIS FUNCTIONALITY! + */ + var $enable_important_blocks = false; + + /** + * Styles for important parts of the code + * @var string + * @todo As above - rethink the whole idea of important blocks as it is buggy and + * will be hard to implement in 1.2 + */ var $important_styles = 'font-weight: bold; color: red;'; // Styles for important parts of the code - var $add_ids = false; // Whether css IDs should be added to the code - var $highlight_extra_lines = array(); // Lines that should be highlighted extra - var $highlight_extra_lines_style = 'color: #cc0; background-color: #ffc;';// Styles of extra-highlighted lines - var $line_numbers_start = 1; // Number at which line numbers should start at - - // Style fields - var $overall_style = ''; // The overall style for this code block - // The style for the actual code + + /** + * Whether CSS IDs should be added to the code + * @var boolean + */ + var $add_ids = false; + + /** + * Lines that should be highlighted extra + * @var array + */ + var $highlight_extra_lines = array(); + + /** + * Styles of extra-highlighted lines + * @var string + */ + var $highlight_extra_lines_style = 'color: #cc0; background-color: #ffc;'; + + /** + * Number at which line numbers should start at + * @var int + * @todo Warning documentation about XHTML compliance + */ + var $line_numbers_start = 1; + + /** + * The overall style for this code block + * @var string + */ + var $overall_style = ''; + + /** + * The style for the actual code + * @var string + */ var $code_style = 'font-family: \'Courier New\', Courier, monospace; font-weight: normal;'; - var $overall_class = ''; // The overall class for this code block - var $overall_id = ''; // The overall id for this code block - // Line number styles + + /** + * The overall class for this code block + * @var string + */ + var $overall_class = ''; + + /** + * The overall ID for this code block + * @var string + */ + var $overall_id = ''; + + /** + * Line number styles + * @var string + */ var $line_style1 = 'font-family: \'Courier New\', Courier, monospace; color: black; font-weight: normal; font-style: normal;'; + + /** + * Line number styles for fancy lines + * @var string + */ var $line_style2 = 'font-weight: bold;'; - var $line_numbers = GESHI_NO_LINE_NUMBERS; // Flag for how line numbers are displayed - var $line_nth_row = 0; // The "nth" value for fancy line highlighting - - // Misc - var $tab_width = 8; // A value for the size of tab stops. - var $max_tabs = 20; // Maximum number of spaces per tab - var $min_tabs = 0; // Minimum " " " " " - var $link_target = ''; // default target for keyword links - var $encoding = 'ISO-8859-1'; // The encoding to use for @htmlentities() calls - - // Deprecated/unused + + /** + * Flag for how line nubmers are displayed + * @var boolean + */ + var $line_numbers = GESHI_NO_LINE_NUMBERS; + + /** + * The "nth" value for fancy line highlighting + * @var int + */ + var $line_nth_row = 0; + + /** + * The size of tab stops + * @var int + */ + var $tab_width = 8; + + /** + * Default target for keyword links + * @var string + */ + var $link_target = ''; + + /** + * The encoding to use for entity encoding + * @var string + */ + var $encoding = 'ISO-8859-1'; + + /** + * Unused (planned for future) + * @var int + */ var $output_format = GESHI_OUTPUT_HTML; + /**#@-*/ /** - * constructor: GeSHi - * ------------------ * Creates a new GeSHi object, with source and language + * + * @param string The source code to highlight + * @param string The language to highlight the source with + * @param string The path to the language file directory. <b>This + * is deprecated!</b> I've backported the auto path + * detection from the 1.1.X dev branch, so now it + * should be automatically set correctly. If you have + * renamed the language directory however, you will + * still need to set the path using this parameter or + * {@link GeSHi::set_language_path()} + * @since 1.0.0 */ - function GeSHi ($source, $language, $path = 'geshi/') + function GeSHi ($source, $language, $path = '') { - $this->source = $source; - // Security, just in case :) - $language = preg_replace('#[^a-zA-Z0-9\-\_]#', '', $language); - $this->language = strtolower($language); - $this->language_path = ( substr($path, strlen($path) - 1, 1) == '/' ) ? $path : $path . '/'; - $this->load_language(); + $this->set_source($source); + $this->set_language_path($path); + $this->set_language($language); } - - // - // Error methods - // - /** - * method: error - * ------------- * Returns an error message associated with the last GeSHi operation, * or false if no error has occured + * + * @return string|false An error message if there has been an error, else false + * @since 1.0.0 */ - function error() + function error () { - global $_GESHI_ERRORS; - if ( $this->error != 0 ) - { - $msg = $_GESHI_ERRORS[$this->error]; + if ($this->error) { + $msg = $this->error_messages[$this->error]; $debug_tpl_vars = array( '{LANGUAGE}' => $this->language, '{PATH}' => $this->language_path ); - foreach ( $debug_tpl_vars as $tpl => $var ) - { + foreach ($debug_tpl_vars as $tpl => $var) { $msg = str_replace($tpl, $var, $msg); } return "<br /><strong>GeSHi Error:</strong> $msg (code $this->error)<br />"; @@ -197,653 +439,631 @@ class GeSHi return false; } - - // - // Getters - // - /** - * get_language_name() - * --------------- * Gets a human-readable language name (thanks to Simon Patterson * for the idea :)) + * + * @return string The name for the current language + * @since 1.0.2 */ - function get_language_name() + function get_language_name () { - if ( $this->error == GESHI_ERROR_NO_SUCH_LANG ) - { + if (GESHI_ERROR_NO_SUCH_LANG == $this->_error) { return $this->language_data['LANG_NAME'] . ' (Unknown Language)'; } return $this->language_data['LANG_NAME']; } - - // - // Setters - // - /** - * method: set_source - * ------------------ * Sets the source code for this object + * + * @param string The source code to highlight + * @since 1.0.0 */ - function set_source ( $source ) + function set_source ($source) { + if ('' == trim($source)) { + $this->error = GESHI_ERROR_NO_INPUT; + } $this->source = $source; } - /** - * method: set_language - * -------------------- * Sets the language for this object + * + * @param string The name of the language to use + * @since 1.0.0 */ - function set_language ( $language ) + function set_language ($language) { + $this->error = false; + $this->strict_mode = GESHI_NEVER; + $language = preg_replace('#[^a-zA-Z0-9\-_]#', '', $language); $this->language = strtolower($language); + + $file_name = $this->language_path . $this->language . '.php'; + if (!is_readable($file_name)) { + $this->error = GESHI_ERROR_NO_SUCH_LANG; + return; + } // Load the language for parsing - $this->load_language(); + $this->load_language($file_name); } - /** - * method: set_language_path - * ------------------------- - * Sets the path to the directory containing the language files. NOTE + * Sets the path to the directory containing the language files. Note * that this path is relative to the directory of the script that included * geshi.php, NOT geshi.php itself. - */ - function set_language_path ( $path ) - { - $this->language_path = ( substr($path, strlen($path) - 1, 1) == '/' ) ? $path : $path . '/'; - } - - - /** - * method: set_header_type - * ----------------------- - * Sets the type of header to be used. If GESHI_HEADER_DIV is used, - * the code is surrounded in a <div>. This means more source code but - * more control over tab width and line-wrapping. GESHI_HEADER_PRE - * means that a <pre> is used - less source, but less control. Default - * is GESHI_HEADER_PRE - */ - function set_header_type ( $type ) - { + * + * @param string The path to the language directory + * @since 1.0.0 + * @deprecated The path to the language files should now be automatically + * detected, so this method should no longer be needed. The + * 1.1.X branch handles manual setting of the path differently + * so this method will disappear in 1.2.0. + */ + function set_language_path ($path) + { + if ($path) { + $this->language_path = ('/' == substr($path, strlen($path) - 1, 1)) ? $path : $path . '/'; + } + } + + /** + * Sets the type of header to be used. + * + * If GESHI_HEADER_DIV is used, the code is surrounded in a <div>.This + * means more source code but more control over tab width and line-wrapping. + * GESHI_HEADER_PRE means that a <pre> is used - less source, but less + * control. Default is GESHI_HEADER_PRE. + * + * @param int The type of header to be used + * @since 1.0.0 + */ + function set_header_type ($type) + { + if (GESHI_HEADER_DIV != $type && GESHI_HEADER_PRE != $type) { + $this->error = GESHI_ERROR_INVALID_HEADER_TYPE; + return; + } $this->header_type = $type; } - /** - * method: set_overall_style - * ------------------------- * Sets the styles for the code that will be outputted * when this object is parsed. The style should be a * string of valid stylesheet declarations + * + * @param string The overall style for the outputted code block + * @param boolean Whether to merge the styles with the current styles or not + * @since 1.0.0 */ - function set_overall_style ( $style, $preserve_defaults = false ) + function set_overall_style ($style, $preserve_defaults = false) { - if ( $preserve_defaults ) - { - $this->overall_style .= $style; - } - else - { + if (!$preserve_defaults) { $this->overall_style = $style; + } else { + $this->overall_style .= $style; } } - /** - * method: set_overall_class - * ------------------------- * Sets the overall classname for this block of code. This * class can then be used in a stylesheet to style this object's * output + * + * @param string The class name to use for this block of code + * @since 1.0.0 */ - function set_overall_class ( $class ) + function set_overall_class ($class) { $this->overall_class = $class; } - /** - * method: set_overall_id - * ---------------------- * Sets the overall id for this block of code. This id can then * be used in a stylesheet to style this object's output + * + * @param string The ID to use for this block of code + * @since 1.0.0 */ - function set_overall_id ( $id ) + function set_overall_id ($id) { $this->overall_id = $id; } - /** - * method: enable_classes - * ---------------------- - * Sets whether CSS classes should be used to highlight the source. Default - * is off, calling this method with no arguments will turn it on - */ - function enable_classes ( $flag = true ) + * Sets whether CSS classes should be used to highlight the source. Default + * is off, calling this method with no arguments will turn it on + * + * @param boolean Whether to turn classes on or not + * @since 1.0.0 + */ + function enable_classes ($flag = true) { - $this->use_classes = ( $flag ) ? true : false; + $this->use_classes = ($flag) ? true : false; } - /** - * method: set_code_style - * ---------------------- * Sets the style for the actual code. This should be a string * containing valid stylesheet declarations. If $preserve_defaults is * true, then styles are merged with the default styles, with the * user defined styles having priority * - * NOTE: Use this method to override any style changes you made to + * Note: Use this method to override any style changes you made to * the line numbers if you are using line numbers, else the line of * code will have the same style as the line number! Consult the * GeSHi documentation for more information about this. - */ - function set_code_style ( $style, $preserve_defaults ) - { - if ( $preserve_defaults ) - { - $this->code_style .= $style; - } - else - { - $this->code_style = $style; - } - } - - - /** - * method: set_line_style - * ---------------------- - * Sets the styles for the line numbers. This should be a string - * containing valid stylesheet declarations. If $preserve_defaults is - * true, then styles are merged with the default styles, with the - * user defined styles having priority - */ - function set_line_style ( $style1, $style2 = '', $preserve_defaults = false ) - { - if ( is_bool($style2) ) - { + * + * @param string The style to use for actual code + * @param boolean Whether to merge the current styles with the new styles + */ + function set_code_style ($style, $preserve_defaults = false) + { + if (!$preserve_defaults) { + $this->code_style = $style; + } else { + $this->code_style .= $style; + } + } + + /** + * Sets the styles for the line numbers. + * + * @param string The style for the line numbers that are "normal" + * @param string|boolean If a string, this is the style of the line + * numbers that are "fancy", otherwise if boolean then this + * defines whether the normal styles should be merged with the + * new normal styles or not + * @param boolean If set, is the flag for whether to merge the "fancy" + * styles with the current styles or not + * @since 1.0.2 + */ + function set_line_style ($style1, $style2 = '', $preserve_defaults = false) + { + if (is_bool($style2)) { $preserve_defaults = $style2; $style2 = ''; } - if ( $preserve_defaults ) - { - $this->line_style1 .= $style1; - $this->line_style2 .= $style2; - } - else - { + if (!$preserve_defaults) { $this->line_style1 = $style1; $this->line_style2 = $style2; + } else { + $this->line_style1 .= $style1; + $this->line_style2 .= $style2; } } - /** - * method: enable_line_numbers - * --------------------------- - * Sets whether line numbers should be displayed. GESHI_NO_LINE_NUMBERS = not displayed, - * GESHI_NORMAL_LINE_NUMBERS = displayed, GESHI_FANCY_LINE_NUMBERS = every nth line a - * different class. Default is for no line numbers to be used - */ - function enable_line_numbers ( $flag, $nth_row = 5 ) - { + * Sets whether line numbers should be displayed. + * + * Valid values for the first parameter are: + * + * <ul> + * <li><b>GESHI_NO_LINE_NUMBERS</b>: Line numbers will not be displayed</li> + * <li><b>GESHI_NORMAL_LINE_NUMBERS</b>: Line numbers will be displayed</li> + * <li><b>GESHI_FANCY_LINE_NUMBERS</b>: Fancy line numbers will be displayed</li> + * </ul> + * + * For fancy line numbers, the second parameter is used to signal which lines + * are to be fancy. For example, if the value of this parameter is 5 then every + * 5th line will be fancy. + * + * @param int How line numbers should be displayed + * @param int Defines which lines are fancy + * @since 1.0.0 + */ + function enable_line_numbers ($flag, $nth_row = 5) + { + if (GESHI_NO_LINE_NUMBERS != $flag && GESHI_NORMAL_LINE_NUMBERS != $flag + && GESHI_FANCY_LINE_NUMBERS != $flag) { + $this->error = GESHI_ERROR_INVALID_LINE_NUMBER_TYPE; + } $this->line_numbers = $flag; $this->line_nth_row = $nth_row; } - /** - * method: set_keyword_group_style - * ------------------------------- * Sets the style for a keyword group. If $preserve_defaults is * true, then styles are merged with the default styles, with the * user defined styles having priority + * + * @param int The key of the keyword group to change the styles of + * @param string The style to make the keywords + * @param boolean Whether to merge the new styles with the old or just + * to overwrite them + * @since 1.0.0 */ - function set_keyword_group_style ( $key, $style, $preserve_defaults = false ) + function set_keyword_group_style ($key, $style, $preserve_defaults = false) { - if ( $preserve_defaults ) - { - $this->language_data['STYLES']['KEYWORDS'][$key] .= $style; - } - else - { + if (!$preserve_defaults) { $this->language_data['STYLES']['KEYWORDS'][$key] = $style; + } else { + $this->language_data['STYLES']['KEYWORDS'][$key] .= $style; } } - /** - * method: set_keyword_group_highlighting - * -------------------------------------- * Turns highlighting on/off for a keyword group + * + * @param int The key of the keyword group to turn on or off + * @param boolean Whether to turn highlighting for that group on or off + * @since 1.0.0 */ function set_keyword_group_highlighting ( $key, $flag = true ) { - $this->lexic_permissions['KEYWORDS'][$key] = ( $flag ) ? true : false; + $this->lexic_permissions['KEYWORDS'][$key] = ($flag) ? true : false; } - /** - * method: set_comments_style - * -------------------------- * Sets the styles for comment groups. If $preserve_defaults is * true, then styles are merged with the default styles, with the * user defined styles having priority + * + * @param int The key of the comment group to change the styles of + * @param string The style to make the comments + * @param boolean Whether to merge the new styles with the old or just + * to overwrite them + * @since 1.0.0 */ - function set_comments_style ( $key, $style, $preserve_defaults = false ) + function set_comments_style ($key, $style, $preserve_defaults = false) { - if ( $preserve_defaults ) - { - $this->language_data['STYLES']['COMMENTS'][$key] .= $style; - } - else - { + if (!$preserve_defaults) { $this->language_data['STYLES']['COMMENTS'][$key] = $style; + } else { + $this->language_data['STYLES']['COMMENTS'][$key] .= $style; } } - /** - * method: set_comments_highlighting - * --------------------------------- * Turns highlighting on/off for comment groups + * + * @param int The key of the comment group to turn on or off + * @param boolean Whether to turn highlighting for that group on or off + * @since 1.0.0 */ - function set_comments_highlighting ( $key, $flag = true ) + function set_comments_highlighting ($key, $flag = true) { - $this->lexic_permissions['COMMENTS'][$key] = ( $flag ) ? true : false; + $this->lexic_permissions['COMMENTS'][$key] = ($flag) ? true : false; } - /** - * method: set_escape_characters_style - * ----------------------------------- * Sets the styles for escaped characters. If $preserve_defaults is * true, then styles are merged with the default styles, with the * user defined styles having priority + * + * @param string The style to make the escape characters + * @param boolean Whether to merge the new styles with the old or just + * to overwrite them + * @since 1.0.0 */ - function set_escape_characters_style ( $style, $preserve_defaults = false ) + function set_escape_characters_style ($style, $preserve_defaults = false) { - if ( $preserve_defaults ) - { - $this->language_data['STYLES']['ESCAPE_CHAR'][0] .= $style; - } - else - { + if (!$preserve_defaults) { $this->language_data['STYLES']['ESCAPE_CHAR'][0] = $style; + } else { + $this->language_data['STYLES']['ESCAPE_CHAR'][0] .= $style; } } - /** - * method: set_escape_characters_highlighting - * ------------------------------------------ * Turns highlighting on/off for escaped characters + * + * @param boolean Whether to turn highlighting for escape characters on or off + * @since 1.0.0 */ - function set_escape_characters_highlighting ( $flag = true ) + function set_escape_characters_highlighting ($flag = true) { - $this->lexic_permissions['ESCAPE_CHAR'] = ( $flag ) ? true : false; + $this->lexic_permissions['ESCAPE_CHAR'] = ($flag) ? true : false; } - /** - * method: set_brackets_style - * -------------------------- * Sets the styles for brackets. If $preserve_defaults is * true, then styles are merged with the default styles, with the * user defined styles having priority * * This method is DEPRECATED: use set_symbols_style instead. * This method will be removed in 1.2.X + * + * @param string The style to make the brackets + * @param boolean Whether to merge the new styles with the old or just + * to overwrite them + * @since 1.0.0 + * @deprecated In favour of set_symbols_style */ - function set_brackets_style ( $style, $preserve_defaults = false ) + function set_brackets_style ($style, $preserve_defaults = false) { - if ( $preserve_defaults ) - { - $this->language_data['STYLES']['BRACKETS'][0] .= $style; - } - else - { + if (!$preserve_defaults) { + $this->language_data['STYLES']['BRACKETS'][0] = $style; + } else { $this->language_data['STYLES']['BRACKETS'][0] = $style; } } - /** - * method: set_brackets_highlighting - * --------------------------------- * Turns highlighting on/off for brackets * * This method is DEPRECATED: use set_symbols_highlighting instead. * This method will be remove in 1.2.X + * + * @param boolean Whether to turn highlighting for brackets on or off + * @since 1.0.0 + * @deprecated In favour of set_symbols_highlighting */ - function set_brackets_highlighting ( $flag ) + function set_brackets_highlighting ($flag) { - $this->lexic_permissions['BRACKETS'] = ( $flag ) ? true : false; + $this->lexic_permissions['BRACKETS'] = ($flag) ? true : false; } - /** - * method: set_symbols_style - * -------------------------- * Sets the styles for symbols. If $preserve_defaults is * true, then styles are merged with the default styles, with the * user defined styles having priority + * + * @param string The style to make the symbols + * @param boolean Whether to merge the new styles with the old or just + * to overwrite them + * @since 1.0.1 */ - function set_symbols_style ( $style, $preserve_defaults = false ) + function set_symbols_style ($style, $preserve_defaults = false) { - if ( $preserve_defaults ) - { - $this->language_data['STYLES']['SYMBOLS'][0] .= $style; - } - else - { + if (!$preserve_defaults) { + $this->language_data['STYLES']['SYMBOLS'][0] = $style; + } else { $this->language_data['STYLES']['SYMBOLS'][0] = $style; } // For backward compatibility - $this->set_brackets_style ( $style, $preserve_defaults ); + $this->set_brackets_style ($style, $preserve_defaults); } - /** - * method: set_symbols_highlighting - * --------------------------------- * Turns highlighting on/off for symbols + * + * @param boolean Whether to turn highlighting for symbols on or off + * @since 1.0.0 */ - function set_symbols_highlighting ( $flag ) + function set_symbols_highlighting ($flag) { - $this->lexic_permissions['SYMBOLS'] = ( $flag ) ? true : false; + $this->lexic_permissions['SYMBOLS'] = ($flag) ? true : false; // For backward compatibility - $this->set_brackets_highlighting ( $flag ); + $this->set_brackets_highlighting ($flag); } - /** - * method: set_strings_style - * ------------------------- * Sets the styles for strings. If $preserve_defaults is * true, then styles are merged with the default styles, with the * user defined styles having priority + * + * @param string The style to make the escape characters + * @param boolean Whether to merge the new styles with the old or just + * to overwrite them + * @since 1.0.0 */ - function set_strings_style ( $style, $preserve_defaults = false ) + function set_strings_style ($style, $preserve_defaults = false) { - if ( $preserve_defaults ) - { - $this->language_data['STYLES']['STRINGS'][0] .= $style; - } - else - { + if (!$preserve_defaults) { + $this->language_data['STYLES']['STRINGS'][0] = $style; + } else { $this->language_data['STYLES']['STRINGS'][0] = $style; } } - /** - * method: set_strings_highlighting - * -------------------------------- * Turns highlighting on/off for strings + * + * @param boolean Whether to turn highlighting for strings on or off + * @since 1.0.0 */ - function set_strings_highlighting ( $flag ) + function set_strings_highlighting ($flag) { - $this->lexic_permissions['STRINGS'] = ( $flag ) ? true : false; + $this->lexic_permissions['STRINGS'] = ($flag) ? true : false; } - /** - * method: set_numbers_style - * ------------------------- * Sets the styles for numbers. If $preserve_defaults is * true, then styles are merged with the default styles, with the * user defined styles having priority + * + * @param string The style to make the numbers + * @param boolean Whether to merge the new styles with the old or just + * to overwrite them + * @since 1.0.0 */ - function set_numbers_style ( $style, $preserve_defaults = false ) + function set_numbers_style ($style, $preserve_defaults = false) { - if ( $preserve_defaults ) - { - $this->language_data['STYLES']['NUMBERS'][0] .= $style; - } - else - { + if (!$preserve_defaults) { + $this->language_data['STYLES']['NUMBERS'][0] = $style; + } else { $this->language_data['STYLES']['NUMBERS'][0] = $style; } } - /** - * method: set_numbers_highlighting - * -------------------------------- * Turns highlighting on/off for numbers + * + * @param boolean Whether to turn highlighting for numbers on or off + * @since 1.0.0 */ - function set_numbers_highlighting ( $flag ) + function set_numbers_highlighting ($flag) { - $this->lexic_permissions['NUMBERS'] = ( $flag ) ? true : false; + $this->lexic_permissions['NUMBERS'] = ($flag) ? true : false; } - /** - * method: set_methods_style - * ------------------------- * Sets the styles for methods. $key is a number that references the * appropriate "object splitter" - see the language file for the language * you are highlighting to get this number. If $preserve_defaults is * true, then styles are merged with the default styles, with the * user defined styles having priority + * + * @param int The key of the object splitter to change the styles of + * @param string The style to make the methods + * @param boolean Whether to merge the new styles with the old or just + * to overwrite them + * @since 1.0.0 */ - function set_methods_style ( $key, $style, $preserve_defaults = false ) + function set_methods_style ($key, $style, $preserve_defaults = false) { - if ( $preserve_defaults ) - { - $this->language_data['STYLES']['METHODS'][$key] .= $style; - } - else - { + if (!$preserve_defaults) { $this->language_data['STYLES']['METHODS'][$key] = $style; + } else { + $this->language_data['STYLES']['METHODS'][$key] .= $style; } } - /** - * method: set_methods_highlighting - * -------------------------------- * Turns highlighting on/off for methods + * + * @param boolean Whether to turn highlighting for methods on or off + * @since 1.0.0 */ - function set_methods_highlighting ( $flag ) + function set_methods_highlighting ($flag) { - $this->lexic_permissions['METHODS'] = ( $flag ) ? true : false; + $this->lexic_permissions['METHODS'] = ($flag) ? true : false; } - /** - * method: set_regexps_style - * ------------------------- * Sets the styles for regexps. If $preserve_defaults is * true, then styles are merged with the default styles, with the * user defined styles having priority + * + * @param string The style to make the regular expression matches + * @param boolean Whether to merge the new styles with the old or just + * to overwrite them + * @since 1.0.0 */ - function set_regexps_style ( $key, $style, $preserve_defaults = false ) + function set_regexps_style ($key, $style, $preserve_defaults = false) { - if ( $preserve_defaults ) - { - $this->language_data['STYLES']['REGEXPS'][$key] .= $style; - } - else - { + if (!$preserve_defaults) { + $this->language_data['STYLES']['REGEXPS'][$key] = $style; + } else { $this->language_data['STYLES']['REGEXPS'][$key] = $style; } } - /** - * method: set_regexps_highlighting - * -------------------------------- * Turns highlighting on/off for regexps + * + * @param int The key of the regular expression group to turn on or off + * @param boolean Whether to turn highlighting for the regular expression group on or off + * @since 1.0.0 */ - function set_regexps_highlighting ( $key, $flag ) + function set_regexps_highlighting ($key, $flag) { - $this->lexic_permissions['REGEXPS'][$key] = ( $flag ) ? true : false; + $this->lexic_permissions['REGEXPS'][$key] = ($flag) ? true : false; } - /** - * method: set_case_sensitivity - * ---------------------------- * Sets whether a set of keywords are checked for in a case sensitive manner + * + * @param int The key of the keyword group to change the case sensitivity of + * @param boolean Whether to check in a case sensitive manner or not + * @since 1.0.0 */ - function set_case_sensitivity ( $key, $case ) + function set_case_sensitivity ($key, $case) { - $this->language_data['CASE_SENSITIVE'][$key] = ( $case ) ? true : false; + $this->language_data['CASE_SENSITIVE'][$key] = ($case) ? true : false; } - /** - * method: set_case_keywords - * ------------------------- * Sets the case that keywords should use when found. Use the constants: - * GESHI_CAPS_NO_CHANGE: leave keywords as-is - * GESHI_CAPS_UPPER: convert all keywords to uppercase where found - * GESHI_CAPS_LOWER: convert all keywords to lowercase where found - * Method added in 1.0.1 - */ - function set_case_keywords ( $case ) + * + * <ul> + * <li><b>GESHI_CAPS_NO_CHANGE</b>: leave keywords as-is</li> + * <li><b>GESHI_CAPS_UPPER</b>: convert all keywords to uppercase where found</li> + * <li><b>GESHI_CAPS_LOWER</b>: convert all keywords to lowercase where found</li> + * </ul> + * + * @param int A constant specifying what to do with matched keywords + * @since 1.0.1 + * @todo Error check the passed value + */ + function set_case_keywords ($case) { $this->language_data['CASE_KEYWORDS'] = $case; } - /** - * method: set_tab_width - * --------------------- * Sets how many spaces a tab is substituted for - * This method will probably be re-engineered later to allow customisability - * in the maximum and minimum number of tabs without mutulating data fields. + * + * Widths below zero are ignored + * + * @param int The tab width + * @since 1.0.0 */ - function set_tab_width ( $width ) + function set_tab_width ($width) { - if ( $width > $this->max_tabs ) $width = $this->max_tabs; - if ( $width < $this->min_tabs ) $width = $this->min_tabs; - $this->tab_width = $width; + $this->tab_width = intval($width); } - /** - * method: enable_strict_mode - * -------------------------- * Enables/disables strict highlighting. Default is off, calling this * method without parameters will turn it on. See documentation - * for more details on strict mode and where to use it + * for more details on strict mode and where to use it. + * + * @param boolean Whether to enable strict mode or not + * @since 1.0.0 */ - function enable_strict_mode ( $mode = true ) + function enable_strict_mode ($mode = true) { - $this->strict_mode = ( $mode ) ? true : false; - // Turn on strict mode no matter what if language should always - // be in strict mode - if ( $this->language_data['STRICT_MODE_APPLIES'] == GESHI_ALWAYS ) - { - $this->strict_mode = true; - } - // Turn off strict mode no matter what if language should never - // be in strict mode - elseif ( $this->language_data['STRICT_MODE_APPLIES'] == GESHI_NEVER ) - { - $this->strict_mode = false; - } + if (GESHI_MAYBE == $this->language_data['STRICT_MODE_APPLIES']) { + $this->strict_mode = ($mode) ? true : false; + } } - /** - * method: disable_highlighting - * ---------------------------- * Disables all highlighting + * + * @since 1.0.0 + * @todo Rewrite with an array traversal */ function disable_highlighting () { - foreach ( $this->language_data['KEYWORDS'] as $key => $words ) - { - $this->lexic_permissions['KEYWORDS'][$key] = false; - } - foreach ( $this->language_data['COMMENT_SINGLE'] as $key => $comment ) - { - $this->lexic_permissions['COMMENTS'][$key] = false; - } - // Multiline comments - $this->lexic_permissions['COMMENTS']['MULTI'] = false; - // Escape characters - $this->lexic_permissions['ESCAPE_CHAR'] = false; - // Brackets - $this->lexic_permissions['BRACKETS'] = false; - // Strings - $this->lexic_permissions['STRINGS'] = false; - // Numbers - $this->lexic_permissions['NUMBERS'] = false; - // Methods - $this->lexic_permissions['METHODS'] = false; - // Symbols - $this->lexic_permissions['SYMBOLS'] = false; - // Script - $this->lexic_permissions['SCRIPT'] = false; - // Regexps - foreach ( $this->language_data['REGEXPS'] as $key => $regexp ) - { - $this->lexic_permissions['REGEXPS'][$key] = false; - } + foreach ($this->lexic_permissions as $key => $value) { + if (is_array($value)) { + foreach ($value as $k => $v) { + $this->lexic_permissions[$key][$k] = false; + } + } else { + $this->lexic_permissions[$key] = false; + } + } // Context blocks $this->enable_important_blocks = false; } - /** - * method: enable_highlighting - * --------------------------- * Enables all highlighting + * + * @since 1.0.0 + * @todo Rewrite with array traversal */ function enable_highlighting () { - foreach ( $this->language_data['KEYWORDS'] as $key => $words ) - { - $this->lexic_permissions['KEYWORDS'][$key] = true; - } - foreach ( $this->language_data['COMMENT_SINGLE'] as $key => $comment ) - { - $this->lexic_permissions['COMMENTS'][$key] = true; - } - // Multiline comments - $this->lexic_permissions['COMMENTS']['MULTI'] = true; - // Escape characters - $this->lexic_permissions['ESCAPE_CHAR'] = true; - // Brackets - $this->lexic_permissions['BRACKETS'] = true; - // Strings - $this->lexic_permissions['STRINGS'] = true; - // Numbers - $this->lexic_permissions['NUMBERS'] = true; - // Methods - $this->lexic_permissions['METHODS'] = true; - // Symbols - $this->lexic_permissions['SYMBOLS'] = true; - // Script - $this->lexic_permissions['SCRIPT'] = true; - // Regexps - foreach ( $this->language_data['REGEXPS'] as $key => $regexp ) - { - $this->lexic_permissions['REGEXPS'][$key] = true; - } + foreach ($this->lexic_permissions as $key => $value) { + if (is_array($value)) { + foreach ($value as $k => $v) { + $this->lexic_permissions[$key][$k] = true; + } + } else { + $this->lexic_permissions[$key] = true; + } + } // Context blocks $this->enable_important_blocks = true; } - /** - * method: get_language_name_from_extension - * ---------------------------------------- * Given a file extension, this method returns either a valid geshi language * name, or the empty string if it couldn't be found + * + * @param string The extension to get a language name for + * @param array A lookup array to use instead of the default + * @since 1.0.5 + * @todo Re-think about how this method works (maybe make it private and/or make it + * a extension->lang lookup?) + * @todo static? */ function get_language_name_from_extension ( $extension, $lookup = array() ) { @@ -863,7 +1083,7 @@ class GeSHi 'cpp' => array('cpp'), 'csharp' => array(), 'css' => array('css'), - 'delphi' => array('dpk'), + 'delphi' => array('dpk', 'dpr'), 'html4strict' => array('html', 'htm'), 'java' => array('java'), 'javascript' => array('js'), @@ -887,12 +1107,9 @@ class GeSHi ); } - foreach ( $lookup as $lang => $extensions ) - { - foreach ( $extensions as $ext ) - { - if ( $ext == $extension ) - { + foreach ($lookup as $lang => $extensions) { + foreach ($extensions as $ext) { + if ($ext == $extension) { return $lang; } } @@ -901,77 +1118,80 @@ class GeSHi } /** - * Method: load_from_file - * ---------------------- * Given a file name, this method loads its contents in, and attempts * to set the language automatically. An optional lookup table can be - * passed for looking up the language name. + * passed for looking up the language name. If not specified a default + * table is used * * The language table is in the form * <pre>array( * 'lang_name' => array('extension', 'extension', ...), * 'lang_name' ... * );</pre> + * + * @todo Complete rethink of this and above method + * @since 1.0.5 */ - function load_from_file ( $file_name, $lookup = array() ) + function load_from_file ($file_name, $lookup = array()) { - if ( is_readable($file_name) ) - { + if (is_readable($file_name)) { $this->set_source(implode('', file($file_name))); $this->set_language($this->get_language_name_from_extension(substr(strrchr($file_name, '.'), 1), $lookup)); - } - else - { + } else { $this->error = GESHI_ERROR_FILE_NOT_READABLE; } } /** - * method: add_keyword - * ------------------- * Adds a keyword to a keyword group for highlighting + * + * @param int The key of the keyword group to add the keyword to + * @param string The word to add to the keyword group + * @since 1.0.0 */ - function add_keyword( $key, $word ) + function add_keyword ($key, $word) { $this->language_data['KEYWORDS'][$key][] = $word; } - /** - * method: remove_keyword - * ---------------------- * Removes a keyword from a keyword group + * + * @param int The key of the keyword group to remove the keyword from + * @param string The word to remove from the keyword group + * @since 1.0.0 */ - function remove_keyword ( $key, $word ) + function remove_keyword ($key, $word) { - $this->language_data['KEYWORDS'][$key] = array_diff($this->language_data['KEYWORDS'][$key], array($word)); + $this->language_data['KEYWORDS'][$key] = + array_diff($this->language_data['KEYWORDS'][$key], array($word)); } - /** - * method: add_keyword_group - * ------------------------- * Creates a new keyword group + * + * @param int The key of the keyword group to create + * @param string The styles for the keyword group + * @param boolean Whether the keyword group is case sensitive ornot + * @param array The words to use for the keyword group + * @since 1.0.0 */ function add_keyword_group ( $key, $styles, $case_sensitive = true, $words = array() ) { - if ( !is_array($words) ) - { - $words = array($words); - } + $words = (array) $words; $this->language_data['KEYWORDS'][$key] = $words; $this->lexic_permissions['KEYWORDS'][$key] = true; $this->language_data['CASE_SENSITIVE'][$key] = $case_sensitive; $this->language_data['STYLES']['KEYWORDS'][$key] = $styles; } - /** - * method: remove_keyword_group - * ---------------------------- * Removes a keyword group + * + * @param int The key of the keyword group to remove + * @since 1.0.0 */ - function remove_keyword_group ( $key ) + function remove_keyword_group ($key) { unset($this->language_data['KEYWORDS'][$key]); unset($this->lexic_permissions['KEYWORDS'][$key]); @@ -979,205 +1199,210 @@ class GeSHi unset($this->language_data['STYLES']['KEYWORDS'][$key]); } - /** - * method: set_header_content - * -------------------------- * Sets the content of the header block + * + * @param string The content of the header block + * @since 1.0.2 */ - function set_header_content ( $content ) + function set_header_content ($content) { $this->header_content = $content; } - /** - * method: set_footer_content - * -------------------------- * Sets the content of the footer block + * + * @param string The content of the footer block + * @since 1.0.2 */ - function set_footer_content ( $content ) + function set_footer_content ($content) { $this->footer_content = $content; } - /** - * method: set_header_content_style - * -------------------------------- * Sets the style for the header content + * + * @param string The style for the header content + * @since 1.0.2 */ - function set_header_content_style ( $style ) + function set_header_content_style ($style) { $this->header_content_style = $style; } - /** - * method: set_footer_content_style - * -------------------------------- * Sets the style for the footer content + * + * @param string The style for the footer content + * @since 1.0.2 */ - function set_footer_content_style ( $style ) + function set_footer_content_style ($style) { $this->footer_content_style = $style; } - /** - * method: set_url_for_keyword_group - * --------------------------------- * Sets the base URL to be used for keywords + * + * @param int The key of the keyword group to set the URL for + * @param string The URL to set for the group. If {FNAME} is in + * the url somewhere, it is replaced by the keyword + * that the URL is being made for + * @since 1.0.2 */ - function set_url_for_keyword_group ( $group, $url ) + function set_url_for_keyword_group ($group, $url) { $this->language_data['URLS'][$group] = $url; } - /** - * method: set_link_styles - * ----------------------- * Sets styles for links in code + * + * @param int A constant that specifies what state the style is being + * set for - e.g. :hover or :visited + * @param string The styles to use for that state + * @since 1.0.2 */ - function set_link_styles ( $type, $styles ) + function set_link_styles ($type, $styles) { $this->link_styles[$type] = $styles; } - /** - * method: set_link_target - * ----------------------- - * Sets the target for links in code - */ + * Sets the target for links in code + * + * @param string The target for links in the code, e.g. _blank + * @since 1.0.3 + */ function set_link_target ( $target ) { - if ( empty( $target ) ) - { + if (!$target) { $this->link_target = ''; - } - else - { + } else { $this->link_target = ' target="' . $target . '" '; } } - /** - * method: set_important_styles - * ---------------------------- * Sets styles for important parts of the code + * + * @param string The styles to use on important parts of the code + * @since 1.0.2 */ - function set_important_styles ( $styles ) + function set_important_styles ($styles) { $this->important_styles = $styles; } - /** - * method: enable_important_blocks - * ------------------------------- * Sets whether context-important blocks are highlighted + * + * @todo REMOVE THIS SHIZ FROM GESHI! */ function enable_important_blocks ( $flag ) { $this->enable_important_blocks = ( $flag ) ? true : false; } - /** - * method: enable_ids - * ------------------ * Whether CSS IDs should be added to each line + * + * @param boolean If true, IDs will be added to each line. + * @since 1.0.2 */ - function enable_ids ( $flag = true ) + function enable_ids ($flag = true) { - $this->add_ids = ( $flag ) ? true : false; + $this->add_ids = ($flag) ? true : false; } - /** - * method: highlight_lines_extra - * ----------------------------- * Specifies which lines to highlight extra + * + * @param mixed An array of line numbers to highlight, or just a line + * number on its own. + * @since 1.0.2 + * @todo Some data replication here that could be cut down on */ - function highlight_lines_extra ( $lines ) + function highlight_lines_extra ($lines) { - if ( is_array($lines) ) - { - foreach ( $lines as $line ) - { + if (is_array($lines)) { + foreach ($lines as $line) { $this->highlight_extra_lines[intval($line)] = intval($line); } - } - else - { + } else { $this->highlight_extra_lines[intval($lines)] = intval($lines); } } - /** - * method: set_highlight_lines_extra_style - * --------------------------------------- * Sets the style for extra-highlighted lines + * + * @param string The style for extra-highlighted lines + * @since 1.0.2 */ - function set_highlight_lines_extra_style ( $styles ) + function set_highlight_lines_extra_style ($styles) { $this->highlight_extra_lines_style = $styles; } - /** - * method: start_line_numbers_at - * ----------------------------- * Sets what number line numbers should start at. Should * be a positive integer, and will be converted to one. - */ - function start_line_numbers_at ( $number ) + * + * <b>Warning:</b> Using this method will add the "start" + * attribute to the <ol> that is used for line numbering. + * This is <b>not</b> valid XHTML strict, so if that's what you + * care about then don't use this method. Firefox is getting + * support for the CSS method of doing this in 1.1 and Opera + * has support for the CSS method, but (of course) IE doesn't + * so it's not worth doing it the CSS way yet. + * + * @param int The number to start line numbers at + * @since 1.0.2 + */ + function start_line_numbers_at ($number) { $this->line_numbers_start = abs(intval($number)); } - /** - * method: set_encoding - * -------------------- - * Sets the encoding used for @htmlentities(), for international + * Sets the encoding used for htmlspecialchars(), for international * support. + * + * @param string The encoding to use for the source + * @since 1.0.3 */ - function set_encoding ( $encoding ) + function set_encoding ($encoding) { - $this->encoding = $encoding; + if ($encoding) { + $this->encoding = $encoding; + } } - /** - * method: parse_code() - * -------------------- * Returns the code in $this->source, highlighted and surrounded by the - * nessecary HTML. This should only be called ONCE, cos it's SLOW! - * If you want to highlight the same source multiple times, you're better - * off doing a whole lot of str_replaces to replace the <<span>>s + * nessecary HTML. + * + * This should only be called ONCE, cos it's SLOW! If you want to highlight + * the same source multiple times, you're better off doing a whole lot of + * str_replaces to replace the <span>s + * + * @since 1.0.0 */ - function parse_code() + function parse_code () { // Start the timer $start_time = microtime(); // Firstly, if there is an error, we won't highlight - // FUTURE: maybe an option to try to force highlighting anyway? - if ( $this->error ) - { + if ($this->error) { $result = $this->header(); - if ( $this->header_type != GESHI_HEADER_PRE ) - { - $result .= $this->indent(@htmlentities($this->source, ENT_COMPAT, $this->encoding)); - } - else - { - $result .= @htmlentities($this->source, ENT_COMPAT, $this->encoding); + if ($this->header_type != GESHI_HEADER_PRE) { + $result .= $this->indent(@htmlspecialchars($this->source, ENT_COMPAT, $this->encoding)); + } else { + $result .= @htmlspecialchars($this->source, ENT_COMPAT, $this->encoding); } // Stop Timing $this->set_time($start_time, microtime()); @@ -1191,67 +1416,54 @@ class GeSHi $code = str_replace("\r", "\n", $code); // Initialise various stuff - $length = strlen($code); - $STRING_OPEN = ''; - $CLOSE_STRING = false; + $length = strlen($code); + $STRING_OPEN = ''; + $CLOSE_STRING = false; $ESCAPE_CHAR_OPEN = false; - $COMMENT_MATCHED = false; + $COMMENT_MATCHED = false; // Turn highlighting on if strict mode doesn't apply to this language - $HIGHLIGHTING_ON = ( !$this->strict_mode ) ? true : ''; + $HIGHLIGHTING_ON = ( !$this->strict_mode ) ? true : ''; // Whether to highlight inside a block of code $HIGHLIGHT_INSIDE_STRICT = false; - $stuff_to_parse = ''; - $result = ''; + $stuff_to_parse = ''; + $result = ''; // "Important" selections are handled like multiline comments - if ( $this->enable_important_blocks ) - { + // @todo GET RID OF THIS SHIZ + if ($this->enable_important_blocks) { $this->language_data['COMMENT_MULTI'][GESHI_START_IMPORTANT] = GESHI_END_IMPORTANT; } - - if ( $this->strict_mode ) - { + if ($this->strict_mode) { // Break the source into bits. Each bit will be a portion of the code // within script delimiters - for example, HTML between < and > $parts = array(0 => array(0 => '')); $k = 0; - for ( $i = 0; $i < $length; $i++ ) - { + for ($i = 0; $i < $length; $i++) { $char = substr($code, $i, 1); - if ( !$HIGHLIGHTING_ON ) - { - foreach ( $this->language_data['SCRIPT_DELIMITERS'] as $key => $delimiters ) - { - foreach ( $delimiters as $open => $close ) - { + if (!$HIGHLIGHTING_ON) { + foreach ($this->language_data['SCRIPT_DELIMITERS'] as $key => $delimiters) { + foreach ($delimiters as $open => $close) { // Get the next little bit for this opening string $check = substr($code, $i, strlen($open)); // If it matches... - if ( $check == $open ) - { + if ($check == $open) { // We start a new block with the highlightable // code in it $HIGHLIGHTING_ON = $open; $i += strlen($open) - 1; - ++$k; $char = $open; - $parts[$k][0] = $char; + $parts[++$k][0] = $char; // No point going around again... break(2); } } } - } - else - { - foreach ( $this->language_data['SCRIPT_DELIMITERS'] as $key => $delimiters ) - { - foreach ( $delimiters as $open => $close ) - { - if ( $open == $HIGHLIGHTING_ON ) - { + } else { + foreach ($this->language_data['SCRIPT_DELIMITERS'] as $key => $delimiters) { + foreach ($delimiters as $open => $close) { + if ($open == $HIGHLIGHTING_ON) { // Found the closing tag break(2); } @@ -1260,22 +1472,18 @@ class GeSHi // We check code from our current position BACKWARDS. This is so // the ending string for highlighting can be included in the block $check = substr($code, $i - strlen($close) + 1, strlen($close)); - if ( $check == $close ) - { + if ($check == $close) { $HIGHLIGHTING_ON = ''; // Add the string to the rest of the string for this part $parts[$k][1] = ( isset($parts[$k][1]) ) ? $parts[$k][1] . $char : $char; - ++$k; - $parts[$k][0] = ''; + $parts[++$k][0] = ''; $char = ''; } } $parts[$k][1] = ( isset($parts[$k][1]) ) ? $parts[$k][1] . $char : $char; } $HIGHLIGHTING_ON = ''; - } - else - { + } else { // Not strict mode - simply dump the source into // the array at index 1 (the first highlightable block) $parts = array( @@ -1289,336 +1497,256 @@ class GeSHi // Now we go through each part. We know that even-indexed parts are // code that shouldn't be highlighted, and odd-indexed parts should // be highlighted - foreach ( $parts as $key => $data ) - { + foreach ($parts as $key => $data) { $part = $data[1]; // If this block should be highlighted... - if ( $key % 2 ) - { - if ( $this->strict_mode ) - { + if ($key % 2) { + if ($this->strict_mode) { // Find the class key for this block of code - foreach ( $this->language_data['SCRIPT_DELIMITERS'] as $script_key => $script_data ) - { - foreach ( $script_data as $open => $close ) - { - if ( $data[0] == $open ) - { + foreach ($this->language_data['SCRIPT_DELIMITERS'] as $script_key => $script_data) { + foreach ($script_data as $open => $close) { + if ($data[0] == $open) { break(2); } } } - if ( $this->language_data['STYLES']['SCRIPT'][$script_key] != '' && $this->lexic_permissions['SCRIPT'] ) - { + if ($this->language_data['STYLES']['SCRIPT'][$script_key] != '' && + $this->lexic_permissions['SCRIPT']) { // Add a span element around the source to // highlight the overall source block - if ( !$this->use_classes && $this->language_data['STYLES']['SCRIPT'][$script_key] != '' ) - { + if (!$this->use_classes && + $this->language_data['STYLES']['SCRIPT'][$script_key] != '') { $attributes = ' style="' . $this->language_data['STYLES']['SCRIPT'][$script_key] . '"'; - } - else - { + } else { $attributes = ' class="sc' . $script_key . '"'; } $result .= "<span$attributes>"; } } - if ( !$this->strict_mode || $this->language_data['HIGHLIGHT_STRICT_BLOCK'][$script_key] ) - { + if (!$this->strict_mode || $this->language_data['HIGHLIGHT_STRICT_BLOCK'][$script_key]) { // Now, highlight the code in this block. This code // is really the engine of GeSHi (along with the method // parse_non_string_part). $length = strlen($part); - for ( $i = 0; $i < $length; $i++ ) - { + for ($i = 0; $i < $length; $i++) { // Get the next char $char = substr($part, $i, 1); // Is this char the newline and line numbers being used? - if ( ($this->line_numbers != GESHI_NO_LINE_NUMBERS || count($this->highlight_extra_lines) > 0) && $char == "\n" ) - { + if (($this->line_numbers != GESHI_NO_LINE_NUMBERS + || count($this->highlight_extra_lines) > 0) + && $char == "\n") { // If so, is there a string open? If there is, we should end it before // the newline and begin it again (so when <li>s are put in the source // remains XHTML compliant) - // NOTE TO SELF: This opens up possibility of config files specifying + // note to self: This opens up possibility of config files specifying // that languages can/cannot have multiline strings??? - if ( $STRING_OPEN ) - { - if ( !$this->use_classes ) - { + if ($STRING_OPEN) { + if (!$this->use_classes) { $attributes = ' style="' . $this->language_data['STYLES']['STRINGS'][0] . '"'; - } - else - { + } else { $attributes = ' class="st0"'; } $char = '</span>' . $char . "<span$attributes>"; } - } - // Is this a match of a string delimiter? - elseif ( $char == $STRING_OPEN ) - { - if ( ($this->lexic_permissions['ESCAPE_CHAR'] && $ESCAPE_CHAR_OPEN) || ($this->lexic_permissions['STRINGS'] && !$ESCAPE_CHAR_OPEN) ) - { + } elseif ($char == $STRING_OPEN) { + // A match of a string delimiter + if (($this->lexic_permissions['ESCAPE_CHAR'] && $ESCAPE_CHAR_OPEN) || + ($this->lexic_permissions['STRINGS'] && !$ESCAPE_CHAR_OPEN)) { $char .= '</span>'; } - if ( !$ESCAPE_CHAR_OPEN ) - { + if (!$ESCAPE_CHAR_OPEN) { $STRING_OPEN = ''; $CLOSE_STRING = true; } $ESCAPE_CHAR_OPEN = false; - } - // Is this the start of a new string? - elseif ( in_array( $char, $this->language_data['QUOTEMARKS'] ) && ($STRING_OPEN == '') && $this->lexic_permissions['STRINGS'] ) - { + } elseif (in_array($char, $this->language_data['QUOTEMARKS']) && + ($STRING_OPEN == '') && $this->lexic_permissions['STRINGS']) { + // The start of a new string $STRING_OPEN = $char; - if ( !$this->use_classes ) - { + if (!$this->use_classes) { $attributes = ' style="' . $this->language_data['STYLES']['STRINGS'][0] . '"'; - } - else - { + } else { $attributes = ' class="st0"'; } $char = "<span$attributes>" . $char; $result .= $this->parse_non_string_part( $stuff_to_parse ); $stuff_to_parse = ''; - } - // Is this an escape char? - elseif ( ($char == $this->language_data['ESCAPE_CHAR']) && ($STRING_OPEN != '') ) - { - if ( !$ESCAPE_CHAR_OPEN ) - { + } elseif (($char == $this->language_data['ESCAPE_CHAR']) && ($STRING_OPEN != '')) { + // An escape character + if (!$ESCAPE_CHAR_OPEN) { $ESCAPE_CHAR_OPEN = true; - if ( $this->lexic_permissions['ESCAPE_CHAR'] ) - { - if ( !$this->use_classes ) - { + if ($this->lexic_permissions['ESCAPE_CHAR']) { + if (!$this->use_classes) { $attributes = ' style="' . $this->language_data['STYLES']['ESCAPE_CHAR'][0] . '"'; - } - else - { + } else { $attributes = ' class="es0"'; } $char = "<span$attributes>" . $char; } - } - else - { + } else { $ESCAPE_CHAR_OPEN = false; - if ( $this->lexic_permissions['ESCAPE_CHAR'] ) - { + if ($this->lexic_permissions['ESCAPE_CHAR']) { $char .= '</span>'; } } - } - elseif ( $ESCAPE_CHAR_OPEN ) - { - if ( $this->lexic_permissions['ESCAPE_CHAR'] ) - { + } elseif ($ESCAPE_CHAR_OPEN) { + if ($this->lexic_permissions['ESCAPE_CHAR']) { $char .= '</span>'; } $ESCAPE_CHAR_OPEN = false; $test_str = $char; - } - elseif ( $STRING_OPEN == '' ) - { + } elseif ($STRING_OPEN == '') { // Is this a multiline comment? - foreach ( $this->language_data['COMMENT_MULTI'] as $open => $close ) - { + foreach ($this->language_data['COMMENT_MULTI'] as $open => $close) { $com_len = strlen($open); $test_str = substr( $part, $i, $com_len ); $test_str_match = $test_str; - if ( $open == $test_str ) - { + if ($open == $test_str) { $COMMENT_MATCHED = true; - if ( $this->lexic_permissions['COMMENTS']['MULTI'] || $test_str == GESHI_START_IMPORTANT ) - { - if ( $test_str != GESHI_START_IMPORTANT ) - { - if ( !$this->use_classes ) - { + //@todo If remove important do remove here + if ($this->lexic_permissions['COMMENTS']['MULTI'] || + $test_str == GESHI_START_IMPORTANT) { + if ($test_str != GESHI_START_IMPORTANT) { + if (!$this->use_classes) { $attributes = ' style="' . $this->language_data['STYLES']['COMMENTS']['MULTI'] . '"'; - } - else - { + } else { $attributes = ' class="coMULTI"'; } - $test_str = "<span$attributes>" . @htmlentities($test_str, ENT_COMPAT, $this->encoding); - } - else - { - if ( !$this->use_classes ) - { + $test_str = "<span$attributes>" . @htmlspecialchars($test_str, ENT_COMPAT, $this->encoding); + } else { + if (!$this->use_classes) { $attributes = ' style="' . $this->important_styles . '"'; - } - else - { + } else { $attributes = ' class="imp"'; } // We don't include the start of the comment if it's an // "important" part $test_str = "<span$attributes>"; } - } - else - { - $test_str = @htmlentities($test_str, ENT_COMPAT, $this->encoding); + } else { + $test_str = @htmlspecialchars($test_str, ENT_COMPAT, $this->encoding); } $close_pos = strpos( $part, $close, $i + strlen($close) ); - if ( $close_pos === false ) - { + if ($close_pos === false) { $close_pos = strlen($part); } // Short-cut through all the multiline code - $rest_of_comment = @htmlentities(substr($part, $i + $com_len, $close_pos - $i), ENT_COMPAT, $this->encoding); - if ( ($this->lexic_permissions['COMMENTS']['MULTI'] || $test_str_match == GESHI_START_IMPORTANT) && ($this->line_numbers != GESHI_NO_LINE_NUMBERS || count($this->highlight_extra_lines) > 0) ) - { + $rest_of_comment = @htmlspecialchars(substr($part, $i + $com_len, $close_pos - $i), ENT_COMPAT, $this->encoding); + if (($this->lexic_permissions['COMMENTS']['MULTI'] || + $test_str_match == GESHI_START_IMPORTANT) && + ($this->line_numbers != GESHI_NO_LINE_NUMBERS || + count($this->highlight_extra_lines) > 0)) { // strreplace to put close span and open span around multiline newlines $test_str .= str_replace("\n", "</span>\n<span$attributes>", $rest_of_comment); - } - else - { + } else { $test_str .= $rest_of_comment; } - if ( $this->lexic_permissions['COMMENTS']['MULTI'] || $test_str_match == GESHI_START_IMPORTANT ) - { + if ($this->lexic_permissions['COMMENTS']['MULTI'] || + $test_str_match == GESHI_START_IMPORTANT) { $test_str .= '</span>'; } $i = $close_pos + $com_len - 1; // parse the rest - $result .= $this->parse_non_string_part( $stuff_to_parse ); + $result .= $this->parse_non_string_part($stuff_to_parse); $stuff_to_parse = ''; break; } } // If we haven't matched a multiline comment, try single-line comments - if ( !$COMMENT_MATCHED ) - { - foreach ( $this->language_data['COMMENT_SINGLE'] as $comment_key => $comment_mark ) - { + if (!$COMMENT_MATCHED) { + foreach ($this->language_data['COMMENT_SINGLE'] as $comment_key => $comment_mark) { $com_len = strlen($comment_mark); - $test_str = substr( $part, $i, $com_len ); - if ( $this->language_data['CASE_SENSITIVE'][GESHI_COMMENTS] ) - { - $match = ( $comment_mark == $test_str ); - } - else - { - $match = ( strtolower($comment_mark) == strtolower($test_str) ); + $test_str = substr($part, $i, $com_len); + if ($this->language_data['CASE_SENSITIVE'][GESHI_COMMENTS]) { + $match = ($comment_mark == $test_str); + } else { + $match = (strtolower($comment_mark) == strtolower($test_str)); } - if ( $match ) - { + if ($match) { $COMMENT_MATCHED = true; - if ( $this->lexic_permissions['COMMENTS'][$comment_key] ) - { - if ( !$this->use_classes ) - { + if ($this->lexic_permissions['COMMENTS'][$comment_key]) { + if (!$this->use_classes) { $attributes = ' style="' . $this->language_data['STYLES']['COMMENTS'][$comment_key] . '"'; - } - else - { + } else { $attributes = ' class="co' . $comment_key . '"'; } - $test_str = "<span$attributes>" . @htmlentities($this->change_case($test_str), ENT_COMPAT, $this->encoding); + $test_str = "<span$attributes>" . @htmlspecialchars($this->change_case($test_str), ENT_COMPAT, $this->encoding); + } else { + $test_str = @htmlspecialchars($test_str, ENT_COMPAT, $this->encoding); } - else - { - $test_str = @htmlentities($test_str, ENT_COMPAT, $this->encoding); - } - $close_pos = strpos( $part, "\n", $i ); - if ( $close_pos === false ) - { + $close_pos = strpos($part, "\n", $i); + if ($close_pos === false) { $close_pos = strlen($part); } - $test_str .= @htmlentities(substr($part, $i + $com_len, $close_pos - $i - $com_len), ENT_COMPAT, $this->encoding); - if ( $this->lexic_permissions['COMMENTS'][$comment_key] ) - { + $test_str .= @htmlspecialchars(substr($part, $i + $com_len, $close_pos - $i - $com_len), ENT_COMPAT, $this->encoding); + if ($this->lexic_permissions['COMMENTS'][$comment_key]) { $test_str .= "</span>"; } $test_str .= "\n"; $i = $close_pos; // parse the rest - $result .= $this->parse_non_string_part( $stuff_to_parse ); + $result .= $this->parse_non_string_part($stuff_to_parse); $stuff_to_parse = ''; break; } } } - } - // Otherwise, convert it to HTML form - elseif ( $STRING_OPEN != '' ) - { - if ( strtolower($this->encoding) == 'utf-8' ) - { + } elseif ($STRING_OPEN != '') { + // Otherwise, convert it to HTML form + if (strtolower($this->encoding) == 'utf-8') { //only escape <128 (we don't want to break multibyte chars) - if ( ord($char) < 128 ) - { - $char = htmlentities($char, ENT_COMPAT, $this->encoding); + if (ord($char) < 128) { + $char = @htmlspecialchars($char, ENT_COMPAT, $this->encoding); } - } - else - { + } else { //encode everthing - $char = htmlentities($char, ENT_COMPAT, $this->encoding); + $char = @htmlspecialchars($char, ENT_COMPAT, $this->encoding); } } // Where are we adding this char? - if ( !$COMMENT_MATCHED ) - { - if ( ($STRING_OPEN == '') && !$CLOSE_STRING ) - { + if (!$COMMENT_MATCHED) { + if (($STRING_OPEN == '') && !$CLOSE_STRING) { $stuff_to_parse .= $char; - } - else - { + } else { $result .= $char; $CLOSE_STRING = false; } - } - else - { + } else { $result .= $test_str; $COMMENT_MATCHED = false; } } // Parse the last bit - $result .= $this->parse_non_string_part( $stuff_to_parse ); + $result .= $this->parse_non_string_part($stuff_to_parse); $stuff_to_parse = ''; - } - else - { - $result .= @htmlentities($part, ENT_COMPAT, $this->encoding); + } else { + $result .= @htmlspecialchars($part, ENT_COMPAT, $this->encoding); } // Close the <span> that surrounds the block - if ( $this->strict_mode && $this->lexic_permissions['SCRIPT'] ) - { + if ($this->strict_mode && $this->lexic_permissions['SCRIPT']) { $result .= '</span>'; } - } - // Else not a block to highlight - else - { - $result .= @htmlentities($part, ENT_COMPAT, $this->encoding); + } else { + // Else not a block to highlight + $result .= @htmlspecialchars($part, ENT_COMPAT, $this->encoding); } } // Parse the last stuff (redundant?) - $result .= $this->parse_non_string_part( $stuff_to_parse ); + $result .= $this->parse_non_string_part($stuff_to_parse); // Lop off the very first and last spaces $result = substr($result, 1, strlen($result) - 1); // Are we still in a string? - if ( $STRING_OPEN ) - { + if ($STRING_OPEN) { $result .= '</span>'; } @@ -1629,12 +1757,15 @@ class GeSHi } /** - * method: indent - * -------------- * Swaps out spaces and tabs for HTML indentation. Not needed if * the code is in a pre block... + * + * @param string The source to indent + * @return string The source with HTML indenting applied + * @since 1.0.0 + * @access private */ - function indent ( $result ) + function indent ($result) { /// Replace tabs with the correct number of spaces if (false !== strpos($result, "\t")) { @@ -1717,92 +1848,98 @@ class GeSHi $result = str_replace(' ', ' ', $result); $result = str_replace(' ', ' ', $result); $result = str_replace("\n ", "\n ", $result); - //$result = str_replace("\t", $this->get_tab_replacement(), $result); - if ( $this->line_numbers == GESHI_NO_LINE_NUMBERS ) - { + + if ($this->line_numbers == GESHI_NO_LINE_NUMBERS) { $result = nl2br($result); } return $result; } /** - * method: change_case - * ------------------- * Changes the case of a keyword for those languages where a change is asked for + * + * @param string The keyword to change the case of + * @return string The keyword with its case changed + * @since 1.0.0 + * @access private */ - function change_case ( $instr ) + function change_case ($instr) { - if ( $this->language_data['CASE_KEYWORDS'] == GESHI_CAPS_UPPER ) - { + if ($this->language_data['CASE_KEYWORDS'] == GESHI_CAPS_UPPER) { return strtoupper($instr); - } - elseif ( $this->language_data['CASE_KEYWORDS'] == GESHI_CAPS_LOWER ) - { + } elseif ($this->language_data['CASE_KEYWORDS'] == GESHI_CAPS_LOWER) { return strtolower($instr); } return $instr; } - /** - * method: add_url_to_keyword - * -------------------------- * Adds a url to a keyword where needed. - * Added in 1.0.2 - */ - function add_url_to_keyword ( $keyword, $group, $start_or_end ) - { - if ( isset($this->language_data['URLS'][$group]) && $this->language_data['URLS'][$group] != '' && substr($keyword, 0, 5) != '</' ) - { + * + * @param string The keyword to add the URL HTML to + * @param int What group the keyword is from + * @param boolean Whether to get the HTML for the start or end + * @return The HTML for either the start or end of the HTML <a> tag + * @since 1.0.2 + * @access private + * @todo Get rid of ender + */ + function add_url_to_keyword ($keyword, $group, $start_or_end) + { + if (isset($this->language_data['URLS'][$group]) && + $this->language_data['URLS'][$group] != '' && + substr($keyword, 0, 5) != '</') { // There is a base group for this keyword - - if ( $start_or_end == 'BEGIN' ) - { + if ($start_or_end == 'BEGIN') { // HTML workaround... not good form (tm) but should work for 1.0.X $keyword = ( substr($keyword, 0, 4) == '<' ) ? substr($keyword, 4) : $keyword; $keyword = ( substr($keyword, -4) == '>' ) ? substr($keyword, 0, strlen($keyword) - 4) : $keyword; - if ( $keyword != '' ) - { + if ($keyword != '') { $keyword = ( $this->language_data['CASE_SENSITIVE'][$group] ) ? $keyword : strtolower($keyword); - return '<|UR1|"' . str_replace(array('{FNAME}', '.'), array(@htmlentities($keyword, ENT_COMPAT, $this->encoding), '<DOT>'), $this->language_data['URLS'][$group]) . '">'; + return '<|UR1|"' . + str_replace( + array('{FNAME}', '.'), + array(@htmlspecialchars($keyword, ENT_COMPAT, $this->encoding), '<DOT>'), + $this->language_data['URLS'][$group] + ) . '">'; } return ''; - } - else - { + } else { return '</a>'; } } } - /** - * method: parse_non_string_part - * ----------------------------- * Takes a string that has no strings or comments in it, and highlights * stuff like keywords, numbers and methods. + * + * @param string The string to parse for keyword, numbers etc. + * @since 1.0.0 + * @access private + * @todo BUGGY! Why? Why not build string and return? */ - function parse_non_string_part ( &$stuff_to_parse ) + function parse_non_string_part (&$stuff_to_parse) { - $stuff_to_parse = ' ' . quotemeta(@htmlentities($stuff_to_parse, ENT_COMPAT, $this->encoding)); + $stuff_to_parse = ' ' . quotemeta(@htmlspecialchars($stuff_to_parse, ENT_COMPAT, $this->encoding)); // These vars will disappear in the future $func = '$this->change_case'; $func2 = '$this->add_url_to_keyword'; - // // Regular expressions // - foreach ( $this->language_data['REGEXPS'] as $key => $regexp ) - { - if ( $this->lexic_permissions['REGEXPS'][$key] ) - { - if ( is_array($regexp) ) - { - $stuff_to_parse = preg_replace( "#" . $regexp[GESHI_SEARCH] . "#{$regexp[GESHI_MODIFIERS]}", "{$regexp[GESHI_BEFORE]}<|!REG3XP$key!>{$regexp[GESHI_REPLACE]}|>{$regexp[GESHI_AFTER]}", $stuff_to_parse); - } - else - { + foreach ($this->language_data['REGEXPS'] as $key => $regexp) { + if ($this->lexic_permissions['REGEXPS'][$key]) { + if (is_array($regexp)) { + $stuff_to_parse = preg_replace( + "#" . + $regexp[GESHI_SEARCH] . + "#{$regexp[GESHI_MODIFIERS]}", + "{$regexp[GESHI_BEFORE]}<|!REG3XP$key!>{$regexp[GESHI_REPLACE]}|>{$regexp[GESHI_AFTER]}", + $stuff_to_parse + ); + } else { $stuff_to_parse = preg_replace( "#(" . $regexp . ")#", "<|!REG3XP$key!>\\1|>", $stuff_to_parse); } } @@ -1815,22 +1952,17 @@ class GeSHi // being highlighted twice (eg <span...><span...>5</span></span>) // Put /NUM!/ in for the styles, which gets replaced at the end. // - if ( $this->lexic_permissions['NUMBERS'] && preg_match('#[0-9]#', $stuff_to_parse ) ) - { + if ($this->lexic_permissions['NUMBERS'] && preg_match('#[0-9]#', $stuff_to_parse )) { $stuff_to_parse = preg_replace('#([^a-zA-Z0-9\#])([0-9]+)([^a-zA-Z0-9])#', "\\1<|/NUM!/>\\2|>\\3", $stuff_to_parse); $stuff_to_parse = preg_replace('#([^a-zA-Z0-9\#>])([0-9]+)([^a-zA-Z0-9])#', "\\1<|/NUM!/>\\2|>\\3", $stuff_to_parse); } // Highlight keywords // if there is a couple of alpha symbols there *might* be a keyword - if ( preg_match('#[a-zA-Z]{2,}#', $stuff_to_parse) ) - { - foreach ( $this->language_data['KEYWORDS'] as $k => $keywordset ) - { - if ( $this->lexic_permissions['KEYWORDS'][$k] ) - { - foreach ( $keywordset as $keyword ) - { + if (preg_match('#[a-zA-Z]{2,}#', $stuff_to_parse)) { + foreach ($this->language_data['KEYWORDS'] as $k => $keywordset) { + if ($this->lexic_permissions['KEYWORDS'][$k]) { + foreach ($keywordset as $keyword) { $keyword = quotemeta($keyword); // // This replacement checks the word is on it's own (except if brackets etc @@ -1838,22 +1970,26 @@ class GeSHi // in just yet - otherwise languages with the keywords "color" or "or" have // a fit. // - if ( false !== stristr($stuff_to_parse, $keyword ) ) - { + if (false !== stristr($stuff_to_parse, $keyword )) { $stuff_to_parse .= ' '; // Might make a more unique string for putting the number in soon // Basically, we don't put the styles in yet because then the styles themselves will // get highlighted if the language has a CSS keyword in it (like CSS, for example ;)) $styles = "/$k/"; $keyword = quotemeta($keyword); - if ( $this->language_data['CASE_SENSITIVE'][$k] ) - { - $stuff_to_parse = preg_replace("#([^a-zA-Z0-9\$_\|\.\#;>])($keyword)([^a-zA-Z0-9_<\|%\-&])#e", "'\\1' . $func2('\\2', '$k', 'BEGIN') . '<|$styles>' . $func('\\2') . '|>' . $func2('\\2', '$k', 'END') . '\\3'", $stuff_to_parse); - } - else - { + if ($this->language_data['CASE_SENSITIVE'][$k]) { + $stuff_to_parse = preg_replace( + "#([^a-zA-Z0-9\$_\|\.\#;>])($keyword)([^a-zA-Z0-9_<\|%\-&])#e", + "'\\1' . $func2('\\2', '$k', 'BEGIN') . '<|$styles>' . $func('\\2') . '|>' . $func2('\\2', '$k', 'END') . '\\3'", + $stuff_to_parse + ); + } else { // Change the case of the word. - $stuff_to_parse = preg_replace("#([^a-zA-Z0-9\$_\|\.\#;>])($keyword)([^a-zA-Z0-9_<\|%\-&])#ie", "'\\1' . $func2('\\2', '$k', 'BEGIN') . '<|$styles>' . $func('\\2') . '|>' . $func2('\\2', '$k', 'END') . '\\3'", $stuff_to_parse); + $stuff_to_parse = preg_replace( + "#([^a-zA-Z0-9\$_\|\.\#;>])($keyword)([^a-zA-Z0-9_<\|%\-&])#ie", + "'\\1' . $func2('\\2', '$k', 'BEGIN') . '<|$styles>' . $func('\\2') . '|>' . $func2('\\2', '$k', 'END') . '\\3'", + $stuff_to_parse + ); } $stuff_to_parse = substr($stuff_to_parse, 0, strlen($stuff_to_parse) - 1); } @@ -1865,26 +2001,19 @@ class GeSHi // // Now that's all done, replace /[number]/ with the correct styles // - foreach ( $this->language_data['KEYWORDS'] as $k => $kws ) - { - if ( !$this->use_classes ) - { + foreach ($this->language_data['KEYWORDS'] as $k => $kws) { + if (!$this->use_classes) { $attributes = ' style="' . $this->language_data['STYLES']['KEYWORDS'][$k] . '"'; - } - else - { + } else { $attributes = ' class="kw' . $k . '"'; } $stuff_to_parse = str_replace("/$k/", $attributes, $stuff_to_parse); } // Put number styles in - if ( !$this->use_classes && $this->lexic_permissions['NUMBERS'] ) - { + if (!$this->use_classes && $this->lexic_permissions['NUMBERS']) { $attributes = ' style="' . $this->language_data['STYLES']['NUMBERS'][0] . '"'; - } - else - { + } else { $attributes = ' class="nu0"'; } $stuff_to_parse = str_replace('/NUM!/', $attributes, $stuff_to_parse); @@ -1892,18 +2021,12 @@ class GeSHi // // Highlight methods and fields in objects // - if ( $this->lexic_permissions['METHODS'] && $this->language_data['OOLANG'] ) - { - foreach ( $this->language_data['OBJECT_SPLITTERS'] as $key => $splitter ) - { - if ( false !== stristr($stuff_to_parse, $splitter) ) - { - if ( !$this->use_classes ) - { + if ($this->lexic_permissions['METHODS'] && $this->language_data['OOLANG']) { + foreach ($this->language_data['OBJECT_SPLITTERS'] as $key => $splitter) { + if (false !== stristr($stuff_to_parse, $splitter)) { + if (!$this->use_classes) { $attributes = ' style="' . $this->language_data['STYLES']['METHODS'][$key] . '"'; - } - else - { + } else { $attributes = ' class="me' . $key . '"'; } $stuff_to_parse = preg_replace("#(" . quotemeta($this->language_data['OBJECT_SPLITTERS'][$key]) . "[\s]*)([a-zA-Z\*\(][a-zA-Z0-9_\*]*)#", "\\1<|$attributes>\\2|>", $stuff_to_parse); @@ -1917,11 +2040,9 @@ class GeSHi // TODO: Fix lexic permissions not converting entities if shouldn't // be highlighting regardless // - if ( $this->lexic_permissions['BRACKETS'] ) - { + if ($this->lexic_permissions['BRACKETS']) { $code_entities_match = array('[', ']', '(', ')', '{', '}'); - if ( !$this->use_classes ) - { + if (!$this->use_classes) { $code_entities_replace = array( '<| style="' . $this->language_data['STYLES']['BRACKETS'][0] . '">[|>', '<| style="' . $this->language_data['STYLES']['BRACKETS'][0] . '">]|>', @@ -1930,9 +2051,7 @@ class GeSHi '<| style="' . $this->language_data['STYLES']['BRACKETS'][0] . '">{|>', '<| style="' . $this->language_data['STYLES']['BRACKETS'][0] . '">}|>', ); - } - else - { + } else { $code_entities_replace = array( '<| class="br0">[|>', '<| class="br0">]|>', @@ -1948,16 +2067,11 @@ class GeSHi // // Add class/style for regexps // - foreach ( $this->language_data['REGEXPS'] as $key => $regexp ) - { - if ( $this->lexic_permissions['REGEXPS'][$key] ) - { - if ( !$this->use_classes ) - { + foreach ($this->language_data['REGEXPS'] as $key => $regexp) { + if ($this->lexic_permissions['REGEXPS'][$key]) { + if (!$this->use_classes) { $attributes = ' style="' . $this->language_data['STYLES']['REGEXPS'][$key] . '"'; - } - else - { + } else { $attributes = ' class="re' . $key . '"'; } $stuff_to_parse = str_replace("!REG3XP$key!", "$attributes", $stuff_to_parse); @@ -1967,19 +2081,13 @@ class GeSHi // Replace <DOT> with . for urls $stuff_to_parse = str_replace('<DOT>', '.', $stuff_to_parse); // Replace <|UR1| with <a href= for urls also - if ( isset($this->link_styles[GESHI_LINK]) ) - { - if ( $this->use_classes ) - { + if (isset($this->link_styles[GESHI_LINK])) { + if ($this->use_classes) { $stuff_to_parse = str_replace('<|UR1|', '<a' . $this->link_target . ' href=', $stuff_to_parse); - } - else - { + } else { $stuff_to_parse = str_replace('<|UR1|', '<a' . $this->link_target . ' style="' . $this->link_styles[GESHI_LINK] . '" href=', $stuff_to_parse); } - } - else - { + } else { $stuff_to_parse = str_replace('<|UR1|', '<a' . $this->link_target . ' href=', $stuff_to_parse); } @@ -1994,11 +2102,14 @@ class GeSHi } /** - * method: set_time - * ---------------- * Sets the time taken to parse the code + * + * @param microtime The time when parsing started + * @param microtime The time when parsing ended + * @since 1.0.2 + * @access private */ - function set_time ( $start_time, $end_time ) + function set_time ($start_time, $end_time) { $start = explode(' ', $start_time); $end = explode(' ', $end_time); @@ -2006,9 +2117,10 @@ class GeSHi } /** - * method: get_time - * ---------------- * Gets the time taken to parse the code + * + * @return double The time taken to parse the code + * @since 1.0.2 */ function get_time () { @@ -2016,221 +2128,170 @@ class GeSHi } /** - * method: load_language - * --------------------- * Gets language information and stores it for later use + * + * @access private + * @todo Needs to load keys for lexic permissions for keywords, regexps etc */ - function load_language () + function load_language ($file_name) { - $file_name = $this->language_path . $this->language . '.php'; - if ( !is_readable($file_name)) - { - $this->error = GESHI_ERROR_NO_SUCH_LANG; - return; - } - require($file_name); + require $file_name; // Perhaps some checking might be added here later to check that // $language data is a valid thing but maybe not $this->language_data = $language_data; // Set strict mode if should be set - if ( $this->language_data['STRICT_MODE_APPLIES'] == GESHI_ALWAYS ) - { + if ($this->language_data['STRICT_MODE_APPLIES'] == GESHI_ALWAYS) { $this->strict_mode = true; } // Set permissions for all lexics to true // so they'll be highlighted by default + foreach ($this->language_data['KEYWORDS'] as $key => $words) { + $this->lexic_permissions['KEYWORDS'][$key] = true; + } + foreach ($this->language_data['COMMENT_SINGLE'] as $key => $comment) { + $this->lexic_permissions['COMMENTS'][$key] = true; + } + foreach ($this->language_data['REGEXPS'] as $key => $regexp) { + $this->lexic_permissions['REGEXPS'][$key] = true; + } $this->enable_highlighting(); // Set default class for CSS $this->overall_class = $this->language; } /** - * method: get_tab_replacement - * --------------------------- - * Gets the replacement string for tabs in the source code. Useful for - * HTML highlighting, where tabs don't mean anything to a browser. - */ - /* - function get_tab_replacement () - { - $i = 0; - $result = ''; - while ( $i < $this->tab_width ) - { - $i++; - if ( $i % 2 == 0 ) - { - $result .= ' '; - } - else - { - $result .= ' '; - } - } - return $result; - } - */ - - /** - * method: finalise - * ---------------- * Takes the parsed code and various options, and creates the HTML * surrounding it to make it look nice. - */ - function finalise ( $parsed_code ) - { - // Remove end parts of important declarations - // This is BUGGY!! My fault for bad code: fix coming in 1.2 - if ( $this->enable_important_blocks && (strstr($parsed_code, @htmlentities(GESHI_START_IMPORTANT, ENT_COMPAT, $this->encoding)) === false) ) - { - $parsed_code = str_replace(@htmlentities(GESHI_END_IMPORTANT, ENT_COMPAT, $this->encoding), '', $parsed_code); - } - - // Add HTML whitespace stuff if we're using the <div> header - if ( $this->header_type == GESHI_HEADER_DIV ) - { - $parsed_code = $this->indent($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 ) - { - // If we're using the <pre> header, we shouldn't add newlines because - // the <pre> will line-break them (and the <li>s already do this for us) - $ls = ( $this->header_type != GESHI_HEADER_PRE ) ? "\n" : ''; - // Get code into lines - $code = explode("\n", $parsed_code); - // Set vars to defaults for following loop - $parsed_code = ''; - $i = 0; - // Foreach line... - foreach ( $code as $line ) - { - $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) ) - { - // Set the attributes to style the line - if ( $this->use_classes ) - { - $attr = ' class="li2"'; - $def_attr = ' class="de2"'; - } - else - { - $attr = ' style="' . $this->line_style2 . '"'; - // This style "covers up" the special styles set for special lines - // so that styles applied to special lines don't apply to the actual - // code on that line - $def_attr = ' style="' . $this->code_style . '"'; - } - // Span or div? - $start = "<div$def_attr>"; - $end = '</div>'; - } - else - { - if ( $this->use_classes ) - { - $def_attr = ' class="de1"'; - } - else - { - $def_attr = ' style="' . $this->code_style . '"'; - } - // Reset everything - $attr = ''; - // Span or div? - $start = "<div$def_attr>"; - $end = '</div>'; - } - - ++$i; - // Are we supposed to use ids? If so, add them - if ( $this->add_ids ) - { - $attr .= " id=\"{$this->overall_id}-{$i}\""; - } - if ( $this->use_classes && in_array($i, $this->highlight_extra_lines) ) - { - $attr .= " class=\"ln-xtra\""; - } - if ( !$this->use_classes && in_array($i, $this->highlight_extra_lines) ) - { - $attr .= " style=\"{$this->highlight_extra_lines_style}\""; - } - - // Add in the line surrounded by appropriate list HTML - $parsed_code .= "<li$attr>$start$line$end</li>$ls"; - } - } - else - { - // No line numbers, but still need to handle highlighting lines extra. - // Have to use divs so the full width of the code is highlighted - $code = explode("\n", $parsed_code); - $parsed_code = ''; - $i = 0; - foreach ( $code as $line ) - { - // Make lines have at least one space in them if they're empty - $line = ( $line ) ? $line : ' '; - if ( in_array(++$i, $this->highlight_extra_lines) ) - { - if ( $this->use_classes ) - { - //$id = ( $this->overall_id != '' ) ? $this->overall_id . "-$i" : $this->overall_class . "-$i"; - $parsed_code .= '<div class="ln-xtra">'; - } - else - { - $parsed_code .= "<div style=\"{$this->highlight_extra_lines_style}\">"; - } - $parsed_code .= $line . "</div>\n"; - } - else - { - $parsed_code .= $line . "\n"; - } - } - } - - // 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); - } - - return $this->header() . chop($parsed_code) . $this->footer(); - } - + * + * @param string The code already parsed + * @return string The code nicely finalised + * @since 1.0.0 + * @access private + */ + function finalise ($parsed_code) + { + // Remove end parts of important declarations + // This is BUGGY!! My fault for bad code: fix coming in 1.2 + // @todo Remove this crap + if ($this->enable_important_blocks && + (strstr($parsed_code, @htmlspecialchars(GESHI_START_IMPORTANT, ENT_COMPAT, $this->encoding)) === false)) { + $parsed_code = str_replace(@htmlspecialchars(GESHI_END_IMPORTANT, ENT_COMPAT, $this->encoding), '', $parsed_code); + } + + // Add HTML whitespace stuff if we're using the <div> header + if ($this->header_type == GESHI_HEADER_DIV) { + $parsed_code = $this->indent($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) { + // If we're using the <pre> header, we shouldn't add newlines because + // the <pre> will line-break them (and the <li>s already do this for us) + $ls = ($this->header_type != GESHI_HEADER_PRE) ? "\n" : ''; + // Get code into lines + $code = explode("\n", $parsed_code); + // Set vars to defaults for following loop + $parsed_code = ''; + $i = 0; + // Foreach line... + foreach ($code as $line) { + $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)) { + // Set the attributes to style the line + if ($this->use_classes) { + $attr = ' class="li2"'; + $def_attr = ' class="de2"'; + } else { + $attr = ' style="' . $this->line_style2 . '"'; + // This style "covers up" the special styles set for special lines + // so that styles applied to special lines don't apply to the actual + // code on that line + $def_attr = ' style="' . $this->code_style . '"'; + } + // Span or div? + $start = "<div$def_attr>"; + $end = '</div>'; + } else { + if ($this->use_classes) { + $def_attr = ' class="de1"'; + } else { + $def_attr = ' style="' . $this->code_style . '"'; + } + // Reset everything + $attr = ''; + // Span or div? + $start = "<div$def_attr>"; + $end = '</div>'; + } + + ++$i; + // Are we supposed to use ids? If so, add them + if ($this->add_ids) { + $attr .= " id=\"{$this->overall_id}-{$i}\""; + } + if ($this->use_classes && in_array($i, $this->highlight_extra_lines)) { + $attr .= " class=\"ln-xtra\""; + } + if (!$this->use_classes && in_array($i, $this->highlight_extra_lines)) { + $attr .= " style=\"{$this->highlight_extra_lines_style}\""; + } + + // Add in the line surrounded by appropriate list HTML + $parsed_code .= "<li$attr>$start$line$end</li>$ls"; + } + } else { + // No line numbers, but still need to handle highlighting lines extra. + // Have to use divs so the full width of the code is highlighted + $code = explode("\n", $parsed_code); + $parsed_code = ''; + $i = 0; + foreach ($code as $line) + { + // Make lines have at least one space in them if they're empty + $line = ($line) ? $line : ' '; + if (in_array(++$i, $this->highlight_extra_lines)) { + if ($this->use_classes) { + $parsed_code .= '<div class="ln-xtra">'; + } else { + $parsed_code .= "<div style=\"{$this->highlight_extra_lines_style}\">"; + } + $parsed_code .= $line . "</div>\n"; + } else { + $parsed_code .= $line . "\n"; + } + } + } + + // 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); + } + + return $this->header() . chop($parsed_code) . $this->footer(); + } /** - * method: header - * -------------- * Creates the header for the code block (with correct attributes) + * + * @return string The header for the code block + * @since 1.0.0 + * @access private */ function header () { // Get attributes needed $attributes = $this->get_attributes(); - /*if ( $this->use_classes ) - {*/ - $ol_attributes = ''; - /*} - else - { - //$ol_attributes = ' style="margin: 0;"'; - }*/ + $ol_attributes = ''; - if ( $this->line_numbers_start != 1 ) - { + if ($this->line_numbers_start != 1) { $ol_attributes .= ' start="' . $this->line_numbers_start . '"'; } @@ -2238,124 +2299,105 @@ class GeSHi $header = $this->format_header_content(); // Work out what to return and do it - if ( $this->line_numbers != GESHI_NO_LINE_NUMBERS ) - { - if ( $this->header_type == GESHI_HEADER_PRE ) - { + if ($this->line_numbers != GESHI_NO_LINE_NUMBERS) { + if ($this->header_type == GESHI_HEADER_PRE) { return "<pre$attributes>$header<ol$ol_attributes>"; - } - elseif ( $this->header_type == GESHI_HEADER_DIV ) - { + } elseif ($this->header_type == GESHI_HEADER_DIV) { return "<div$attributes>$header<ol$ol_attributes>"; } - } - else - { - if ( $this->header_type == GESHI_HEADER_PRE ) - { + } else { + if ($this->header_type == GESHI_HEADER_PRE) { return "<pre$attributes>$header"; - } - elseif ( $this->header_type == GESHI_HEADER_DIV ) - { + } elseif ($this->header_type == GESHI_HEADER_DIV) { return "<div$attributes>$header"; } } } - /** - * method: format_header_content - * ----------------------------- * Returns the header content, formatted for output + * + * @return string The header content, formatted for output + * @since 1.0.2 + * @access private */ function format_header_content () { $header = $this->header_content; - if ( $header ) - { - if ( $this->header_type == GESHI_HEADER_PRE ) - { + if ($header) { + if ($this->header_type == GESHI_HEADER_PRE) { $header = str_replace("\n", '', $header); } $header = $this->replace_keywords($header); - if ( $this->use_classes ) - { + if ($this->use_classes) { $attr = ' class="head"'; - } - else - { + } else { $attr = " style=\"{$this->header_content_style}\""; } return "<div$attr>$header</div>"; } } - /** - * method: footer - * -------------- - * Returns the footer for the code block. Ending newline removed in 1.0.2 + * Returns the footer for the code block. + * + * @return string The footer for the code block + * @since 1.0.0 + * @access private */ function footer () { $footer_content = $this->format_footer_content(); - if ( $this->header_type == GESHI_HEADER_DIV ) - { - if ( $this->line_numbers != GESHI_NO_LINE_NUMBERS ) - { + if ($this->header_type == GESHI_HEADER_DIV) { + if ($this->line_numbers != GESHI_NO_LINE_NUMBERS) { return "</ol>$footer_content</div>"; } return "$footer_content</div>"; - } - else - { - if ( $this->line_numbers != GESHI_NO_LINE_NUMBERS ) - { + } else { + if ($this->line_numbers != GESHI_NO_LINE_NUMBERS) { return "</ol>$footer_content</pre>"; } return "$footer_content</pre>"; } } - /** - * method: format_footer_content - * ----------------------------- * Returns the footer content, formatted for output + * + * @return string The footer content, formatted for output + * @since 1.0.2 + * @access private */ function format_footer_content () { $footer = $this->footer_content; - if ( $footer ) - { - if ( $this->header_type == GESHI_HEADER_PRE ) - { + if ($footer) { + if ($this->header_type == GESHI_HEADER_PRE) { $footer = str_replace("\n", '', $footer);; } $footer = $this->replace_keywords($footer); - if ( $this->use_classes ) - { + if ($this->use_classes) { $attr = ' class="foot"'; - } - else - { + } else { $attr = " style=\"{$this->footer_content_style}\">"; } return "<div$attr>$footer</div>"; } } - /** - * method: replace_keywords - * ---------------------- * Replaces certain keywords in the header and footer with * certain configuration values + * + * @param string The header or footer content to do replacement on + * @return string The header or footer with replaced keywords + * @since 1.0.2 + * @access private */ - function replace_keywords ( $instr ) + function replace_keywords ($instr) { $keywords = $replacements = array(); @@ -2366,65 +2408,63 @@ class GeSHi $replacements[] = $this->language; $keywords[] = '<VERSION>'; - $replacements[] = '1.0.6'; + $replacements[] = GESHI_VERSION; return str_replace($keywords, $replacements, $instr); } /** - * method: get_attributes - * ---------------------- * Gets the CSS attributes for this code + * + * @return The CSS attributes for this code + * @since 1.0.0 + * @access private + * @todo Document behaviour change - class is outputted regardless of whether we're using classes or not. + * Same with style */ function get_attributes () { $attributes = ''; - if ( $this->overall_class != '' && $this->use_classes ) - { + if ($this->overall_class != '') { $attributes .= " class=\"{$this->overall_class}\""; } - if ( $this->overall_id != '' ) - { + if ($this->overall_id != '') { $attributes .= " id=\"{$this->overall_id}\""; } - if ( $this->overall_style != '' && !$this->use_classes ) - { + if ($this->overall_style != '') { $attributes .= ' style="' . $this->overall_style . '"'; } return $attributes; } - /** - * method: get_stylesheet - * ---------------------- * Returns a stylesheet for the highlighted code. If $economy mode * is true, we only return the stylesheet declarations that matter for * this code block instead of the whole thing + * + * @param boolean Whether to use economy mode or not + * @return string A stylesheet built on the data for the current language + * @since 1.0.0 */ - function get_stylesheet ( $economy_mode = true ) + function get_stylesheet ($economy_mode = true) { // If there's an error, chances are that the language file // won't have populated the language data file, so we can't // risk getting a stylesheet... - if ( $this->error ) - { + if ($this->error) { return ''; } // First, work out what the selector should be. If there's an ID, // that should be used, the same for a class. Otherwise, a selector // of '' means that these styles will be applied anywhere - $selector = ( $this->overall_id != '' ) ? "#{$this->overall_id} " : ''; - $selector = ( $selector == '' && $this->overall_class != '' ) ? ".{$this->overall_class} " : $selector; + $selector = ($this->overall_id != '') ? "#{$this->overall_id} " : ''; + $selector = ($selector == '' && $this->overall_class != '') ? ".{$this->overall_class} " : $selector; // Header of the stylesheet - if ( !$economy_mode ) - { + if (!$economy_mode) { $stylesheet = "/**\n * GeSHi Dynamically Generated Stylesheet\n * --------------------------------------\n * Dynamically generated stylesheet for {$this->language}\n * CSS class: {$this->overall_class}, CSS id: {$this->overall_id}\n * GeSHi (c) Nigel McNie 2004 (http://qbnz.com/highlighter)\n */\n"; - } - else - { + } else { $stylesheet = '/* GeSHi (c) Nigel McNie 2004 (http://qbnz.com/highlighter) */' . "\n"; } @@ -2432,141 +2472,109 @@ class GeSHi // (<ol>s have margins that should be destroyed so all layout is // controlled by the set_overall_style method, which works on the // <pre> or <div> container). Additionally, set default styles for lines - if ( !$economy_mode || $this->line_numbers != GESHI_NO_LINE_NUMBERS ) - { + if (!$economy_mode || $this->line_numbers != GESHI_NO_LINE_NUMBERS) { //$stylesheet .= "$selector, {$selector}ol, {$selector}ol li {margin: 0;}\n"; $stylesheet .= "$selector.de1, $selector.de2 {{$this->code_style}}\n"; } // Add overall styles - if ( !$economy_mode || $this->overall_style != '' ) - { + if (!$economy_mode || $this->overall_style != '') { $stylesheet .= "$selector {{$this->overall_style}}\n"; } // Add styles for links - foreach ( $this->link_styles as $key => $style ) - { - if ( !$economy_mode || $key == GESHI_LINK && $style != '' ) - { + foreach ($this->link_styles as $key => $style) { + if (!$economy_mode || $key == GESHI_LINK && $style != '') { $stylesheet .= "{$selector}a:link {{$style}}\n"; } - if ( !$economy_mode || $key == GESHI_HOVER && $style != '' ) - { + if (!$economy_mode || $key == GESHI_HOVER && $style != '') { $stylesheet .= "{$selector}a:hover {{$style}}\n"; } - if ( !$economy_mode || $key == GESHI_ACTIVE && $style != '' ) - { + if (!$economy_mode || $key == GESHI_ACTIVE && $style != '') { $stylesheet .= "{$selector}a:active {{$style}}\n"; } - if ( !$economy_mode || $key == GESHI_VISITED && $style != '' ) - { + if (!$economy_mode || $key == GESHI_VISITED && $style != '') { $stylesheet .= "{$selector}a:visited {{$style}}\n"; } } // Header and footer - if ( !$economy_mode || $this->header_content_style != '' ) - { + if (!$economy_mode || $this->header_content_style != '') { $stylesheet .= "$selector.head {{$this->header_content_style}}\n"; } - if ( !$economy_mode || $this->footer_content_style != '' ) - { + if (!$economy_mode || $this->footer_content_style != '') { $stylesheet .= "$selector.foot {{$this->footer_content_style}}\n"; } // Styles for important stuff - if ( !$economy_mode || $this->important_styles != '' ) - { + if (!$economy_mode || $this->important_styles != '') { $stylesheet .= "$selector.imp {{$this->important_styles}}\n"; } - // Styles for lines being highlighted extra - if ( !$economy_mode || count($this->highlight_extra_lines) ) - { - /*foreach ( $this->highlight_extra_lines as $line ) - { - $id = ( $this->overall_id != '' ) ? $this->overall_id . "-$line" : $this->overall_class . "-$line"; - $stylesheet .= "$selector#$id,"; - }*/ + if (!$economy_mode || count($this->highlight_extra_lines)) { $stylesheet .= "$selector.ln-xtra {{$this->highlight_extra_lines_style}}\n"; } - // Simple line number styles - if ( !$economy_mode || ($this->line_numbers != GESHI_NO_LINE_NUMBERS && $this->line_style1 != '') ) - { + if (!$economy_mode || ($this->line_numbers != GESHI_NO_LINE_NUMBERS && $this->line_style1 != '')) { $stylesheet .= "{$selector}li {{$this->line_style1}}\n"; } // If there is a style set for fancy line numbers, echo it out - if ( !$economy_mode || ($this->line_numbers == GESHI_FANCY_LINE_NUMBERS && $this->line_style2 != '') ) - { + if (!$economy_mode || ($this->line_numbers == GESHI_FANCY_LINE_NUMBERS && $this->line_style2 != '')) { $stylesheet .= "{$selector}li.li2 {{$this->line_style2}}\n"; } - - foreach ( $this->language_data['STYLES']['KEYWORDS'] as $group => $styles ) - { - if ( !$economy_mode || !($economy_mode && (!$this->lexic_permissions['KEYWORDS'][$group] || $styles == '')) ) - { + foreach ($this->language_data['STYLES']['KEYWORDS'] as $group => $styles) { + if (!$economy_mode || !($economy_mode && (!$this->lexic_permissions['KEYWORDS'][$group] || $styles == ''))) { $stylesheet .= "$selector.kw$group {{$styles}}\n"; } } - foreach ( $this->language_data['STYLES']['COMMENTS'] as $group => $styles ) - { - if ( !$economy_mode || !($economy_mode && $styles == '') && !($economy_mode && !$this->lexic_permissions['COMMENTS'][$group]) ) - { + foreach ($this->language_data['STYLES']['COMMENTS'] as $group => $styles) { + if (!$economy_mode || !($economy_mode && $styles == '') && + !($economy_mode && !$this->lexic_permissions['COMMENTS'][$group])) { $stylesheet .= "$selector.co$group {{$styles}}\n"; } } - foreach ( $this->language_data['STYLES']['ESCAPE_CHAR'] as $group => $styles ) - { - if ( !$economy_mode || !($economy_mode && $styles == '') && !($economy_mode && !$this->lexic_permissions['ESCAPE_CHAR']) ) - { + foreach ($this->language_data['STYLES']['ESCAPE_CHAR'] as $group => $styles) { + if (!$economy_mode || !($economy_mode && $styles == '') && !($economy_mode && + !$this->lexic_permissions['ESCAPE_CHAR'])) { $stylesheet .= "$selector.es$group {{$styles}}\n"; } } - foreach ( $this->language_data['STYLES']['SYMBOLS'] as $group => $styles ) - { - if ( !$economy_mode || !($economy_mode && $styles == '') && !($economy_mode && !$this->lexic_permissions['BRACKETS']) ) - { + foreach ($this->language_data['STYLES']['SYMBOLS'] as $group => $styles) { + if (!$economy_mode || !($economy_mode && $styles == '') && !($economy_mode && + !$this->lexic_permissions['BRACKETS'])) { $stylesheet .= "$selector.br$group {{$styles}}\n"; } } - foreach ( $this->language_data['STYLES']['STRINGS'] as $group => $styles ) - { - if ( !$economy_mode || !($economy_mode && $styles == '') && !($economy_mode && !$this->lexic_permissions['STRINGS']) ) - { + foreach ($this->language_data['STYLES']['STRINGS'] as $group => $styles) { + if (!$economy_mode || !($economy_mode && $styles == '') && !($economy_mode && + !$this->lexic_permissions['STRINGS'])) { $stylesheet .= "$selector.st$group {{$styles}}\n"; } } - foreach ( $this->language_data['STYLES']['NUMBERS'] as $group => $styles ) - { - if ( !$economy_mode || !($economy_mode && $styles == '') && !($economy_mode && !$this->lexic_permissions['NUMBERS']) ) - { + foreach ($this->language_data['STYLES']['NUMBERS'] as $group => $styles) { + if (!$economy_mode || !($economy_mode && $styles == '') && !($economy_mode && + !$this->lexic_permissions['NUMBERS'])) { $stylesheet .= "$selector.nu$group {{$styles}}\n"; } } - foreach ( $this->language_data['STYLES']['METHODS'] as $group => $styles ) - { - if ( !$economy_mode || !($economy_mode && $styles == '') && !($economy_mode && !$this->lexic_permissions['METHODS']) ) - { + foreach ($this->language_data['STYLES']['METHODS'] as $group => $styles) { + if (!$economy_mode || !($economy_mode && $styles == '') && !($economy_mode && + !$this->lexic_permissions['METHODS'])) { $stylesheet .= "$selector.me$group {{$styles}}\n"; } } - foreach ( $this->language_data['STYLES']['SCRIPT'] as $group => $styles ) - { - if ( !$economy_mode || !($economy_mode && $styles == '') /*&& !($economy_mode && !$this->lexic_permissions['SCRIPT'])*/ ) - { + foreach ($this->language_data['STYLES']['SCRIPT'] as $group => $styles) { + if (!$economy_mode || !($economy_mode && $styles == '')) { $stylesheet .= "$selector.sc$group {{$styles}}\n"; } } - foreach ( $this->language_data['STYLES']['REGEXPS'] as $group => $styles ) - { - if ( !$economy_mode || !($economy_mode && $styles == '') && !($economy_mode && !$this->lexic_permissions['REGEXPS'][$group]) ) - { + foreach ($this->language_data['STYLES']['REGEXPS'] as $group => $styles) { + if (!$economy_mode || !($economy_mode && $styles == '') && !($economy_mode && + !$this->lexic_permissions['REGEXPS'][$group])) { $stylesheet .= "$selector.re$group {{$styles}}\n"; } } @@ -2577,24 +2585,27 @@ class GeSHi } // End Class GeSHi -if ( !function_exists('geshi_highlight') ) -{ +if (!function_exists('geshi_highlight')) { /** - * function: geshi_highlight - * ------------------------- - * Easy way to highlight stuff. Behaves just like highlight_string - */ - function geshi_highlight ( $string, $language, $path, $return = false ) + * Easy way to highlight stuff. Behaves just like highlight_string + * + * @param string The code to highlight + * @param string The language to highlight the code in + * @param string The path to the language files. You can leave this blank if you need + * as from version 1.0.7 the path should be automatically detected + * @param boolean Whether to return the result or to echo + * @return string The code highlighted (if $return is true) + * @since 1.0.2 + */ + function geshi_highlight ($string, $language, $path, $return = false) { $geshi = new GeSHi($string, $language, $path); $geshi->set_header_type(GESHI_HEADER_DIV); - if ( $return ) - { + if ($return) { return str_replace('<div>', '<code>', str_replace('</div>', '</code>', $geshi->parse_code())); } echo str_replace('<div>', '<code>', str_replace('</div>', '</code>', $geshi->parse_code())); - if ( $geshi->error() ) - { + if ($geshi->error()) { return false; } return true; diff --git a/inc/geshi/actionscript.php b/inc/geshi/actionscript.php index f04e2a1a6..8373c2abf 100644 --- a/inc/geshi/actionscript.php +++ b/inc/geshi/actionscript.php @@ -7,7 +7,7 @@ * Release Version: 1.0.6 * CVS Revision Version: $Revision: 1.1 $ * Date Started: 2004/06/20 - * Last Modified: $Date: 2005/01/29 01:48:39 $ + * Last Modified: $Date: 2005/06/02 04:57:18 $ * * Actionscript language file for GeSHi. * diff --git a/inc/geshi/ada.php b/inc/geshi/ada.php index 7ce4f52ee..848b3b1bf 100644 --- a/inc/geshi/ada.php +++ b/inc/geshi/ada.php @@ -5,9 +5,9 @@ * Author: Tux (tux@inmail.cz) * Copyright: (c) 2004 Tux (http://tux.a4.cz/), Nigel McNie (http://qbnz.com/highlighter) * Release Version: 1.0.6 - * CVS Revision Version: $Revision: 1.1 $ + * CVS Revision Version: $Revision: 1.2 $ * Date Started: 2004/07/29 - * Last Modified: $Date: 2005/01/29 01:48:39 $ + * Last Modified: $Date: 2005/06/13 22:27:06 $ * * Ada language file for GeSHi. * Words are from SciTe configuration file @@ -133,4 +133,3 @@ $language_data = array ( ); ?> - diff --git a/inc/geshi/apache.php b/inc/geshi/apache.php index 78e5f76ce..893090965 100644 --- a/inc/geshi/apache.php +++ b/inc/geshi/apache.php @@ -5,9 +5,9 @@ * Author: Tux (tux@inmail.cz) * Copyright: (c) 2004 Tux (http://tux.a4.cz/), Nigel McNie (http://qbnz.com/highlighter) * Release Version: 1.0.6 - * CVS Revision Version: $Revision: 1.1 $ + * CVS Revision Version: $Revision: 1.2 $ * Date Started: 2004/29/07 - * Last Modified: $Date: 2005/01/29 01:48:39 $ + * Last Modified: $Date: 2005/06/13 22:27:06 $ * * Apache language file for GeSHi. * Words are from SciTe configuration file @@ -171,4 +171,3 @@ $language_data = array ( ); ?> - diff --git a/inc/geshi/asm.php b/inc/geshi/asm.php index d2836c18e..9cbf59ef8 100644 --- a/inc/geshi/asm.php +++ b/inc/geshi/asm.php @@ -7,7 +7,7 @@ * Release Version: 1.0.6 * CVS Revision Version: $Revision: 1.1 $ * Date Started: 2004/07/27 - * Last Modified: $Date: 2005/01/29 01:48:39 $ + * Last Modified: $Date: 2005/06/02 04:57:18 $ * * x86 Assembler language file for GeSHi. * Words are from SciTe configuration file (based on NASM syntax) diff --git a/inc/geshi/asp.php b/inc/geshi/asp.php index e4d3884e1..5135d4771 100644 --- a/inc/geshi/asp.php +++ b/inc/geshi/asp.php @@ -7,7 +7,7 @@ * Release Version: 1.0.6 * CVS Revision Version: $Revision: 1.1 $
* Date Started: 2004/08/13
- * Last Modified: $Date: 2005/01/29 01:48:39 $
+ * Last Modified: $Date: 2005/06/02 04:57:18 $
*
* ASP language file for GeSHi.
*
diff --git a/inc/geshi/bash.php b/inc/geshi/bash.php index 65631998a..3cfa98559 100644 --- a/inc/geshi/bash.php +++ b/inc/geshi/bash.php @@ -7,7 +7,7 @@ * Release Version: 1.0.6 * CVS Revision Version: $Revision: 1.1 $ * Date Started: 2004/08/20 - * Last Modified: $Date: 2005/01/29 01:48:39 $ + * Last Modified: $Date: 2005/06/02 04:57:18 $ * * BASH language file for GeSHi. * diff --git a/inc/geshi/c.php b/inc/geshi/c.php index 896a588c2..d2fb41e35 100644 --- a/inc/geshi/c.php +++ b/inc/geshi/c.php @@ -9,7 +9,7 @@ * Release Version: 1.0.6 * CVS Revision Version: $Revision: 1.1 $ * Date Started: 2004/06/04 - * Last Modified: $Date: 2005/01/29 01:48:39 $ + * Last Modified: $Date: 2005/06/02 04:57:18 $ * * C language file for GeSHi. * diff --git a/inc/geshi/c_mac.php b/inc/geshi/c_mac.php index 2527cbf8e..d65cb9e70 100644 --- a/inc/geshi/c_mac.php +++ b/inc/geshi/c_mac.php @@ -7,7 +7,7 @@ * Release Version: 1.0.6 * CVS Revision Version: $Revision: 1.1 $ * Date Started: 2004/06/04 - * Last Modified: $Date: 2005/01/29 01:48:39 $ + * Last Modified: $Date: 2005/06/02 04:57:18 $ * * C for Macs language file for GeSHi. * diff --git a/inc/geshi/caddcl.php b/inc/geshi/caddcl.php index 84deade8b..9eb542db5 100644 --- a/inc/geshi/caddcl.php +++ b/inc/geshi/caddcl.php @@ -7,7 +7,7 @@ * Release Version: 1.0.6 * CVS Revision Version: $Revision: 1.1 $ * Date Started: 2004/08/30 - * Last Modified: $Date: 2005/01/29 01:48:39 $ + * Last Modified: $Date: 2005/06/02 04:57:18 $ * * CAD DCL (Dialog Control Language) file for GeSHi. * diff --git a/inc/geshi/cadlisp.php b/inc/geshi/cadlisp.php index dfeb57db3..16b56c067 100644 --- a/inc/geshi/cadlisp.php +++ b/inc/geshi/cadlisp.php @@ -7,7 +7,7 @@ * Release Version: 1.0.6 * CVS Revision Version: $Revision: 1.1 $ * Date Started: 2004/08/30 - * Last Modified: $Date: 2005/01/29 01:48:39 $ + * Last Modified: $Date: 2005/06/02 04:57:18 $ * * AutoCAD/IntelliCAD Lisp language file for GeSHi. * diff --git a/inc/geshi/cpp.php b/inc/geshi/cpp.php index fd8a3d6ca..0e2d10ed2 100644 --- a/inc/geshi/cpp.php +++ b/inc/geshi/cpp.php @@ -8,9 +8,9 @@ * - Jack Lloyd (lloyd@randombit.net)
* Copyright: (c) 2004 Dennis Bayer, Nigel McNie (http://qbnz.com/highlighter)
* Release Version: 1.0.6 - * CVS Revision Version: $Revision: 1.1 $
+ * CVS Revision Version: $Revision: 1.2 $
* Date Started: 2004/09/27
- * Last Modified: $Date: 2005/01/29 01:48:39 $
+ * Last Modified: $Date: 2005/06/13 22:27:06 $
*
* C++ language file for GeSHi.
*
@@ -170,5 +170,3 @@ $language_data = array ( );
?>
-
-
diff --git a/inc/geshi/csharp.php b/inc/geshi/csharp.php index efb4e6a74..981f04488 100644 --- a/inc/geshi/csharp.php +++ b/inc/geshi/csharp.php @@ -7,7 +7,7 @@ * Release Version: 1.0.6 * CVS Revision Version: $Revision: 1.1 $
* Date Started: 2004/06/04
- * Last Modified: $Date: 2005/01/29 01:48:39 $
+ * Last Modified: $Date: 2005/06/02 04:57:18 $
*
* C# language file for GeSHi.
*
diff --git a/inc/geshi/css.php b/inc/geshi/css.php index cea30cdd2..03f6c1409 100644 --- a/inc/geshi/css.php +++ b/inc/geshi/css.php @@ -5,9 +5,9 @@ * Author: Nigel McNie (oracle.shinoda@gmail.com) * Copyright: (c) 2004 Nigel McNie (http://qbnz.com/highlighter/) * Release Version: 1.0.6 - * CVS Revision Version: $Revision: 1.1 $ + * CVS Revision Version: $Revision: 1.2 $ * Date Started: 2004/06/18 - * Last Modified: $Date: 2005/01/29 01:48:39 $ + * Last Modified: $Date: 2005/06/13 22:27:48 $ * * CSS language file for GeSHi. * @@ -67,7 +67,7 @@ $language_data = array ( 'border-right-style', 'border-right-width', 'border-top-color', 'border-top-style', 'border-top-width','border-bottom', 'border-collapse', 'border-left', 'border-width', 'border-color', 'border-spacing', - 'border-style', 'border-top', 'border', 'bottom', 'caption-side', + 'border-style', 'border-top', 'border', 'caption-side', 'clear', 'clip', 'color', 'content', 'counter-increment', 'counter-reset', 'cue-after', 'cue-before', 'cue', 'cursor', 'direction', 'display', 'elevation', 'empty-cells', 'float', 'font-family', 'font-size', @@ -85,12 +85,13 @@ $language_data = array ( 'speak', 'speech-rate', 'stress', 'table-layout', 'text-align', 'text-decoration', 'text-indent', 'text-shadow', 'text-transform', 'top', 'unicode-bidi', 'vertical-align', 'visibility', 'voice-family', 'volume', 'white-space', 'widows', - 'width', 'word-spacing', 'z-index' + 'width', 'word-spacing', 'z-index', 'bottom' ), 2 => array( 'above', 'absolute', 'always', 'armenian', 'aural', 'auto', 'avoid', 'baseline', 'behind', 'below', 'bidi-override', 'blink', 'block', 'bold', 'bolder', 'both', - 'capitalize', 'center-left', 'center-right', 'center', 'circle', 'cjk-ideographic', 'close-quote', 'collapse', 'condensed', 'continuous', 'crop', 'crosshair', 'cross', 'cursive', + 'capitalize', 'center-left', 'center-right', 'center', 'circle', 'cjk-ideographic', + 'close-quote', 'collapse', 'condensed', 'continuous', 'crop', 'crosshair', 'cross', 'cursive', 'dashed', 'decimal-leading-zero', 'decimal', 'default', 'digits', 'disc', 'dotted', 'double', 'e-resize', 'embed', 'extra-condensed', 'extra-expanded', 'expanded', 'fantasy', 'far-left', 'far-right', 'faster', 'fast', 'fixed', 'fuchsia', diff --git a/inc/geshi/d.php b/inc/geshi/d.php new file mode 100644 index 000000000..d69515531 --- /dev/null +++ b/inc/geshi/d.php @@ -0,0 +1,287 @@ +<?php +/************************************************************************************* + * d.php + * ----- + * Author: Thomas Kuehne (thomas@kuehne.cn) + * Copyright: (c) 2005 Thomas Kuehne (http://thomas.kuehne.cn/) + * Release Version: 1.0.0 + * CVS Revision Version: $Revision: 1.1 $ + * Date Started: 2005/04/22 + * Last Modified: $Date: 2005/06/15 12:06:28 $ + * + * D language file for GeSHi. + * + * CHANGES + * ------- + * 2005/04/22 (0.0.2) + * - added _d_* and sizeof/ptrdiff_t + * 2005/04/20 (0.0.1) + * - First release + * + * TODO (updated 2005/04/22) + * ------------------------- + * * nested comments + * * correct handling of r"" and `` + * * correct handling of ... and .. + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ + +$language_data = array ( + 'LANG_NAME' => 'D', + 'COMMENT_SINGLE' => array(1 => '//'), + 'COMMENT_MULTI' => array('/*' => '*/'), + 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, + 'QUOTEMARKS' => array('"', "'", '`'), + 'ESCAPE_CHAR' => '\\', + 'KEYWORDS' => array( + 1 => array( + 'while', + 'switch', + 'if', + 'foreach', + 'for', + 'goto', + 'return', + 'else', + 'do', + 'case', + 'continue', + 'break' + ), + 2 => array( + 'with', + 'union', + 'typeof', + 'typeid', + 'typedef', + 'try', + 'true', + 'throw', + 'this', + 'super', + 'pragma', + 'out', + 'null', + 'new', + 'module', + 'mixin', + 'is', + 'invariant', + 'interface', + 'inout', + 'in', + 'import', + 'function', + 'finally', + 'false', + 'extern', + 'delete', + 'delegate', + 'default', + 'catch', + 'cast', + 'body', + 'assert', + 'asm', + 'alias' + ), + 3 => array( + 'TypeInfo', + 'SwitchError', + 'OutOfMemoryException', + 'Object', + 'ModuleInfo', + 'Interface', + 'Exception', + 'Error', + 'ClassInfo', + 'ArrayBoundsError', + 'AssertError', + '_d_throw', + '_d_switch_ustring', + '_d_switch_string', + '_d_switch_dstring', + '_d_OutOfMemory', + '_d_obj_eq', + '_d_obj_cmp', + '_d_newclass', + '_d_newbitarray', + '_d_newarrayi', + '_d_new', + '_d_monitorrelease', + '_d_monitor_prolog', + '_d_monitor_handler', + '_d_monitorexit', + '_d_monitor_epilog', + '_d_monitorenter', + '_d_local_unwind', + '_d_isbaseof2', + '_d_isbaseof', + '_d_invariant', + '_d_interface_vtbl', + '_d_interface_cast', + '_d_framehandler', + '_d_exception_filter', + '_d_exception', + '_d_dynamic_cast', + '_d_delmemory', + '_d_delinterface', + '_d_delclass', + '_d_delarray', + '_d_criticalexit', + '_d_criticalenter', + '_d_create_exception_object', + '_d_callfinalizer', + '_d_arraysetlengthb', + '_d_arraysetlength', + '_d_arraysetbit2', + '_d_arraysetbit', + '_d_arraycopybit', + '_d_arraycopy', + '_d_arraycatn', + '_d_arraycatb', + '_d_arraycat', + '_d_arraycast_frombit', + '_d_arraycast', + '_d_arrayappendcb', + '_d_arrayappendc', + '_d_arrayappendb', + '_d_arrayappend', + ), + 4 => array( + 'wchar', + 'volatile', + 'void', + 'version', + 'ushort', + 'unittest', + 'ulong', + 'uint', + 'ucent', + 'ubyte', + 'template', + 'struct', + 'static', + 'synchronized', + 'size_t', + 'short', + 'real', + 'public', + 'protected', + 'private', + 'ptrdiff_t', + 'package', + 'override', + 'long', + 'int', + 'ireal', + 'ifloat', + 'idouble', + 'float', + 'final', + 'export', + 'enum', + 'double', + 'deprecated', + 'debug', + 'dchar', + 'creal', + 'const', + 'class', + 'char', + 'cfloat', + 'cent', + 'cdouble', + 'byte', + 'bool', + 'bit', + 'auto', + 'align', + 'abstract' + ) + ), + 'SYMBOLS' => array( + '(', ')', '[', ']', '{', '}', '?', '!', ';', ':', ',', '...', '..', + '+', '-', '*', '/', '%', '&', '|', '^', '<', '>', '=', '~', + ), + 'CASE_SENSITIVE' => array( + GESHI_COMMENTS => true, + 1 => true, + 2 => true, + 3 => true, + 4 => true + ), + 'STYLES' => array( + 'KEYWORDS' => array( + 1 => 'color: #b1b100;', + 2 => 'color: #000000; font-weight: bold;', + 3 => 'color: #aaaadd; font-weight: bold;', + 4 => 'color: #993333;' + ), + 'COMMENTS' => array( + 1=> 'color: #808080; font-style: italic;', + 2=> 'color: #a1a100;', + 'MULTI' => 'color: #808080; font-style: italic;' + ), + 'ESCAPE_CHAR' => array( + 0 => 'color: #000099; font-weight: bold;' + ), + 'BRACKETS' => array( + 0 => 'color: #66cc66;' + ), + 'STRINGS' => array( + 0 => 'color: #ff0000;' + ), + 'NUMBERS' => array( + 0 => 'color: #cc66cc;' + ), + 'METHODS' => array( + 1 => 'color: #006600;', + 2 => 'color: #006600;' + ), + 'SYMBOLS' => array( + 0 => 'color: #66cc66;' + ), + 'SCRIPT' => array( + ), + 'REGEXPS' => array( + ) + ), + 'URLS' => array( + 1 => '', + 2 => '', + 3 => '', + 4 => '' + ), + 'OOLANG' => true, + 'OBJECT_SPLITTERS' => array( + 1 => '.', + ), + 'REGEXPS' => array( + ), + 'STRICT_MODE_APPLIES' => GESHI_NEVER, + 'SCRIPT_DELIMITERS' => array( + ), + 'HIGHLIGHT_STRICT_BLOCK' => array( + ) +); + +?> diff --git a/inc/geshi/delphi.php b/inc/geshi/delphi.php index 89a6385cf..13b7deb4c 100644 --- a/inc/geshi/delphi.php +++ b/inc/geshi/delphi.php @@ -7,7 +7,7 @@ * Release Version: 1.0.6 * CVS Revision Version: $Revision: 1.1 $
* Date Started: 2004/07/26
- * Last Modified: $Date: 2005/01/29 01:48:39 $
+ * Last Modified: $Date: 2005/06/02 04:57:18 $
*
* Delphi (Object Pascal) language file for GeSHi.
*
diff --git a/inc/geshi/diff.php b/inc/geshi/diff.php new file mode 100644 index 000000000..47ccab677 --- /dev/null +++ b/inc/geshi/diff.php @@ -0,0 +1,137 @@ +<?php +/************************************************************************************* + * diff.php + * -------- + * Author: Conny Brunnkvist (conny@fuchsia.se) + * Copyright: (c) 2004 Fuchsia Open Source Solutions (http://www.fuchsia.se/) + * Release Version: 1.0.0 + * CVS Revision Version: $Revision: 1.1 $ + * Date Started: 2004/12/29 + * Last Modified: $Date: 2005/06/14 13:02:34 $ + * + * Diff-output language file for GeSHi. + * + * CHANGES + * ------- + * 2004/12/29 (1.0.0) + * - First Release + * + * TODO (updated 2004/12/29) + * ------------------------- + * * Find out why GeSHi doesn't seem to allow matching of start (^) and end ($) + * * So that we can stop pretending that we are dealing with single-line comments + * * Should be able to cover all sorts of diff-output + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ + + +$language_data = array ( + 'LANG_NAME' => 'Diff', + 'COMMENT_SINGLE' => array( + 0 => '--- ', + 1 => '+++ ', + 2 => '<', + 3 => '>', + 4 => '-', + 5 => '+', + 6 => '!', + 7 => '@@', + 8 => '*** ', + /*9 => '***************',*/ + /*10 => ' ', // All other rows starts with a space (bug?) */ + ), + 'COMMENT_MULTI' => array(), + 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, + 'QUOTEMARKS' => array(), + 'ESCAPE_CHAR' => ' ', + 'KEYWORDS' => array( + 0 => array( + '\ No newline at end of file', + ), + 1 => array( + '***************' /* This only seems to works in some cases? */ + ), + ), + 'SYMBOLS' => array( + ), + 'CASE_SENSITIVE' => array( + GESHI_COMMENTS => false, + ), + 'STYLES' => array( + 'KEYWORDS' => array( + 0 => 'color: #aaaaaa; font-style: italic;', + 1 => 'color: #dd6611;', + ), + 'COMMENTS' => array( + 0 => 'color: #228822;', + 1 => 'color: #228822;', + 2 => 'color: #991111;', + 3 => 'color: #00aaee;', + 4 => 'color: #991111;', + 5 => 'color: #00b000;', + /*6 => 'color: #dd6611;', */ + 6 => 'color: #0011dd;', + 7 => 'color: #aaaa88;', + 8 => 'color: #228822;', + /*9 => 'color: #aaaa88;',*/ + /*10 => 'color: #000000;',*/ + ), + 'ESCAPE_CHAR' => array( + ), + 'BRACKETS' => array( + ), + 'STRINGS' => array( + ), + 'NUMBERS' => array( + ), + 'METHODS' => array( + ), + 'SYMBOLS' => array( + ), + 'SCRIPT' => array( + ), + 'REGEXPS' => array( + 0 => 'color: #aaaaaa;', + /*1 => 'color: #000000;',*/ + ), + ), + 'URLS' => array( + ), + 'OOLANG' => false, + 'OBJECT_SPLITTER' => '', + 'REGEXPS' => array( + 0 => "[0-9,]+[acd][0-9,]+", + /*1 => array( // Match all other lines - again this also doesn't work. + GESHI_SEARCH => '(\ )(.+)', + GESHI_REPLACE => '\\2\\3', + GESHI_MODIFIERS => '', + GESHI_BEFORE => '\\1', + GESHI_AFTER => '' + ),*/ + ), + 'STRICT_MODE_APPLIES' => GESHI_NEVER, + 'SCRIPT_DELIMITERS' => array( + ), + 'HIGHLIGHT_STRICT_BLOCK' => array( + ) +); + +?> diff --git a/inc/geshi/html4strict.php b/inc/geshi/html4strict.php index 7e9bf1416..6f483afaf 100644 --- a/inc/geshi/html4strict.php +++ b/inc/geshi/html4strict.php @@ -7,7 +7,7 @@ * Release Version: 1.0.6 * CVS Revision Version: $Revision: 1.1 $ * Date Started: 2004/07/10 - * Last Modified: $Date: 2005/01/29 01:48:39 $ + * Last Modified: $Date: 2005/06/02 04:57:18 $ * * HTML 4.01 strict language file for GeSHi. * diff --git a/inc/geshi/java.php b/inc/geshi/java.php index 7a8ea2f92..860ce32f8 100644 --- a/inc/geshi/java.php +++ b/inc/geshi/java.php @@ -5,9 +5,9 @@ * Author: Nigel McNie (oracle.shinoda@gmail.com) * Copyright: (c) 2004 Nigel McNie (http://qbnz.com/highlighter/) * Release Version: 1.0.6 - * CVS Revision Version: $Revision: 1.1 $ + * CVS Revision Version: $Revision: 1.2 $ * Date Started: 2004/07/10 - * Last Modified: $Date: 2005/01/29 01:48:39 $ + * Last Modified: $Date: 2005/06/13 22:28:25 $ * * Java language file for GeSHi. * @@ -65,7 +65,8 @@ $language_data = array ( 'null', 'return', 'false', 'final', 'true', 'public', 'private', 'protected', 'extends', 'break', 'class', 'new', 'try', 'catch', 'throws', 'finally', 'implements', - 'interface', 'throw', 'native', 'synchronized', 'this' + 'interface', 'throw', 'native', 'synchronized', 'this', + 'abstract', 'transient' ), 3 => array( 'AbstractAction', 'AbstractBorder', 'AbstractButton', 'AbstractCellEditor', @@ -248,27 +249,11 @@ $language_data = array ( 'FocusEvent', 'FocusListener', 'FocusManager', 'Font', 'FontFormatException', 'FontMetrics', 'FontRenderContext', 'FontUIResource', 'Format', 'FormatConversionProvider', 'FormView', 'Frame', 'FREE_MEM', 'GapContent', 'GeneralPath', 'GeneralSecurityException', - 'GlyphJustificationInfo', 'GlyphMetrics', 'GlyphVector', - 'GlyphView', - 'GlyphView.GlyphPainter', - 'GradientPaint', - 'GraphicAttribute', - 'Graphics', - 'Graphics2D', - 'GraphicsConfigTemplate', - 'GraphicsConfiguration', - 'GraphicsDevice', - 'GraphicsEnvironment', - 'GrayFilter', - 'GregorianCalendar', - 'GridBagConstraints', - 'GridBagLayout', - 'GridLayout', - 'Group', - 'Guard', - 'GuardedObject', - 'GZIPInputStream', - 'GZIPOutputStream', + 'GlyphJustificationInfo', 'GlyphMetrics', 'GlyphVector', 'GlyphView', 'GlyphView.GlyphPainter', + 'GradientPaint', 'GraphicAttribute', 'Graphics', 'Graphics2D', 'GraphicsConfigTemplate', + 'GraphicsConfiguration', 'GraphicsDevice', 'GraphicsEnvironment', 'GrayFilter', + 'GregorianCalendar', 'GridBagConstraints', 'GridBagLayout', 'GridLayout', 'Group', 'Guard', + 'GuardedObject', 'GZIPInputStream', 'GZIPOutputStream', 'HasControls', 'HashMap', 'HashSet', @@ -1330,7 +1315,7 @@ $language_data = array ( '_Remote_Stub ' ), 4 => array( - 'static', 'void', 'double', 'int', 'real', 'boolean', 'byte' + 'static', 'void', 'double', 'int', 'real', 'boolean', 'byte', 'short', 'long', 'single' ) ), 'SYMBOLS' => array( @@ -1382,7 +1367,7 @@ $language_data = array ( 'URLS' => array( 1 => '', 2 => '', - 3 => 'http://www.google.com/search?q=allinurl%3A{FNAME}+java.sun.com&bntl=1', + 3 => 'http://www.google.com/search?q=allinurl%3A{FNAME}+java.sun.com&bntl=1', 4 => '' ), 'OOLANG' => true, @@ -1399,4 +1384,4 @@ $language_data = array ( ) ); -?> +?>
\ No newline at end of file diff --git a/inc/geshi/javascript.php b/inc/geshi/javascript.php index 8744229b1..c321dfa38 100644 --- a/inc/geshi/javascript.php +++ b/inc/geshi/javascript.php @@ -7,7 +7,7 @@ * Release Version: 1.0.6 * CVS Revision Version: $Revision: 1.1 $
* Date Started: 2004/06/20
- * Last Modified: $Date: 2005/01/29 01:48:39 $
+ * Last Modified: $Date: 2005/06/02 04:57:18 $
*
* JavaScript language file for GeSHi.
*
diff --git a/inc/geshi/lisp.php b/inc/geshi/lisp.php index 66b65ae3d..b59e49350 100644 --- a/inc/geshi/lisp.php +++ b/inc/geshi/lisp.php @@ -7,7 +7,7 @@ * Release Version: 1.0.6 * CVS Revision Version: $Revision: 1.1 $ * Date Started: 2004/08/30 - * Last Modified: $Date: 2005/01/29 01:48:39 $ + * Last Modified: $Date: 2005/06/02 04:57:18 $ * * Generic Lisp language file for GeSHi. * diff --git a/inc/geshi/lua.php b/inc/geshi/lua.php index 57e61aba7..28fecbfff 100644 --- a/inc/geshi/lua.php +++ b/inc/geshi/lua.php @@ -7,7 +7,7 @@ * Release Version: 1.0.6 * CVS Revision Version: $Revision: 1.1 $ * Date Started: 2004/07/10 - * Last Modified: $Date: 2005/01/29 01:48:39 $ + * Last Modified: $Date: 2005/06/02 04:57:18 $ * * LUA language file for GeSHi. * diff --git a/inc/geshi/matlab.php b/inc/geshi/matlab.php new file mode 100644 index 000000000..e27807c84 --- /dev/null +++ b/inc/geshi/matlab.php @@ -0,0 +1,109 @@ +<?php
+/*************************************************************************************
+ * matlab.php
+ * -----------
+ * Author: Florian Knorn (floz@gmx.de)
+ * Copyright: (c) 2004 Florian Knorn (http://www.florian-knorn.com)
+ * Release Version: 1.0.0
+ * CVS Revision Version: $Revision: 1.1 $
+ * Date Started: 2005/02/09
+ * Last Modified: $Date: 2005/06/15 12:06:28 $
+ *
+ * Matlab M-file language file for GeSHi.
+ *
+ * CHANGES
+ * -------
+ * 2005/05/07 (1.0.0)
+ * - First Release
+ *
+ *
+ *************************************************************************************
+ *
+ * This file is part of GeSHi.
+ *
+ * GeSHi is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GeSHi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GeSHi; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ ************************************************************************************/
+
+$language_data = array (
+ 'LANG_NAME' => 'M',
+ 'COMMENT_SINGLE' => array(1 => '%'),
+ 'COMMENT_MULTI' => array(),
+ 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE,
+ 'QUOTEMARKS' => array("'"),
+ 'ESCAPE_CHAR' => '',
+ 'KEYWORDS' => array(
+ 1 => array(
+ 'break', 'case', 'catch', 'continue', 'elseif', 'else', 'end', 'for',
+ 'function', 'global', 'if', 'otherwise', 'persistent', 'return',
+ 'switch', 'try', 'while','...'
+ ),
+ ),
+ 'SYMBOLS' => array(
+ '...'
+ ),
+ 'CASE_SENSITIVE' => array(
+ GESHI_COMMENTS => true,
+ 1 => false,
+ 2 => false,
+ 3 => false,
+ 4 => false,
+ ),
+ 'STYLES' => array(
+ 'KEYWORDS' => array(
+ 1 => 'color: #0000FF;',
+ ),
+ 'COMMENTS' => array(
+ 1 => 'color: #228B22;',
+ ),
+ 'ESCAPE_CHAR' => array(
+ ),
+ 'BRACKETS' => array(
+ ),
+ 'STRINGS' => array(
+ 0 => 'color: #A020F0;'
+ ),
+ 'NUMBERS' => array(
+ ),
+ 'METHODS' => array(
+ ),
+ 'SYMBOLS' => array(
+ ),
+ 'REGEXPS' => array(
+ ),
+ 'SCRIPT' => array(
+ )
+ ),
+ 'URLS' => array(
+ 1 => '',
+ 2 => '',
+ 3 => '',
+ 4 => ''
+ ),
+ 'OOLANG' => true,
+ 'OBJECT_SPLITTERS' => array(
+ 1 => '.',
+ 2 => '::'
+ ),
+ 'REGEXPS' => array(
+ ),
+ 'STRICT_MODE_APPLIES' => GESHI_NEVER,
+ 'SCRIPT_DELIMITERS' => array(
+ ),
+ 'HIGHLIGHT_STRICT_BLOCK' => array(
+ )
+);
+
+?>
diff --git a/inc/geshi/mpasm.php b/inc/geshi/mpasm.php index 26732d9ae..2075cea78 100644 --- a/inc/geshi/mpasm.php +++ b/inc/geshi/mpasm.php @@ -7,7 +7,7 @@ * Release Version: 1.0.6 * CVS Revision Version: $Revision: 1.1 $ * Date Started: 2004/12/6 - * Last Modified: $Date: 2005/01/29 02:12:58 $ + * Last Modified: $Date: 2005/06/02 04:57:18 $ * * Microchip Assembler language file for GeSHi. * diff --git a/inc/geshi/nsis.php b/inc/geshi/nsis.php index 9e35dd1d7..bddb4979b 100644 --- a/inc/geshi/nsis.php +++ b/inc/geshi/nsis.php @@ -7,7 +7,7 @@ * Release Version: 1.0.6 * CVS Revision Version: $Revision: 1.1 $ * Date Started: 2004/29/07 - * Last Modified: $Date: 2005/01/29 01:48:39 $ + * Last Modified: $Date: 2005/06/02 04:57:18 $ * * NullSoft Installer System language file for GeSHi. * Words are from SciTe configuration file diff --git a/inc/geshi/objc.php b/inc/geshi/objc.php index c39683968..015fd2e24 100644 --- a/inc/geshi/objc.php +++ b/inc/geshi/objc.php @@ -7,7 +7,7 @@ * Release Version: 1.0.6 * CVS Revision Version: $Revision: 1.1 $ * Date Started: 2004/06/04 - * Last Modified: $Date: 2005/01/29 01:48:39 $ + * Last Modified: $Date: 2005/06/02 04:57:18 $ * * Objective C language file for GeSHi. * diff --git a/inc/geshi/oobas.php b/inc/geshi/oobas.php index 4652197ed..3ba4e34d4 100644 --- a/inc/geshi/oobas.php +++ b/inc/geshi/oobas.php @@ -7,7 +7,7 @@ * Release Version: 1.0.6 * CVS Revision Version: $Revision: 1.1 $ * Date Started: 2004/08/30 - * Last Modified: $Date: 2005/01/29 01:48:39 $ + * Last Modified: $Date: 2005/06/02 04:57:18 $ * * OpenOffice.org Basic language file for GeSHi. * diff --git a/inc/geshi/oracle8.php b/inc/geshi/oracle8.php index f3c8c9c8a..9797722b0 100644 --- a/inc/geshi/oracle8.php +++ b/inc/geshi/oracle8.php @@ -5,9 +5,9 @@ * Author: Guy Wicks (Guy.Wicks@rbs.co.uk) * Copyright: (c) 2004 Nigel McNie (http://qbnz.com/highlighter) * Release Version: 1.0.6 - * CVS Revision Version: $Revision: 1.2 $ + * CVS Revision Version: $Revision: 1.1 $ * Date Started: 2004/06/04 - * Last Modified: $Date: 2005/01/29 02:06:01 $ + * Last Modified: $Date: 2005/06/02 04:57:18 $ * * Oracle 8 language file for GeSHi * diff --git a/inc/geshi/pascal.php b/inc/geshi/pascal.php index b36cad7f1..8d4c9701c 100644 --- a/inc/geshi/pascal.php +++ b/inc/geshi/pascal.php @@ -7,7 +7,7 @@ * Release Version: 1.0.6 * CVS Revision Version: $Revision: 1.1 $ * Date Started: 2004/07/26 - * Last Modified: $Date: 2005/01/29 01:48:39 $ + * Last Modified: $Date: 2005/06/02 04:57:18 $ * * Pascal language file for GeSHi. * diff --git a/inc/geshi/perl.php b/inc/geshi/perl.php index cfc0fee53..b2e5b2117 100644 --- a/inc/geshi/perl.php +++ b/inc/geshi/perl.php @@ -7,7 +7,7 @@ * Release Version: 1.0.6 * CVS Revision Version: $Revision: 1.1 $ * Date Started: 2004/08/20 - * Last Modified: $Date: 2005/01/29 01:48:39 $ + * Last Modified: $Date: 2005/06/02 04:57:18 $ * * Perl language file for GeSHi. * diff --git a/inc/geshi/php-brief.php b/inc/geshi/php-brief.php index f1d6bddfb..85fd72765 100644 --- a/inc/geshi/php-brief.php +++ b/inc/geshi/php-brief.php @@ -7,7 +7,7 @@ * Release Version: 1.0.6 * CVS Revision Version: $Revision: 1.1 $ * Date Started: 2004/06/02 - * Last Modified: $Date: 2005/01/29 01:48:39 $ + * Last Modified: $Date: 2005/06/02 04:57:18 $ * * PHP language file for GeSHi (brief version). * diff --git a/inc/geshi/php.php b/inc/geshi/php.php index 734e770a7..3f6b60e7f 100644 --- a/inc/geshi/php.php +++ b/inc/geshi/php.php @@ -5,9 +5,9 @@ * Author: Nigel McNie (oracle.shinoda@gmail.com) * Copyright: (c) 2004 Nigel McNie (http://qbnz.com/highlighter/) * Release Version: 1.0.6 - * CVS Revision Version: $Revision: 1.1 $ + * CVS Revision Version: $Revision: 1.2 $ * Date Started: 2004/06/20 - * Last Modified: $Date: 2005/01/29 01:48:39 $ + * Last Modified: $Date: 2005/06/13 22:28:47 $ * * PHP language file for GeSHi. * @@ -60,8 +60,9 @@ $language_data = array ( 'KEYWORDS' => array( 1 => array( 'include', 'require', 'include_once', 'require_once', - 'for', 'foreach', 'as', 'if', 'elseif', 'else', 'while', 'do', 'endwhile', 'endif', 'switch', 'case', 'endswitch', - 'return', 'break' + 'for', 'foreach', 'as', 'if', 'elseif', 'else', 'while', 'do', 'endwhile', + 'endif', 'switch', 'case', 'endswitch', + 'return', 'break', 'continue' ), 2 => array( 'null', '__LINE__', '__FILE__', @@ -254,7 +255,8 @@ $language_data = array ( 'apache_setenv','apache_response_headers','apache_request_headers','apache_note','apache_lookup_uri','apache_get_version', 'apache_child_terminate','aggregation_info','aggregate_properties_by_regexp','aggregate_properties_by_list','aggregate_properties','aggregate_methods_by_regexp', 'aggregate_methods_by_list','aggregate_methods','aggregate','addslashes','addcslashes','acosh', - 'acos','abs','_','echo', 'print', 'global', 'static', 'exit', 'array', 'empty', 'eval', 'isset', 'unset', 'die' + 'acos','abs','_','echo', 'print', 'global', 'static', 'exit', 'array', 'empty', + 'eval', 'isset', 'unset', 'die', 'list' ) ), 'SYMBOLS' => array( diff --git a/inc/geshi/python.php b/inc/geshi/python.php index ca1b231eb..2434ca40e 100644 --- a/inc/geshi/python.php +++ b/inc/geshi/python.php @@ -5,14 +5,16 @@ * Author: Roberto Rossi (rsoftware@altervista.org) * Copyright: (c) 2004 Roberto Rossi (http://rsoftware.altervista.org), Nigel McNie (http://qbnz.com/highlighter) * Release Version: 1.0.6 - * CVS Revision Version: $Revision: 1.1 $ + * CVS Revision Version: $Revision: 1.2 $ * Date Started: 2004/08/30 - * Last Modified: $Date: 2005/01/29 01:48:39 $ + * Last Modified: $Date: 2005/06/14 13:03:15 $ * * Python language file for GeSHi. * * CHANGES * ------- + * 2005/05/26 + * - Modifications by Tim (tim@skreak.com): added more keyword categories, tweaked colors * 2004/11/27 (1.0.1) * - Added support for multiple object splitters * 2004/08/30 (1.0.0) @@ -46,49 +48,127 @@ $language_data = array ( 'COMMENT_SINGLE' => array(1 => '#'), 'COMMENT_MULTI' => array(), 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, - 'QUOTEMARKS' => array('"'), - 'ESCAPE_CHAR' => '', + 'QUOTEMARKS' => array('"', "'", '"""'), + 'ESCAPE_CHAR' => '\\', 'KEYWORDS' => array( + + /* + ** Set 1: reserved words + ** http://python.org/doc/current/ref/keywords.html + */ 1 => array( - 'and','assert','break','class','continue','def','del','elif','else','except','exec','finally','for','from', - 'global','if','import','in','is','lambda','map','not','None','or','pass','print','raise','range','return', - 'try','while','abs','apply','callable','chr','cmp','coerce','compile','complex','delattr','dir','divmod', - 'eval','execfile','filter','float','getattr','globals','group','hasattr','hash','hex','', - 'id','input','int','intern','isinstance','issubclass','joinfields','len','list','local','long', - 'max','min','match','oct','open','ord','pow','raw_input','reduce','reload','repr','round', - 'search','setattr','setdefault','slice','str','splitfields','unichr','unicode','tuple','type', - 'vars','xrange','zip','__abs__','__add__','__and__','__call__','__cmp__','__coerce__', - '__del__','__delattr__','__delitem__','__delslice__','__div__','__divmod__', - '__float__','__getattr__','__getitem__','__getslice__','__hash__','__hex__', - '__iadd__','__isub__','__imod__','__idiv__','__ipow__','__iand__','__ior__','__ixor__', - '__ilshift__','__irshift__','__invert__','__int__','__init__','__len__','__long__','__lshift__', - '__mod__','__mul__','__neg__','__nonzero__','__oct__','__or__','__pos__','__pow__', + 'and', 'del', 'for', 'is', 'raise', 'assert', 'elif', 'from', 'lambda', 'return', 'break', + 'else', 'global', 'not', 'try', 'class', 'except', 'if', 'or', 'while', 'continue', 'exec', + 'import', 'pass', 'yield', 'def', 'finally', 'in', 'print' + ), + + /* + ** Set 2: builtins + ** http://python.org/doc/current/lib/built-in-funcs.html + */ + 2 => array( + '__import__', 'abs', 'basestring', 'bool', 'callable', 'chr', 'classmethod', 'cmp', + 'compile', 'complex', 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval', 'execfile', + 'file', 'filter', 'float', 'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'help', + 'hex', 'id', 'input', 'int', 'isinstance', 'issubclass', 'iter', 'len', 'list', 'locals', + 'long', 'map', 'max', 'min', 'object', 'oct', 'open', 'ord', 'pow', 'property', 'range', + 'raw_input', 'reduce', 'reload', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice', + 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'unichr', 'unicode', + 'vars', 'xrange', 'zip', + // Built-in constants: http://python.org/doc/current/lib/node35.html + 'False', 'True', 'None', 'NotImplemented', 'Ellipsis', + // Built-in Exceptions: http://python.org/doc/current/lib/module-exceptions.html + 'Exception', 'StandardError', 'ArithmeticError', 'LookupError', 'EnvironmentError', + 'AssertionError', 'AttributeError', 'EOFError', 'FloatingPointError', 'IOError', + 'ImportError', 'IndexError', 'KeyError', 'KeyboardInterrupt', 'MemoryError', 'NameError', + 'NotImplementedError', 'OSError', 'OverflowError', 'ReferenceError', 'RuntimeError', + 'StopIteration', 'SyntaxError', 'SystemError', 'SystemExit', 'TypeError', + 'UnboundlocalError', 'UnicodeError', 'UnicodeEncodeError', 'UnicodeDecodeError', + 'UnicodeTranslateError', 'ValueError', 'WindowsError', 'ZeroDivisionError', 'Warning', + 'UserWarning', 'DeprecationWarning', 'PendingDeprecationWarning', 'SyntaxWarning', + 'RuntimeWarning', 'FutureWarning', + // self: this is a common python convention (but not a reserved word) + 'self' + ), + + /* + ** Set 3: standard library + ** http://python.org/doc/current/lib/modindex.html + */ + 3 => array( + '__builtin__', '__future__', '__main__', '_winreg', 'aifc', 'AL', 'al', 'anydbm', + 'array', 'asynchat', 'asyncore', 'atexit', 'audioop', 'base64', 'BaseHTTPServer', + 'Bastion', 'binascii', 'binhex', 'bisect', 'bsddb', 'bz2', 'calendar', 'cd', 'cgi', + 'CGIHTTPServer', 'cgitb', 'chunk', 'cmath', 'cmd', 'code', 'codecs', 'codeop', + 'collections', 'colorsys', 'commands', 'compileall', 'compiler', 'compiler', + 'ConfigParser', 'Cookie', 'cookielib', 'copy', 'copy_reg', 'cPickle', 'crypt', + 'cStringIO', 'csv', 'curses', 'datetime', 'dbhash', 'dbm', 'decimal', 'DEVICE', + 'difflib', 'dircache', 'dis', 'distutils', 'dl', 'doctest', 'DocXMLRPCServer', 'dumbdbm', + 'dummy_thread', 'dummy_threading', 'email', 'encodings', 'errno', 'exceptions', 'fcntl', + 'filecmp', 'fileinput', 'FL', 'fl', 'flp', 'fm', 'fnmatch', 'formatter', 'fpectl', + 'fpformat', 'ftplib', 'gc', 'gdbm', 'getopt', 'getpass', 'gettext', 'GL', 'gl', 'glob', + 'gopherlib', 'grp', 'gzip', 'heapq', 'hmac', 'hotshot', 'htmlentitydefs', 'htmllib', + 'HTMLParser', 'httplib', 'imageop', 'imaplib', 'imgfile', 'imghdr', 'imp', 'inspect', + 'itertools', 'jpeg', 'keyword', 'linecache', 'locale', 'logging', 'mailbox', 'mailcap', + 'marshal', 'math', 'md5', 'mhlib', 'mimetools', 'mimetypes', 'MimeWriter', 'mimify', + 'mmap', 'msvcrt', 'multifile', 'mutex', 'netrc', 'new', 'nis', 'nntplib', 'operator', + 'optparse', 'os', 'ossaudiodev', 'parser', 'pdb', 'pickle', 'pickletools', 'pipes', + 'pkgutil', 'platform', 'popen2', 'poplib', 'posix', 'posixfile', 'pprint', 'profile', + 'pstats', 'pty', 'pwd', 'py_compile', 'pyclbr', 'pydoc', 'Queue', 'quopri', 'random', + 're', 'readline', 'repr', 'resource', 'rexec', 'rfc822', 'rgbimg', 'rlcompleter', + 'robotparser', 'sched', 'ScrolledText', 'select', 'sets', 'sgmllib', 'sha', 'shelve', + 'shlex', 'shutil', 'signal', 'SimpleHTTPServer', 'SimpleXMLRPCServer', 'site', 'smtpd', + 'smtplib', 'sndhdr', 'socket', 'SocketServer', 'stat', 'statcache', 'statvfs', 'string', + 'StringIO', 'stringprep', 'struct', 'subprocess', 'sunau', 'SUNAUDIODEV', 'sunaudiodev', + 'symbol', 'sys', 'syslog', 'tabnanny', 'tarfile', 'telnetlib', 'tempfile', 'termios', + 'test', 'textwrap', 'thread', 'threading', 'time', 'timeit', 'Tix', 'Tkinter', 'token', + 'tokenize', 'traceback', 'tty', 'turtle', 'types', 'unicodedata', 'unittest', 'urllib2', + 'urllib', 'urlparse', 'user', 'UserDict', 'UserList', 'UserString', 'uu', 'warnings', + 'wave', 'weakref', 'webbrowser', 'whichdb', 'whrandom', 'winsound', 'xdrlib', 'xml', + 'xmllib', 'xmlrpclib', 'zipfile', 'zipimport', 'zlib' + ), + + /* + ** Set 4: special methods + ** http://python.org/doc/current/ref/specialnames.html + */ + 4 => array( + /* + // Iterator types: http://python.org/doc/current/lib/typeiter.html + '__iter__', 'next', + // String types: http://python.org/doc/current/lib/string-methods.html + 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', + 'find', 'index', 'isalnum', 'isaplpha', 'isdigit', 'islower', 'isspace', 'istitle', + 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'replace', 'rfind', 'rindex', 'rjust', + 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', + 'translate', 'upper', 'zfill', + */ + // Basic customization: http://python.org/doc/current/ref/customization.html + '__new__', '__init__', '__del__', '__repr__', '__str__', + '__lt__', '__le__', '__eq__', '__ne__', '__gt__', '__ge__', '__cmp__', '__rcmp__', + '__hash__', '__nonzero__', '__unicode__', '__dict__', + // Attribute access: http://python.org/doc/current/ref/attribute-access.html + '__setattr__', '__delattr__', '__getattr__', '__getattribute__', '__get__', '__set__', + '__delete__', '__slots__', + // Class creation, callable objects + '__metaclass__', '__call__', + // Container types: http://python.org/doc/current/ref/sequence-types.html + '__len__', '__getitem__', '__setitem__', '__delitem__', '__iter__', '__contains__', + '__getslice__', '__setslice__', '__delslice__', + // Numeric types: http://python.org/doc/current/ref/numeric-types.html + '__abs__','__add__','__and__','__coerce__','__div__','__divmod__','__float__', + '__hex__','__iadd__','__isub__','__imod__','__idiv__','__ipow__','__iand__', + '__ior__','__ixor__', '__ilshift__','__irshift__','__invert__','__int__', + '__long__','__lshift__', + '__mod__','__mul__','__neg__','__oct__','__or__','__pos__','__pow__', '__radd__','__rdiv__','__rdivmod__','__rmod__','__rpow__','__rlshift__','__rrshift__', '__rshift__','__rsub__','__rmul__','__repr__','__rand__','__rxor__','__ror__', - '__setattr__','__setitem__','__setslice__','__str__','__sub__','__xor__', - '__bases__','__class__','__dict__','__methods__','__members__','__name__', - '__version__','ArithmeticError','AssertionError','AttributeError','EOFError','Exception', - 'FloatingPointError','IOError','ImportError','IndentationError','IndexError', - 'KeyError','KeyboardInterrupt','LookupError','MemoryError','NameError','OverflowError', - 'RuntimeError','StandardError','SyntaxError','SystemError','SystemExit','TabError','TypeError', - 'ValueError','ZeroDivisionError','AST','','atexit','BaseHTTPServer','Bastion', - 'cmd','codecs','commands','compileall','copy','CGIHTTPServer','Complex','dbhash', - 'dircmp','dis','dospath','dumbdbm','emacs','find','fmt','fnmatch','ftplib', - 'getopt','glob','gopherlib','grep','htmllib','httplib','ihooks','imghdr','imputil', - 'linecache','lockfile','macpath','macurl2path','mailbox','mailcap', - 'mimetools','mimify','mutex','math','Mimewriter','newdir','ni','nntplib','ntpath','nturl2path', - 'os','ospath','pdb','pickle','pipes','poly','popen2','posixfile','posixpath','profile','pstats','pyclbr', - 'pyexpat','Para','quopri','Queue','rand','random','regex','regsub','rfc822', - 'sched','sgmllib','shelve','site','sndhdr','string','sys','snmp', - 'SimpleHTTPServer','StringIO','SocketServer', - 'tb','tempfile','toaiff','token','tokenize','traceback','tty','types','tzparse', - 'Tkinter','unicodedata','urllib','urlparse','util','uu','UserDict','UserList', - 'wave','webbrowser','whatsound','whichdb','whrandom','xdrlib','xml','xmlpackage', - 'zmod','array','struct','self', + '__sub__','__xor__' ) + ), 'SYMBOLS' => array( - '(', ')', '[', ']', '{', '}', '*', '&', '%', '!', ';', '<', '>', '?' + '(', ')', '[', ']', '{', '}', '*', '&', '%', '!', ';', '<', '>', '?', '`' ), 'CASE_SENSITIVE' => array( GESHI_COMMENTS => true, @@ -96,7 +176,10 @@ $language_data = array ( ), 'STYLES' => array( 'KEYWORDS' => array( - 1 => 'color: #b1b100;' + 1 => 'color: #ff7700;font-weight:bold;', // Reserved + 2 => 'color: #008000;', // Built-ins + self + 3 => 'color: #dc143c;', // Standard lib + 4 => 'color: #0000cd;' // Special methods ), 'COMMENTS' => array( 1 => 'color: #808080; font-style: italic;', @@ -106,16 +189,16 @@ $language_data = array ( 0 => 'color: #000099; font-weight: bold;' ), 'BRACKETS' => array( - 0 => 'color: #66cc66;' + 0 => 'color: black;' ), 'STRINGS' => array( - 0 => 'color: #ff0000;' + 0 => 'color: #483d8b;' ), 'NUMBERS' => array( - 0 => 'color: #cc66cc;' + 0 => 'color: #ff4500;' ), 'METHODS' => array( - 1 => 'color: #202020;' + 1 => 'color: black;' ), 'SYMBOLS' => array( 0 => 'color: #66cc66;' @@ -140,4 +223,4 @@ $language_data = array ( ) ); -?>
\ No newline at end of file +?> diff --git a/inc/geshi/qbasic.php b/inc/geshi/qbasic.php index 3eafea681..72c179b53 100644 --- a/inc/geshi/qbasic.php +++ b/inc/geshi/qbasic.php @@ -7,7 +7,7 @@ * Release Version: 1.0.6 * CVS Revision Version: $Revision: 1.1 $ * Date Started: 2004/06/20 - * Last Modified: $Date: 2005/01/29 01:48:39 $ + * Last Modified: $Date: 2005/06/02 04:57:18 $ * * QBasic/QuickBASIC language file for GeSHi. * diff --git a/inc/geshi/smarty.php b/inc/geshi/smarty.php index 6dae5f4d9..eb8514ad2 100644 --- a/inc/geshi/smarty.php +++ b/inc/geshi/smarty.php @@ -5,9 +5,9 @@ * Author: Alan Juden (alan@judenware.org)
* Copyright: (c) 2004 Alan Juden, Nigel McNie (http://qbnz.com/highlighter/)
* Release Version: 1.0.6 - * CVS Revision Version: $Revision: 1.1 $
+ * CVS Revision Version: $Revision: 1.2 $
* Date Started: 2004/07/10
- * Last Modified: $Date: 2005/01/29 01:48:39 $
+ * Last Modified: $Date: 2005/06/13 22:29:20 $
*
* Smarty template language file for GeSHi.
*
@@ -49,7 +49,7 @@ $language_data = array ( 'KEYWORDS' => array(
1 => array(
'$smarty', 'now', 'const', 'capture', 'config', 'section', 'foreach', 'template', 'version', 'ldelim', 'rdelim',
- 'config_load', 'foreach', 'foreachelse', 'include', 'include_php', 'insert', 'if', 'elseif', 'else', 'php',
+ 'config_load', 'foreachelse', 'include', 'include_php', 'insert', 'if', 'elseif', 'else', 'php',
'sectionelse', 'clear_all_cache', 'clear_cache', 'is_cached', 'from', 'item'
),
2 => array(
@@ -164,4 +164,4 @@ $language_data = array ( )
);
-?>
\ No newline at end of file +?>
diff --git a/inc/geshi/sql.php b/inc/geshi/sql.php index 9537df2c1..284ccdc31 100644 --- a/inc/geshi/sql.php +++ b/inc/geshi/sql.php @@ -5,9 +5,9 @@ * Author: Nigel McNie (oracle.shinoda@gmail.com) * Copyright: (c) 2004 Nigel McNie (http://qbnz.com/highlighter) * Release Version: 1.0.6 - * CVS Revision Version: $Revision: 1.1 $ + * CVS Revision Version: $Revision: 1.2 $ * Date Started: 2004/06/04 - * Last Modified: $Date: 2005/01/29 01:48:39 $ + * Last Modified: $Date: 2005/06/15 12:07:06 $ * * SQL language file for GeSHi. * @@ -52,7 +52,7 @@ $language_data = array ( 'LANG_NAME' => 'SQL', 'COMMENT_SINGLE' => array(1 =>'--', 2 => '#'), - 'COMMENT_MULTI' => array(), + 'COMMENT_MULTI' => array('/*' => '*/'), 'CASE_KEYWORDS' => 1, 'QUOTEMARKS' => array("'", '"', '`'), 'ESCAPE_CHAR' => '\\', diff --git a/inc/geshi/vb.php b/inc/geshi/vb.php index da2a90eb0..c0be88130 100644 --- a/inc/geshi/vb.php +++ b/inc/geshi/vb.php @@ -7,7 +7,7 @@ * Release Version: 1.0.6 * CVS Revision Version: $Revision: 1.1 $ * Date Started: 2004/08/30 - * Last Modified: $Date: 2005/01/29 01:48:39 $ + * Last Modified: $Date: 2005/06/02 04:57:18 $ * * Visual Basic language file for GeSHi. * diff --git a/inc/geshi/vbnet.php b/inc/geshi/vbnet.php index bc9a9f8bc..2fb77bc33 100644 --- a/inc/geshi/vbnet.php +++ b/inc/geshi/vbnet.php @@ -5,9 +5,9 @@ * Author: Alan Juden (alan@judenware.org)
* Copyright: (c) 2004 Alan Juden, Nigel McNie (http://qbnz.com/highlighter)
* Release Version: 1.0.6 - * CVS Revision Version: $Revision: 1.1 $
+ * CVS Revision Version: $Revision: 1.3 $
* Date Started: 2004/06/04
- * Last Modified: $Date: 2005/01/29 01:48:39 $
+ * Last Modified: $Date: 2005/06/15 12:07:32 $
*
* VB.NET language file for GeSHi.
*
@@ -152,7 +152,6 @@ ),
'COMMENTS' => array(
1 => 'color: #008080; font-style: italic;',
- 2 => 'color: #008080;',
'MULTI' => 'color: #008080; font-style: italic;'
),
'ESCAPE_CHAR' => array(
@@ -197,4 +196,4 @@ )
);
-?>
\ No newline at end of file +?>
diff --git a/inc/geshi/vhdl.php b/inc/geshi/vhdl.php new file mode 100644 index 000000000..bb6d7f0aa --- /dev/null +++ b/inc/geshi/vhdl.php @@ -0,0 +1,140 @@ +<?php +/************************************************************************************* + * vhdl.php + * -------- + * Author: Alexander 'E-Razor' Krause (admin@erazor-zone.de) + * Copyright: (c) 2005 Alexander Krause + * Release Version: 1.0.0 + * CVS Revision Version: $Revision: 1.1 $ + * Date Started: 2005/06/15 + * Last Modified: $Date: 2005/06/14 13:02:34 $ + * + * VHDL (VHSICADL, very high speed integrated circuit HDL) language file for GeSHi. + * + * CHANGES + * ------- + * 2006/06/15 (1.0.0) + * - First Release + * + * TODO + * ---- + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ + +$language_data = array ( + 'LANG_NAME' => 'vhdl', + 'COMMENT_SINGLE' => array(1 => '--'), + 'COMMENT_MULTI' => array(), + 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, + 'QUOTEMARKS' => array('"'), + 'ESCAPE_CHAR' => '', + 'KEYWORDS' => array( + /*keywords*/ + 1 => array( + 'access','after','alias','all','assert','architecture','begin', + 'block','body','buffer','bus','case','component','configuration','constant', + 'disconnect','downto','else','elsif','end','entity','exit','file','for', + 'function','generate','generic','group','guarded','if','impure','in', + 'inertial','inout','is','label','library','linkage','literal','loop', + 'map','new','next','null','of','on','open','others','out','package', + 'port','postponed','procedure','process','pure','range','record','register', + 'reject','report','return','select','severity','signal','shared','subtype', + 'then','to','transport','type','unaffected','units','until','use','variable', + 'wait','when','while','with','note','warning','error','failure','and', + 'or','xor','not','nor' + ), + /*types*/ + 2 => array( + 'bit','bit_vector','character','boolean','integer','real','time','string', + 'severity_level','positive','natural','signed','unsigned','line','text', + 'std_logic','std_logic_vector','std_ulogic','std_ulogic_vector','qsim_state', + 'qsim_state_vector','qsim_12state','qsim_12state_vector','qsim_strength', + 'mux_bit','mux_vector','reg_bit','reg_vector','wor_bit','wor_vector' + ), + /*operators*/ + 3 => array( + '=','<=',':=','=>','==' + ) + ), + 'SYMBOLS' => array( + '[', ']', '(', ')',';','<','>',':' + ), + 'CASE_SENSITIVE' => array( + GESHI_COMMENTS => true, + 1 => false, + 2 => false + ), + 'STYLES' => array( + 'KEYWORDS' => array( + 1 => 'color: #000000; font-weight: bold;', + 2 => 'color: #aa0000;' + ), + 'COMMENTS' => array( + 1 => 'color: #adadad; font-style: italic;' + ), + 'ESCAPE_CHAR' => array( + 0 => 'color: #000099; font-weight: bold;' + ), + 'BRACKETS' => array( + 0 => 'color: #66cc66;' + ), + 'STRINGS' => array( + 0 => 'color: #7f007f;' + ), + 'NUMBERS' => array( + 0 => 'color: #ff0000;' + ), + 'METHODS' => array( + ), + 'SYMBOLS' => array( + 0 => 'color: #66cc66;' + ), + 'REGEXPS' => array( + 0 => 'color: #ff0000;', + 1 => 'color: #ff0000;', + 2 => 'color: #ff0000;', + 3 => 'color: #ff0000;' + ), + 'SCRIPT' => array( + ) + ), + 'URLS' => array( + 1 => '', + 2 => '' + ), + 'OOLANG' => false, + 'OBJECT_SPLITTERS' => array( + ), + 'REGEXPS' => array( + 0 => '(\b(0x)[0-9a-fA-F]{2,}[hH]?|\b(0x)?[0-9a-fA-F]{2,}[hH])|'. + '(\b[0-9]{1,}((\.){1}[0-9]{1,}){0,1}(E)[\-]{0,1}[0-9]{1,})|'. + '(\b(ns))|'. + "('[0-9a-zA-Z]+)", + 1 => "\b(''[0-9]'')" + ), + 'STRICT_MODE_APPLIES' => GESHI_NEVER, + 'SCRIPT_DELIMITERS' => array( + ), + 'HIGHLIGHT_STRICT_BLOCK' => array( + ) +); + +?> diff --git a/inc/geshi/xml.php b/inc/geshi/xml.php index 9eb775b7e..24bf1a4d6 100644 --- a/inc/geshi/xml.php +++ b/inc/geshi/xml.php @@ -5,9 +5,9 @@ * Author: Nigel McNie (oracle.shinoda@gmail.com) * Copyright: (c) 2004 Nigel McNie (http://qbnz.com/highlighter/) * Release Version: 1.0.6 - * CVS Revision Version: $Revision: 1.1 $ + * CVS Revision Version: $Revision: 1.3 $ * Date Started: 2004/09/01 - * Last Modified: $Date: 2005/01/29 01:48:39 $ + * Last Modified: $Date: 2005/06/13 22:30:42 $ * * XML language file for GeSHi. Based on the idea/file by Christian Weiske * @@ -43,7 +43,7 @@ ************************************************************************************/ $language_data = array ( - 'LANG_NAME' => 'HTML', + 'LANG_NAME' => 'XML', 'COMMENT_SINGLE' => array(), 'COMMENT_MULTI' => array('<!--' => '-->'), 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, @@ -105,7 +105,7 @@ $language_data = array ( GESHI_AFTER => '\\4' ), 1 => array( - GESHI_SEARCH => '(</?[a-z0-9]*(>)?)', + GESHI_SEARCH => '(</?[a-z0-9_]*(>)?)', GESHI_REPLACE => '\\1', GESHI_MODIFIERS => 'i', GESHI_BEFORE => '', diff --git a/inc/parser/handler.php b/inc/parser/handler.php index 3ba3d654e..5908f23a2 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -315,7 +315,8 @@ class Doku_Handler { $matches[0] = NULL; } # $matches[0] contains name of programming language - # if available + # if available, We shortcut html here. + if($matches[0] == 'html') $matches[0] = 'html4strict'; $this->_addCall( 'code', array($matches[1],$matches[0]), |