GeSHi
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 /geshi/geshi.php (line 157)
GeSHi
Creates a new GeSHi object, with source and language
- string $source: The source code to highlight
- string $language: The language to highlight the source with
- string $path: The path to the language file directory. This is deprecated! 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 GeSHi::set_language_path()
Adds a keyword to a keyword group for highlighting
- int $key: The key of the keyword group to add the keyword to
- string $word: The word to add to the keyword group
Creates a new keyword group
- int $key: The key of the keyword group to create
- string $styles: The styles for the keyword group
- boolean $case_sensitive: Whether the keyword group is case sensitive ornot
- array $words: The words to use for the keyword group
Sets whether CSS classes should be used to highlight the source. Default is off, calling this method with no arguments will turn it on
- boolean $flag: Whether to turn classes on or not
Whether CSS IDs should be added to each line
- boolean $flag: If true, IDs will be added to each line.
Sets whether context-important blocks are highlighted
- $flag
Sets whether line numbers should be displayed.
Valid values for the first parameter are:
- GESHI_NO_LINE_NUMBERS: Line numbers will not be displayed
- GESHI_NORMAL_LINE_NUMBERS: Line numbers will be displayed
- GESHI_FANCY_LINE_NUMBERS: Fancy line numbers will be displayed
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.
- int $flag: How line numbers should be displayed
- int $nth_row: Defines which lines are fancy
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.
- boolean $mode: Whether to enable strict mode or not
Returns an error message associated with the last GeSHi operation, or false if no error has occured
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
- string $extension: The extension to get a language name for
- array $lookup: A lookup array to use instead of the default
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
- boolean $economy_mode: Whether to use economy mode or not
Specifies which lines to highlight extra
- mixed $lines: An array of line numbers to highlight, or just a line number on its own.
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' ... );
- $file_name
- $lookup
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
Removes a keyword from a keyword group
- int $key: The key of the keyword group to remove the keyword from
- string $word: The word to remove from the keyword group
Removes a keyword group
- int $key: The key of the keyword group to remove
Turns highlighting on/off for brackets
This method is DEPRECATED: use set_symbols_highlighting instead. This method will be remove in 1.2.X
- boolean $flag: Whether to turn highlighting for brackets on or off
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
- string $style: The style to make the brackets
- boolean $preserve_defaults: Whether to merge the new styles with the old or just to overwrite them
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
- int $case: A constant specifying what to do with matched keywords
Sets whether a set of keywords are checked for in a case sensitive manner
- int $key: The key of the keyword group to change the case sensitivity of
- boolean $case: Whether to check in a case sensitive manner or not
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.
- string $style: The style to use for actual code
- boolean $preserve_defaults: Whether to merge the current styles with the new styles
Turns highlighting on/off for comment groups
- int $key: The key of the comment group to turn on or off
- boolean $flag: Whether to turn highlighting for that group on or off
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
- int $key: The key of the comment group to change the styles of
- string $style: The style to make the comments
- boolean $preserve_defaults: Whether to merge the new styles with the old or just to overwrite them
Sets the encoding used for htmlspecialchars(), for international support.
- string $encoding: The encoding to use for the source
Turns highlighting on/off for escaped characters
- boolean $flag: Whether to turn highlighting for escape characters on or off
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
- string $style: The style to make the escape characters
- boolean $preserve_defaults: Whether to merge the new styles with the old or just to overwrite them
Sets the content of the footer block
- string $content: The content of the footer block
Sets the style for the footer content
- string $style: The style for the footer content
Sets the content of the header block
- string $content: The content of the header block
Sets the style for the header content
- string $style: 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.
- int $type: The type of header to be used
Sets the style for extra-highlighted lines
- string $styles: The style for extra-highlighted lines
Sets styles for important parts of the code
- string $styles: The styles to use on important parts of the code
Turns highlighting on/off for a keyword group
- int $key: The key of the keyword group to turn on or off
- boolean $flag: Whether to turn highlighting for that group on or off
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
- int $key: The key of the keyword group to change the styles of
- string $style: The style to make the keywords
- boolean $preserve_defaults: Whether to merge the new styles with the old or just to overwrite them
Sets the language for this object
- string $language: The name of the language to use
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.
- string $path: The path to the language directory
Sets the styles for the line numbers.
- string $style1: The style for the line numbers that are "normal"
- string|boolean $style2: 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
- boolean $preserve_defaults: If set, is the flag for whether to merge the "fancy" styles with the current styles or not
Sets styles for links in code
- int $type: A constant that specifies what state the style is being set for - e.g. :hover or :visited
- string $styles: The styles to use for that state
Sets the target for links in code
- string $target: The target for links in the code, e.g. _blank
Turns highlighting on/off for methods
- boolean $flag: Whether to turn highlighting for methods on or off
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
- int $key: The key of the object splitter to change the styles of
- string $style: The style to make the methods
- boolean $preserve_defaults: Whether to merge the new styles with the old or just to overwrite them
Turns highlighting on/off for numbers
- boolean $flag: Whether to turn highlighting for numbers on or off
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
- string $style: The style to make the numbers
- boolean $preserve_defaults: Whether to merge the new styles with the old or just to overwrite them
Sets the overall classname for this block of code. This class can then be used in a stylesheet to style this object's output
- string $class: The class name to use for this block of code
Sets the overall id for this block of code. This id can then be used in a stylesheet to style this object's output
- string $id: The ID to use for this block of code
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
- string $style: The overall style for the outputted code block
- boolean $preserve_defaults: Whether to merge the styles with the current styles or not
Turns highlighting on/off for regexps
- int $key: The key of the regular expression group to turn on or off
- boolean $flag: Whether to turn highlighting for the regular expression group on or off
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
- string $key: The style to make the regular expression matches
- boolean $style: Whether to merge the new styles with the old or just to overwrite them
- $preserve_defaults
Sets the source code for this object
- string $source: The source code to highlight
Turns highlighting on/off for strings
- boolean $flag: Whether to turn highlighting for strings on or off
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
- string $style: The style to make the escape characters
- boolean $preserve_defaults: Whether to merge the new styles with the old or just to overwrite them
Turns highlighting on/off for symbols
- boolean $flag: Whether to turn highlighting for symbols on or off
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
- string $style: The style to make the symbols
- boolean $preserve_defaults: Whether to merge the new styles with the old or just to overwrite them
Sets how many spaces a tab is substituted for
Widths below zero are ignored
- int $width: The tab width
Sets the base URL to be used for keywords
- int $group: The key of the keyword group to set the URL for
- string $url: 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
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.
- int $number: The number to start line numbers at
Documentation generated on Mon, 05 Mar 2007 21:05:07 +0000 by phpDocumentor 1.3.1