ILIAS
release_5-3 Revision v5.3.23-19-g915713cf615
|
Public Member Functions | |
__construct ($source='', $language='', $path='') | |
Creates a new GeSHi object, with source and language. More... | |
get_version () | |
Returns the version of GeSHi. More... | |
error () | |
Returns an error message associated with the last GeSHi operation, or false if no error has occurred. More... | |
get_language_name () | |
Gets a human-readable language name (thanks to Simon Patterson for the idea :)) More... | |
set_source ($source) | |
Sets the source code for this object. More... | |
strip_language_name ($language) | |
Clean up the language name to prevent malicious code injection. More... | |
set_language ($language, $force_reset=false) | |
Sets the language for this object. More... | |
set_language_path ($path) | |
Sets the path to the directory containing the language files. More... | |
get_supported_languages ($full_names=false) | |
Get supported langs or an associative array lang=>full_name. More... | |
get_language_fullname ($language) | |
Get full_name for a lang or false. More... | |
set_header_type ($type) | |
Sets the type of header to be used. More... | |
set_overall_style ($style, $preserve_defaults=false) | |
Sets the styles for the code that will be outputted when this object is parsed. More... | |
set_overall_class ($class) | |
Sets the overall classname for this block of code. More... | |
set_overall_id ($id) | |
Sets the overall id for this block of code. More... | |
enable_classes ($flag=true) | |
Sets whether CSS classes should be used to highlight the source. More... | |
set_code_style ($style, $preserve_defaults=false) | |
Sets the style for the actual code. More... | |
set_line_style ($style1, $style2='', $preserve_defaults=false) | |
Sets the styles for the line numbers. More... | |
enable_line_numbers ($flag, $nth_row=5) | |
Sets whether line numbers should be displayed. More... | |
enable_multiline_span ($flag) | |
Sets wether spans and other HTML markup generated by GeSHi can span over multiple lines or not. More... | |
get_multiline_span () | |
Get current setting for multiline spans, see GeSHi->enable_multiline_span(). More... | |
set_keyword_group_style ($key, $style, $preserve_defaults=false) | |
Sets the style for a keyword group. More... | |
set_keyword_group_highlighting ($key, $flag=true) | |
Turns highlighting on/off for a keyword group. More... | |
set_comments_style ($key, $style, $preserve_defaults=false) | |
Sets the styles for comment groups. More... | |
set_comments_highlighting ($key, $flag=true) | |
Turns highlighting on/off for comment groups. More... | |
set_escape_characters_style ($style, $preserve_defaults=false, $group=0) | |
Sets the styles for escaped characters. More... | |
set_escape_characters_highlighting ($flag=true) | |
Turns highlighting on/off for escaped characters. More... | |
set_brackets_style ($style, $preserve_defaults=false) | |
Sets the styles for brackets. More... | |
set_brackets_highlighting ($flag) | |
Turns highlighting on/off for brackets. More... | |
set_symbols_style ($style, $preserve_defaults=false, $group=0) | |
Sets the styles for symbols. More... | |
set_symbols_highlighting ($flag) | |
Turns highlighting on/off for symbols. More... | |
set_strings_style ($style, $preserve_defaults=false, $group=0) | |
Sets the styles for strings. More... | |
set_strings_highlighting ($flag) | |
Turns highlighting on/off for strings. More... | |
set_script_style ($style, $preserve_defaults=false, $group=0) | |
Sets the styles for strict code blocks. More... | |
set_numbers_style ($style, $preserve_defaults=false, $group=0) | |
Sets the styles for numbers. More... | |
set_numbers_highlighting ($flag) | |
Turns highlighting on/off for numbers. More... | |
set_methods_style ($key, $style, $preserve_defaults=false) | |
Sets the styles for methods. More... | |
set_methods_highlighting ($flag) | |
Turns highlighting on/off for methods. More... | |
set_regexps_style ($key, $style, $preserve_defaults=false) | |
Sets the styles for regexps. More... | |
set_regexps_highlighting ($key, $flag) | |
Turns highlighting on/off for regexps. More... | |
set_case_sensitivity ($key, $case) | |
Sets whether a set of keywords are checked for in a case sensitive manner. More... | |
set_case_keywords ($case) | |
Sets the case that keywords should use when found. More... | |
set_tab_width ($width) | |
Sets how many spaces a tab is substituted for. More... | |
set_use_language_tab_width ($use) | |
Sets whether or not to use tab-stop width specifed by language. More... | |
get_real_tab_width () | |
Returns the tab width to use, based on the current language and user preference. More... | |
enable_strict_mode ($mode=true) | |
Enables/disables strict highlighting. More... | |
disable_highlighting () | |
Disables all highlighting. More... | |
enable_highlighting ($flag=true) | |
Enables all highlighting. More... | |
load_from_file ($file_name, $lookup=array()) | |
Given a file name, this method loads its contents in, and attempts to set the language automatically. More... | |
add_keyword ($key, $word) | |
Adds a keyword to a keyword group for highlighting. More... | |
remove_keyword ($key, $word, $recompile=true) | |
Removes a keyword from a keyword group. More... | |
add_keyword_group ($key, $styles, $case_sensitive=true, $words=array()) | |
Creates a new keyword group. More... | |
remove_keyword_group ($key) | |
Removes a keyword group. More... | |
optimize_keyword_group ($key) | |
compile optimized regexp list for keyword group More... | |
set_header_content ($content) | |
Sets the content of the header block. More... | |
set_footer_content ($content) | |
Sets the content of the footer block. More... | |
set_header_content_style ($style) | |
Sets the style for the header content. More... | |
set_footer_content_style ($style) | |
Sets the style for the footer content. More... | |
enable_inner_code_block ($flag) | |
Sets whether to force a surrounding block around the highlighted code or not. More... | |
set_url_for_keyword_group ($group, $url) | |
Sets the base URL to be used for keywords. More... | |
set_link_styles ($type, $styles) | |
Sets styles for links in code. More... | |
set_link_target ($target) | |
Sets the target for links in code. More... | |
set_important_styles ($styles) | |
Sets styles for important parts of the code. More... | |
enable_important_blocks ($flag) | |
Sets whether context-important blocks are highlighted. More... | |
enable_ids ($flag=true) | |
Whether CSS IDs should be added to each line. More... | |
highlight_lines_extra ($lines, $style=null) | |
Specifies which lines to highlight extra. More... | |
set_highlight_lines_extra_style ($styles) | |
Sets the style for extra-highlighted lines. More... | |
set_line_ending ($line_ending) | |
Sets the line-ending. More... | |
start_line_numbers_at ($number) | |
Sets what number line numbers should start at. More... | |
set_encoding ($encoding) | |
Sets the encoding used for htmlspecialchars(), for international support. More... | |
enable_keyword_links ($enable=true) | |
Turns linking of keywords on or off. More... | |
parse_code () | |
Returns the code in $this->source, highlighted and surrounded by the nessecary HTML. More... | |
get_time () | |
Gets the time taken to parse the code. More... | |
get_stylesheet ($economy_mode=true) | |
Returns a stylesheet for the highlighted code. More... | |
Static Public Member Functions | |
static | get_language_name_from_extension ( $extension, $lookup=array()) |
Given a file extension, this method returns either a valid geshi language name, or the empty string if it couldn't be found. More... | |
Protected Member Functions | |
build_style_cache () | |
Setup caches needed for styling. More... | |
build_parse_cache () | |
Setup caches needed for parsing. More... | |
indent (&$result) | |
Swaps out spaces and tabs for HTML indentation. More... | |
change_case ($instr) | |
Changes the case of a keyword for those languages where a change is asked for. More... | |
handle_keyword_replace ($match) | |
Handles replacements of keywords to include markup and links if requested. More... | |
handle_regexps_callback ($matches) | |
handles regular expressions highlighting-definitions with callback functions More... | |
handle_multiline_regexps ($matches) | |
handles newlines in REGEXPS matches. More... | |
parse_non_string_part ($stuff_to_parse) | |
Takes a string that has no strings or comments in it, and highlights stuff like keywords, numbers and methods. More... | |
set_time ($start_time, $end_time) | |
Sets the time taken to parse the code. More... | |
merge_arrays () | |
Merges arrays recursively, overwriting values of the first array with values of later arrays. More... | |
load_language ($file_name) | |
Gets language information and stores it for later use. More... | |
finalise (&$parsed_code) | |
Takes the parsed code and various options, and creates the HTML surrounding it to make it look nice. More... | |
header () | |
Creates the header for the code block (with correct attributes) More... | |
footer () | |
Returns the footer for the code block. More... | |
replace_keywords ($instr) | |
Replaces certain keywords in the header and footer with certain configuration values. More... | |
hsc ($string, $quote_style=ENT_COMPAT) | |
Secure replacement for PHP built-in function htmlspecialchars(). More... | |
_genCSSName ($name) | |
Generate a CSS class name from a given string. More... | |
get_line_style ($line) | |
Get's the style that is used for the specified line. More... | |
optimize_regexp_list ($list, $regexp_delimiter='/') | |
this functions creates an optimized regular expression list of an array of strings. More... | |
_optimize_regexp_list_tokens_to_string (&$tokens, $recursed=false) | |
this function creates the appropriate regexp string of an token array you should not call this function directly, More... | |
GeSHi::__construct | ( | $source = '' , |
|
$language = '' , |
|||
$path = '' |
|||
) |
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() |
Definition at line 560 of file geshi.php.
References $language, $path, $source, set_language(), set_language_path(), and set_source().
|
protected |
Generate a CSS class name from a given string.
Prevents invalid CSS classes.
string | $name | Proposed class name |
Definition at line 4328 of file geshi.php.
References $name.
Referenced by get_stylesheet(), and header().
|
protected |
this function creates the appropriate regexp string of an token array you should not call this function directly,
array | $tokens | array of tokens |
bool | $recursed | to know wether we recursed or not |
Definition at line 4692 of file geshi.php.
References $language, $list, $path, and GESHI_HEADER_NONE.
Referenced by optimize_regexp_list().
GeSHi::add_keyword | ( | $key, | |
$word | |||
) |
GeSHi::add_keyword_group | ( | $key, | |
$styles, | |||
$case_sensitive = true , |
|||
$words = array() |
|||
) |
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 |
Definition at line 1621 of file geshi.php.
References $key, $styles, array, and optimize_keyword_group().
|
protected |
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.
Definition at line 1972 of file geshi.php.
References $i, $key, array, build_style_cache(), GESHI_NUMBER_BIN_PREFIX_0B, GESHI_NUMBER_BIN_PREFIX_PERCENT, GESHI_NUMBER_BIN_SUFFIX, GESHI_NUMBER_FLT_NONSCI, GESHI_NUMBER_FLT_NONSCI_F, GESHI_NUMBER_FLT_SCI_SHORT, GESHI_NUMBER_FLT_SCI_ZERO, GESHI_NUMBER_HEX_PREFIX, GESHI_NUMBER_HEX_PREFIX_DOLLAR, GESHI_NUMBER_HEX_SUFFIX, GESHI_NUMBER_INT_BASIC, GESHI_NUMBER_INT_CSTYLE, GESHI_NUMBER_OCT_PREFIX, GESHI_NUMBER_OCT_PREFIX_0O, GESHI_NUMBER_OCT_PREFIX_AT, GESHI_NUMBER_OCT_SUFFIX, hsc(), and optimize_keyword_group().
Referenced by parse_code().
|
protected |
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
Definition at line 1922 of file geshi.php.
References $i, array, GESHI_NUMBER_FLT_NONSCI, and GESHI_NUMBER_INT_BASIC.
Referenced by build_parse_cache(), and get_stylesheet().
|
protected |
Changes the case of a keyword for those languages where a change is asked for.
string | $instr | The keyword to change the case of |
Definition at line 3220 of file geshi.php.
References GESHI_CAPS_LOWER, and GESHI_CAPS_UPPER.
Referenced by handle_keyword_replace(), and parse_code().
GeSHi::disable_highlighting | ( | ) |
Disables all highlighting.
Definition at line 1407 of file geshi.php.
References enable_highlighting().
GeSHi::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
boolean | $flag | Whether to turn classes on or not |
GeSHi::enable_highlighting | ( | $flag = true | ) |
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.
boolean | $flag | A flag specifying whether to enable or disable all highlighting |
Definition at line 1421 of file geshi.php.
References $key, and enable_important_blocks().
Referenced by disable_highlighting(), and load_language().
GeSHi::enable_ids | ( | $flag = true | ) |
GeSHi::enable_important_blocks | ( | $flag | ) |
Sets whether context-important blocks are highlighted.
boolean | $flag | Tells whether to enable or disable highlighting of important blocks |
Definition at line 1796 of file geshi.php.
Referenced by enable_highlighting(), finalise(), and parse_code().
GeSHi::enable_inner_code_block | ( | $flag | ) |
GeSHi::enable_keyword_links | ( | $enable = true | ) |
GeSHi::enable_line_numbers | ( | $flag, | |
$nth_row = 5 |
|||
) |
Sets whether line numbers should be displayed.
Valid values for the first parameter are:
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 |
Definition at line 952 of file geshi.php.
References error(), GESHI_ERROR_INVALID_LINE_NUMBER_TYPE, GESHI_FANCY_LINE_NUMBERS, GESHI_NO_LINE_NUMBERS, and GESHI_NORMAL_LINE_NUMBERS.
GeSHi::enable_multiline_span | ( | $flag | ) |
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.
boolean | $flag | Wether multiline spans are allowed or not |
GeSHi::enable_strict_mode | ( | $mode = true | ) |
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 |
Definition at line 1394 of file geshi.php.
References GESHI_ALWAYS, GESHI_MAYBE, and GESHI_NEVER.
GeSHi::error | ( | ) |
Returns an error message associated with the last GeSHi operation, or false if no error has occurred.
Definition at line 588 of file geshi.php.
References array.
Referenced by enable_line_numbers(), get_language_fullname(), get_language_name(), get_stylesheet(), load_from_file(), parse_code(), set_header_type(), and set_language().
|
protected |
Takes the parsed code and various options, and creates the HTML surrounding it to make it look nice.
string | $parsed_code | The code already parsed (reference!) |
NOTE: memorypeak #1
NOTE: memorypeak #2
Definition at line 3827 of file geshi.php.
References $attributes, $code, $end, $i, $key, $line_style1, $line_style2, $n, array, enable_important_blocks(), footer(), GESHI_END_IMPORTANT, GESHI_FANCY_LINE_NUMBERS, GESHI_HEADER_PRE, GESHI_HEADER_PRE_TABLE, GESHI_HEADER_PRE_VALID, GESHI_NO_LINE_NUMBERS, GESHI_START_IMPORTANT, get_line_style(), header(), hsc(), and indent().
Referenced by parse_code().
|
protected |
Returns the footer for the code block.
Definition at line 4150 of file geshi.php.
References $footer_content, GESHI_HEADER_DIV, GESHI_HEADER_NONE, GESHI_HEADER_PRE, GESHI_HEADER_PRE_TABLE, GESHI_HEADER_PRE_VALID, GESHI_NO_LINE_NUMBERS, and replace_keywords().
Referenced by finalise().
GeSHi::get_language_fullname | ( | $language | ) |
Get full_name for a lang or false.
string | $language | short langname (html4strict for example) |
Definition at line 780 of file geshi.php.
References $data, $language, and error().
Referenced by get_supported_languages().
GeSHi::get_language_name | ( | ) |
Gets a human-readable language name (thanks to Simon Patterson for the idea :))
Definition at line 612 of file geshi.php.
References error(), and GESHI_ERROR_NO_SUCH_LANG.
|
static |
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 one |
Definition at line 1448 of file geshi.php.
|
protected |
Get's the style that is used for the specified line.
int | $line | The line number information is requested for |
Definition at line 4544 of file geshi.php.
References $highlight_extra_lines_style, and $style.
Referenced by finalise().
GeSHi::get_multiline_span | ( | ) |
Get current setting for multiline spans, see GeSHi->enable_multiline_span().
Definition at line 980 of file geshi.php.
References $allow_multiline_span.
GeSHi::get_real_tab_width | ( | ) |
Returns the tab width to use, based on the current language and user preference.
Definition at line 1377 of file geshi.php.
References $tab_width.
Referenced by indent().
GeSHi::get_stylesheet | ( | $economy_mode = true | ) |
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 |
Definition at line 4341 of file geshi.php.
References $key, $linestyle, $style, $styles, _genCSSName(), build_style_cache(), error(), GESHI_ACTIVE, GESHI_CLASS, GESHI_FANCY_LINE_NUMBERS, GESHI_HOVER, GESHI_LINK, GESHI_NO_LINE_NUMBERS, and GESHI_VISITED.
GeSHi::get_supported_languages | ( | $full_names = false | ) |
Get supported langs or an associative array lang=>full_name.
boolean | $full_names |
Definition at line 729 of file geshi.php.
References array, and get_language_fullname().
GeSHi::get_time | ( | ) |
Gets the time taken to parse the code.
Definition at line 3680 of file geshi.php.
References $time.
Referenced by replace_keywords().
GeSHi::get_version | ( | ) |
Returns the version of GeSHi.
Definition at line 576 of file geshi.php.
References GESHI_VERSION.
|
protected |
Handles replacements of keywords to include markup and links if requested.
string | $match | The keyword to add the Markup to |
Definition at line 3240 of file geshi.php.
References $_kw_replace_group, array, change_case(), and hsc().
|
protected |
handles newlines in REGEXPS matches.
Set the hmr* vars before calling this
array | $matches | the matches array |
Definition at line 3315 of file geshi.php.
References $_hmr_after, $_hmr_before, $_hmr_replace, and array.
|
protected |
handles regular expressions highlighting-definitions with callback functions
array | $matches | the matches array |
|
protected |
Creates the header for the code block (with correct attributes)
Definition at line 4071 of file geshi.php.
References $attributes, $header, $header_content, _genCSSName(), GESHI_HEADER_DIV, GESHI_HEADER_NONE, GESHI_HEADER_PRE, GESHI_HEADER_PRE_TABLE, GESHI_HEADER_PRE_VALID, GESHI_NO_LINE_NUMBERS, and replace_keywords().
Referenced by finalise().
GeSHi::highlight_lines_extra | ( | $lines, | |
$style = null |
|||
) |
Specifies which lines to highlight extra.
The extra style parameter was added in 1.0.7.21.
mixed | $lines | An array of line numbers to highlight, or just a line number on its own. |
string | $style | A string specifying the style to use for this line. If null is specified, the default style is used. If false is specified, the line will be removed from special highlighting |
Definition at line 1824 of file geshi.php.
References $style.
|
protected |
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.
http://www.gnu.org/copyleft/lgpl.html GNU Lesser General Public License
string | $string | string to be converted |
integer | $quote_style |
|
Definition at line 4289 of file geshi.php.
References array.
Referenced by build_parse_cache(), finalise(), handle_keyword_replace(), parse_code(), and parse_non_string_part().
|
protected |
Swaps out spaces and tabs for HTML indentation.
Not needed if the code is in a pre block...
string | $result | The source to indent (reference!) |
Replace tabs with the correct number of spaces
Definition at line 3121 of file geshi.php.
References $i, $key, $n, $result, $tab_width, GESHI_HEADER_PRE_TABLE, GESHI_NO_LINE_NUMBERS, and get_real_tab_width().
Referenced by finalise().
GeSHi::load_from_file | ( | $file_name, | |
$lookup = array() |
|||
) |
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' ... );
string | $file_name | The filename to load the source from |
array | $lookup | A lookup array to use instead of the default one |
Definition at line 1555 of file geshi.php.
References error(), GESHI_ERROR_FILE_NOT_READABLE, set_language(), and set_source().
|
protected |
Gets language information and stores it for later use.
string | $file_name | The filename of the language file you want to load |
Definition at line 3729 of file geshi.php.
References $key, $language_data, array, enable_highlighting(), GESHI_NEVER, and merge_arrays().
Referenced by set_language().
|
protected |
Merges arrays recursively, overwriting values of the first array with values of later arrays.
Definition at line 3689 of file geshi.php.
References $i, $key, and $ret.
Referenced by load_language().
GeSHi::optimize_keyword_group | ( | $key | ) |
compile optimized regexp list for keyword group
int | $key | The key of the keyword group to compile & optimize |
Definition at line 1664 of file geshi.php.
References $key, and optimize_regexp_list().
Referenced by add_keyword_group(), build_parse_cache(), and remove_keyword().
|
protected |
this functions creates an optimized regular expression list of an array of strings.
Example: $list = array('faa', 'foo', 'foobar'); => string 'f(aa|oo(bar)?)'
array | $list | array of (unquoted) strings |
string | $regexp_delimiter | your regular expression delimiter, |
Definition at line 4569 of file geshi.php.
References $i, $list, _optimize_regexp_list_tokens_to_string(), array, GESHI_MAX_PCRE_LENGTH, and GESHI_MAX_PCRE_SUBPATTERNS.
Referenced by optimize_keyword_group().
GeSHi::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
The value in $delimiters is expected to be an RegExp containing exactly 2 matching groups:
NOTE: memorypeak #3
Definition at line 2159 of file geshi.php.
References $allow_multiline_span, $attributes, $code, $comment, $i, $key, $result, array, build_parse_cache(), change_case(), enable_important_blocks(), error(), finalise(), GESHI_COMMENTS, GESHI_END_IMPORTANT, GESHI_ERROR_NO_SUCH_LANG, GESHI_MAYBE, GESHI_NO_LINE_NUMBERS, GESHI_START_IMPORTANT, hsc(), parse_non_string_part(), set_time(), and string.
|
protected |
Takes a string that has no strings or comments in it, and highlights stuff like keywords, numbers and methods.
string | $stuff_to_parse | The string to parse for keyword, numbers etc. |
Definition at line 3348 of file geshi.php.
References $attributes, $id, $key, $x, array, GESHI_AFTER, GESHI_BEFORE, GESHI_CLASS, GESHI_LINK, GESHI_MODIFIERS, GESHI_NO_LINE_NUMBERS, GESHI_REPLACE, GESHI_SEARCH, and hsc().
Referenced by parse_code().
GeSHi::remove_keyword | ( | $key, | |
$word, | |||
$recompile = true |
|||
) |
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 |
bool | $recompile | Wether to automatically recompile the optimized regexp list or not. Note: if you set this to false and |
Definition at line 1599 of file geshi.php.
References $key, and optimize_keyword_group().
GeSHi::remove_keyword_group | ( | $key | ) |
|
protected |
Replaces certain keywords in the header and footer with certain configuration values.
string | $instr | The header or footer content to do replacement on |
Definition at line 4205 of file geshi.php.
References $time, array, GESHI_VERSION, and get_time().
Referenced by footer(), and header().
GeSHi::set_brackets_highlighting | ( | $flag | ) |
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 |
Definition at line 1131 of file geshi.php.
Referenced by set_symbols_highlighting().
GeSHi::set_brackets_style | ( | $style, | |
$preserve_defaults = false |
|||
) |
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 |
Definition at line 1113 of file geshi.php.
References $style.
Referenced by set_symbols_style().
GeSHi::set_case_keywords | ( | $case | ) |
Sets the case that keywords should use when found.
Use the constants:
int | $case | A constant specifying what to do with matched keywords |
Definition at line 1335 of file geshi.php.
References array, GESHI_CAPS_LOWER, GESHI_CAPS_NO_CHANGE, and GESHI_CAPS_UPPER.
GeSHi::set_case_sensitivity | ( | $key, | |
$case | |||
) |
GeSHi::set_code_style | ( | $style, | |
$preserve_defaults = false |
|||
) |
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 |
Definition at line 898 of file geshi.php.
References $style.
GeSHi::set_comments_highlighting | ( | $key, | |
$flag = true |
|||
) |
GeSHi::set_comments_style | ( | $key, | |
$style, | |||
$preserve_defaults = false |
|||
) |
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 |
Definition at line 1041 of file geshi.php.
GeSHi::set_encoding | ( | $encoding | ) |
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.
string | $encoding | The encoding to use for the source |
Definition at line 1898 of file geshi.php.
References $encoding.
GeSHi::set_escape_characters_highlighting | ( | $flag = true | ) |
GeSHi::set_escape_characters_style | ( | $style, | |
$preserve_defaults = false , |
|||
$group = 0 |
|||
) |
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 |
int | $group | Tells the group of symbols for which style should be set. |
Definition at line 1081 of file geshi.php.
References $style.
GeSHi::set_footer_content | ( | $content | ) |
GeSHi::set_footer_content_style | ( | $style | ) |
GeSHi::set_header_content | ( | $content | ) |
GeSHi::set_header_content_style | ( | $style | ) |
GeSHi::set_header_type | ( | $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.
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 |
Definition at line 820 of file geshi.php.
References $type, array, error(), GESHI_ERROR_INVALID_HEADER_TYPE, GESHI_HEADER_DIV, GESHI_HEADER_NONE, GESHI_HEADER_PRE, GESHI_HEADER_PRE_TABLE, and GESHI_HEADER_PRE_VALID.
GeSHi::set_highlight_lines_extra_style | ( | $styles | ) |
GeSHi::set_important_styles | ( | $styles | ) |
GeSHi::set_keyword_group_highlighting | ( | $key, | |
$flag = true |
|||
) |
GeSHi::set_keyword_group_style | ( | $key, | |
$style, | |||
$preserve_defaults = false |
|||
) |
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 |
Definition at line 995 of file geshi.php.
GeSHi::set_language | ( | $language, | |
$force_reset = false |
|||
) |
Sets the language for this object.
string | $language | The name of the language to use |
bool | $force_reset |
Definition at line 653 of file geshi.php.
References $language, error(), GESHI_ERROR_NO_SUCH_LANG, GESHI_NEVER, load_language(), and strip_language_name().
Referenced by __construct(), load_from_file(), and set_language_path().
GeSHi::set_language_path | ( | $path | ) |
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 |
Definition at line 695 of file geshi.php.
References $path, and set_language().
Referenced by __construct().
GeSHi::set_line_ending | ( | $line_ending | ) |
Sets the line-ending.
string | $line_ending | The new line-ending |
Definition at line 1863 of file geshi.php.
References $line_ending, and string.
GeSHi::set_line_style | ( | $style1, | |
$style2 = '' , |
|||
$preserve_defaults = false |
|||
) |
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 |
Definition at line 918 of file geshi.php.
References $style2.
GeSHi::set_link_styles | ( | $type, | |
$styles | |||
) |
GeSHi::set_link_target | ( | $target | ) |
GeSHi::set_methods_highlighting | ( | $flag | ) |
GeSHi::set_methods_style | ( | $key, | |
$style, | |||
$preserve_defaults = false |
|||
) |
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 |
Definition at line 1265 of file geshi.php.
GeSHi::set_numbers_highlighting | ( | $flag | ) |
GeSHi::set_numbers_style | ( | $style, | |
$preserve_defaults = false , |
|||
$group = 0 |
|||
) |
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 |
int | $group | Tells the group of numbers for which style should be set. |
Definition at line 1234 of file geshi.php.
References $style.
GeSHi::set_overall_class | ( | $class | ) |
GeSHi::set_overall_id | ( | $id | ) |
GeSHi::set_overall_style | ( | $style, | |
$preserve_defaults = false |
|||
) |
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 |
Definition at line 841 of file geshi.php.
References $style.
GeSHi::set_regexps_highlighting | ( | $key, | |
$flag | |||
) |
GeSHi::set_regexps_style | ( | $key, | |
$style, | |||
$preserve_defaults = false |
|||
) |
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 |
bool | $preserve_defaults | Whether to merge the new styles with the old or just to overwrite them |
Definition at line 1295 of file geshi.php.
GeSHi::set_script_style | ( | $style, | |
$preserve_defaults = false , |
|||
$group = 0 |
|||
) |
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
string | $style | The style to make the script blocks |
boolean | $preserve_defaults | Whether to merge the new styles with the old or just to overwrite them |
int | $group | Tells the group of script blocks for which style should be set. |
Definition at line 1214 of file geshi.php.
References $style.
GeSHi::set_source | ( | $source | ) |
Sets the source code for this object.
string | $source | The source code to highlight |
Definition at line 625 of file geshi.php.
References $source, and array.
Referenced by __construct(), and load_from_file().
GeSHi::set_strings_highlighting | ( | $flag | ) |
GeSHi::set_strings_style | ( | $style, | |
$preserve_defaults = false , |
|||
$group = 0 |
|||
) |
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 |
int | $group | Tells the group of strings for which style should be set. |
Definition at line 1185 of file geshi.php.
References $style.
GeSHi::set_symbols_highlighting | ( | $flag | ) |
Turns highlighting on/off for symbols.
boolean | $flag | Whether to turn highlighting for symbols on or off |
Definition at line 1166 of file geshi.php.
References set_brackets_highlighting().
GeSHi::set_symbols_style | ( | $style, | |
$preserve_defaults = false , |
|||
$group = 0 |
|||
) |
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 |
int | $group | Tells the group of symbols for which style should be set. |
Definition at line 1146 of file geshi.php.
References $style, and set_brackets_style().
GeSHi::set_tab_width | ( | $width | ) |
Sets how many spaces a tab is substituted for.
Widths below zero are ignored
int | $width | The tab width |
|
protected |
Sets the time taken to parse the code.
string | $start_time | The time when parsing started as returned by |
string | $end_time | The time when parsing ended as returned by |
Definition at line 3668 of file geshi.php.
Referenced by parse_code().
GeSHi::set_url_for_keyword_group | ( | $group, | |
$url | |||
) |
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 |
Definition at line 1748 of file geshi.php.
References $url.
GeSHi::set_use_language_tab_width | ( | $use | ) |
GeSHi::start_line_numbers_at | ( | $number | ) |
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 |
GeSHi::strip_language_name | ( | $language | ) |
Clean up the language name to prevent malicious code injection.
string | $language | The name of the language to strip |
Definition at line 636 of file geshi.php.
References $language.
Referenced by set_language().
|
protected |
Definition at line 543 of file geshi.php.
Referenced by handle_multiline_regexps().
|
protected |
Definition at line 541 of file geshi.php.
Referenced by handle_multiline_regexps().
|
protected |
Definition at line 542 of file geshi.php.
Referenced by handle_multiline_regexps().
|
protected |
Definition at line 531 of file geshi.php.
Referenced by handle_keyword_replace().
|
protected |
Definition at line 462 of file geshi.php.
Referenced by get_multiline_span(), and parse_code().
|
protected |
|
protected |
Definition at line 493 of file geshi.php.
Referenced by set_encoding().
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Definition at line 393 of file geshi.php.
Referenced by get_line_style().
|
protected |
|
protected |
Definition at line 238 of file geshi.php.
Referenced by __construct(), _optimize_regexp_list_tokens_to_string(), get_language_fullname(), set_language(), and strip_language_name().
|
protected |
Definition at line 244 of file geshi.php.
Referenced by load_language().
|
protected |
|
protected |
|
protected |
Definition at line 401 of file geshi.php.
Referenced by set_line_ending().
|
protected |
|
protected |
Definition at line 437 of file geshi.php.
Referenced by finalise().
|
protected |
Definition at line 443 of file geshi.php.
Referenced by finalise().
|
protected |
|
protected |
Definition at line 232 of file geshi.php.
Referenced by __construct(), and set_source().
|
protected |
Definition at line 474 of file geshi.php.
Referenced by get_real_tab_width(), and indent().
|
protected |
|
protected |
Definition at line 315 of file geshi.php.
Referenced by get_time(), and replace_keywords().