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.
Located in /plugins/content/geshi/geshi/geshi.php (line 262)
Whether CSS IDs should be added to the code
Flag to decide if multi line spans are allowed. Set it to false to make sure each tag is closed before and reopened after each linefeed.
The style for the actual code
Whether important blocks should be recognised or not
The encoding to use for entity encoding
NOTE: Used with Escape Char Sequences to fix UTF-8 handling (cf. SF#2037598)
The error message associated with an error
Possible error messages
The content of the footer block
The style of the footer block
Tells if a block around the highlighted source should be forced
if not using line numbering
The content of the header block
The style of the header block
The type of header to use. Can be one of the following values:
Lines that should be highlighted extra
Styles of extra-highlighted lines
Styles of lines that should be highlighted extra
Styles for important parts of the code
Should keywords be linked?
The language to use when highlighting
The data for the language used
The path to the language files
Array of permissions for which lexics should be highlighted
The line ending If null, nl2br() will be used on the result string.
Otherwise, all instances of \n will be replaced with $line_ending
The "nth" value for fancy line highlighting
Flag for how line numbers are displayed
Number at which line numbers should start at
Line number styles
Line number styles for fancy lines
The styles for hyperlinks in the code
Default target for keyword links
Currently loaded language file
The overall class for this code block
The overall ID for this code block
The overall style for this code block
Wether the caches needed for parsing are built or not
The source code to highlight
Whether highlighting is strict or not
Style for line numbers when GESHI_HEADER_PRE_TABLE is chosen
The size of tab stops
The time it took to parse the code
Whether to use CSS classes in output
Should we use language-defined tab stop widths?
some "callback parameters" for handle_multiline_regexps
Work around for Suhosin Patch with disabled /e modifier
Note from suhosins author in config file: <blockquote> The /e modifier inside
allows code execution. Often it is the cause for remote code execution exploits. It is wise to deactivate this feature and test where in the application it is used. The developer using the /e modifier should be made aware that he should use instead </blockquote>Creates a new GeSHi object, with source and language
Adds a keyword to a keyword group for highlighting
Creates a new keyword group
Setup caches needed for parsing. This is automatically called in parse_code() when appropriate.
This function makes stylesheet generators much faster as they do not need these caches.
Setup caches needed for styling. This is automatically called in
parse_code() and get_stylesheet() when appropriate. This function helps stylesheet generators as they rely on some style information being preprocessed
Changes the case of a keyword for those languages where a change is asked for
Disables all highlighting
Sets whether CSS classes should be used to highlight the source. Default is off, calling this method with no arguments will turn it on
Enables all highlighting
The optional flag parameter was added in version 1.0.7.21 and can be used to enable (true) or disable (false) all highlighting.
Whether CSS IDs should be added to each line
Sets whether context-important blocks are highlighted
Sets whether to force a surrounding block around the highlighted code or not
Turns linking of keywords on or off.
Sets whether line numbers should be displayed.
Valid values for the first parameter are:
Sets wether spans and other HTML markup generated by GeSHi can span over multiple lines or not. Defaults to true to reduce overhead.
Set it to false if you want to manipulate the output or manually display the code in an ordered list.
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.
Returns an error message associated with the last GeSHi operation, or false if no error has occured
Takes the parsed code and various options, and creates the HTML surrounding it to make it look nice.
Returns the footer for the code block.
Get full_name for a lang or false.
Gets a human-readable language name (thanks to Simon Patterson for the idea :))
Given a file extension, this method returns either a valid geshi language name, or the empty string if it couldn't be found
Get's the style that is used for the specified line
Get current setting for multiline spans, see GeSHi->enable_multiline_span().
Returns the tab width to use, based on the current language and user preference
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
Get supported langs or an associative array lang=>full_name.
Gets the time taken to parse the code
Handles replacements of keywords to include markup and links if requested
handles newlines in REGEXPS matches. Set the _hmr_* vars before calling this
handles regular expressions highlighting-definitions with callback functions
Creates the header for the code block (with correct attributes)
Specifies which lines to highlight extra
The extra style parameter was added in 1.0.7.21.
Secure replacement for PHP built-in function htmlspecialchars().
See ticket #427 (http://wush.net/trac/wikka/ticket/427) for the rationale for this replacement function.
The INTERFACE for this function is almost the same as that for htmlspecialchars(), with the same default for quote style; however, there is no 'charset' parameter. The reason for this is as follows:
The PHP docs say: "The third argument charset defines character set used in conversion."
I suspect PHP's htmlspecialchars() is working at the byte-value level and thus _needs_ to know (or asssume) a character set because the special characters to be replaced could exist at different code points in different character sets. (If indeed htmlspecialchars() works at byte-value level that goes some way towards explaining why the vulnerability would exist in this function, too, and not only in htmlentities() which certainly is working at byte-value level.)
This replacement function however works at character level and should therefore be "immune" to character set differences - so no charset parameter is needed or provided. If a third parameter is passed, it will be silently ignored.
In the OUTPUT there is a minor difference in that we use ''' instead of PHP's ''' for a single quote: this provides compatibility with get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES) (see comment by mikiwoz at yahoo dot co dot uk on http://php.net/htmlspecialchars); it also matches the entity definition for XML 1.0 (http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_Special_characters). Like PHP we use a numeric character reference instead of ''' for the single quote. For the other special characters we use the named entity references, as PHP is doing.
Swaps out spaces and tabs for HTML indentation. Not needed if the code is in a pre block...
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. If not specified a default table is used
The language table is in the form
array( 'lang_name' => array('extension', 'extension', ...), 'lang_name' ... );
Gets language information and stores it for later use
Merges arrays recursively, overwriting values of the first array with values of later arrays
compile optimized regexp list for keyword group
this functions creates an optimized regular expression list of an array of strings.
Example:
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
Takes a string that has no strings or comments in it, and highlights stuff like keywords, numbers and methods.
Removes a keyword from a keyword group
Removes a keyword group
Replaces certain keywords in the header and footer with certain configuration values
Turns highlighting on/off for brackets
This method is DEPRECATED: use set_symbols_highlighting instead. This method will be remove in 1.2.X
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
Sets the case that keywords should use when found. Use the constants:
Sets whether a set of keywords are checked for in a case sensitive manner
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 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.
Turns highlighting on/off for comment groups
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
Sets the encoding used for htmlspecialchars(), for international support.
NOTE: This is not needed for now because htmlspecialchars() is not being used (it has a security hole in PHP4 that has not been patched). Maybe in a future version it may make a return for speed reasons, but I doubt it.
Turns highlighting on/off for escaped characters
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
Sets the content of the footer block
Sets the style for the footer content
Sets the content of the header block
Sets the style for the header content
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.
From 1.0.7.2, you can use GESHI_HEADER_NONE to specify that no header code should be outputted.
Sets the style for extra-highlighted lines
Sets styles for important parts of the code
Turns highlighting on/off for a keyword group
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
Sets the language for this object
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.
Sets the line-ending
Sets the styles for the line numbers.
Sets styles for links in code
Sets the target for links in code
Turns highlighting on/off for methods
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
Turns highlighting on/off for numbers
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
Sets the overall classname for this block of code. This class can then be used in a stylesheet to style this object's output
Sets the overall id for this block of code. This id can then be used in a stylesheet to style this object's output
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
Turns highlighting on/off for regexps
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
Sets the styles for strict code blocks. If $preserve_defaults is true, then styles are merged with the default styles, with the user defined styles having priority
Sets the source code for this object
Turns highlighting on/off for strings
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
Turns highlighting on/off for symbols
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
Sets how many spaces a tab is substituted for
Widths below zero are ignored
Sets the time taken to parse the code
Sets the base URL to be used for keywords
Sets whether or not to use tab-stop width specifed by language
Sets what number line numbers should start at. Should be a positive integer, and will be converted to one.
Warning: Using this method will add the "start" attribute to the <ol> that is used for line numbering. This is not 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.
this function creates the appropriate regexp string of an token array you should not call this function directly, @see $this->optimize_regexp_list().
Documentation generated on Mon, 25 Jun 2012 13:55:00 -0500 by phpDocumentor 1.4.4