GeSHiThe 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 /geshi.php (line 158)
void
add_keyword_group
(int $key, string $styles, [boolean $case_sensitive = true], [array $words = array()])
void
set_line_style
(string $style1, [string|boolean $style2 = ''], [boolean $preserve_defaults = false])
Constructor GeSHi (line 411)
Creates a new GeSHi object, with source and language
add_keyword (line 1129)
Adds a keyword to a keyword group for highlighting
add_keyword_group (line 1154)
Creates a new keyword group
disable_highlighting (line 998)
Disables all highlighting
enable_classes (line 579)
Sets whether CSS classes should be used to highlight the source. Default is off, calling this method with no arguments will turn it on
enable_highlighting (line 1019)
Enables all highlighting
enable_ids (line 1281)
Whether CSS IDs should be added to each line
enable_important_blocks (line 1271)
Sets whether context-important blocks are highlighted
enable_keyword_links (line 1356)
Turns linking of keywords on or off.
enable_line_numbers (line 650)
Sets whether line numbers should be displayed.
Valid values for the first parameter are:
enable_strict_mode (line 986)
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.
error (line 424)
Returns an error message associated with the last GeSHi operation, or false if no error has occured
get_language_name (line 446)
Gets a human-readable language name (thanks to Simon Patterson for the idea :))
get_language_name_from_extension (line 1045)
Given a file extension, this method returns either a valid geshi language name, or the empty string if it couldn't be found
get_stylesheet (line 2651)
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_time (line 2212)
Gets the time taken to parse the code
highlight_lines_extra (line 1293)
Specifies which lines to highlight extra
hsc (line 2620)
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.
load_from_file (line 1112)
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' ...
);
parse_code (line 1370)
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
remove_keyword (line 1140)
Removes a keyword from a keyword group
remove_keyword_group (line 1168)
Removes a keyword group
set_brackets_highlighting (line 783)
Turns highlighting on/off for brackets
This method is DEPRECATED: use set_symbols_highlighting instead. This method will be remove in 1.2.X
set_brackets_style (line 764)
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
set_case_keywords (line 962)
Sets the case that keywords should use when found. Use the constants:
set_case_sensitivity (line 947)
Sets whether a set of keywords are checked for in a case sensitive manner
set_code_style (line 597)
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.
set_comments_highlighting (line 717)
Turns highlighting on/off for comment groups
set_comments_style (line 701)
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
set_encoding (line 1345)
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.
set_escape_characters_highlighting (line 746)
Turns highlighting on/off for escaped characters
set_escape_characters_style (line 731)
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
set_footer_content (line 1191)
Sets the content of the footer block
set_footer_content_style (line 1211)
Sets the style for the footer content
set_header_content (line 1181)
Sets the content of the header block
set_header_content_style (line 1201)
Sets the style for the header content
set_header_type (line 519)
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.
set_highlight_lines_extra_style (line 1310)
Sets the style for extra-highlighted lines
set_important_styles (line 1261)
Sets styles for important parts of the code
set_keyword_group_highlighting (line 686)
Turns highlighting on/off for a keyword group
set_keyword_group_style (line 670)
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
set_language (line 470)
Sets the language for this object
set_language_path (line 498)
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.
set_line_style (line 618)
Sets the styles for the line numbers.
set_link_styles (line 1236)
Sets styles for links in code
set_link_target (line 1246)
Sets the target for links in code
set_methods_highlighting (line 906)
Turns highlighting on/off for methods
set_methods_style (line 891)
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
set_numbers_highlighting (line 874)
Turns highlighting on/off for numbers
set_numbers_style (line 859)
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
set_overall_class (line 557)
Sets the overall classname for this block of code. This class can then be used in a stylesheet to style this object's output
set_overall_id (line 568)
Sets the overall id for this block of code. This id can then be used in a stylesheet to style this object's output
set_overall_style (line 540)
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
set_regexps_highlighting (line 936)
Turns highlighting on/off for regexps
set_regexps_style (line 920)
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
set_source (line 459)
Sets the source code for this object
set_strings_highlighting (line 845)
Turns highlighting on/off for strings
set_strings_style (line 830)
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
set_symbols_highlighting (line 814)
Turns highlighting on/off for symbols
set_symbols_style (line 797)
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
set_tab_width (line 974)
Sets how many spaces a tab is substituted for
Widths below zero are ignored
set_url_for_keyword_group (line 1224)
Sets the base URL to be used for keywords
start_line_numbers_at (line 1329)
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.
Documentation generated on Sun, 25 Feb 2007 21:29:33 +1300 by phpDocumentor 1.3.0