GeSHi


geshi.GeSHi
geshi.php at line 253

Class GeSHi

GeSHi

public class 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.

Author:
Nigel McNie , Benny Baumann
Copyright:
(C) 2004 - 2007 Nigel McNie, (C) 2007 - 2008 Benny Baumann

Field Summary
boolean

$add_ids

Whether CSS IDs should be added to the code

boolean

$allow_multiline_span

Flag to decide if multi line spans are allowed.

string

$code_style

The style for the actual code

boolean

$enable_important_blocks

Whether important blocks should be recognised or not

string

$encoding

The encoding to use for entity encoding NOTE: Used with Escape Char Sequences to fix UTF-8 handling (cf.

string

$error

The error message associated with an error

array

$error_messages

Possible error messages

string

$footer_content

The content of the footer block

string

$footer_content_style

The style of the footer block

boolean

$force_code_block

Tells if a block around the highlighted source should be forced if not using line numbering

string

$header_content

The content of the header block

string

$header_content_style

The style of the header block

int

$header_type

The type of header to use.

array

$highlight_extra_lines

Lines that should be highlighted extra

string

$highlight_extra_lines_style

Styles of extra-highlighted lines

array

$highlight_extra_lines_styles

Styles of lines that should be highlighted extra

string

$important_styles

Styles for important parts of the code

boolean

$keyword_links

Should keywords be linked?

string

$language

The language to use when highlighting

array

$language_data

The data for the language used

string

$language_path

The path to the language files

array

$lexic_permissions

Array of permissions for which lexics should be highlighted

string

$line_ending

The line ending If null, nl2br() will be used on the result string.

int

$line_nth_row

The "nth" value for fancy line highlighting

boolean

$line_numbers

Flag for how line numbers are displayed

int

$line_numbers_start

Number at which line numbers should start at

string

$line_style1

Line number styles

string

$line_style2

Line number styles for fancy lines

array

$link_styles

The styles for hyperlinks in the code

string

$link_target

Default target for keyword links

string

$loaded_language

Currently loaded language file

string

$overall_class

The overall class for this code block

string

$overall_id

The overall ID for this code block

string

$overall_style

The overall style for this code block

bool

$parse_cache_built

Wether the caches needed for parsing are built or not

boolean

$strict_mode

Whether highlighting is strict or not

int

$tab_width

The size of tab stops

string

$table_linenumber_style

Style for line numbers when GESHI_HEADER_PRE_TABLE is chosen

double

$time

The time it took to parse the code

boolean

$use_classes

Whether to use CSS classes in output

int

$use_language_tab_width

Should we use language-defined tab stop widths?

Constructor Summary

GeSHi(mixed source, mixed language, mixed path, string The)

Creates a new GeSHi object, with source and language

Method Summary
void

add_keyword(mixed key, mixed word, string The)

Adds a keyword to a keyword group for highlighting

void

add_keyword_group(mixed key, mixed styles, mixed case_sensitive, mixed words, array The, boolean Whether)

Creates a new keyword group

void

disable_highlighting()

Disables all highlighting

void

enable_classes(mixed flag, boolean Whether)

Sets whether CSS classes should be used to highlight the source.

void

enable_highlighting(mixed flag, boolean A)

Enables all highlightingThe optional flag parameter was added in version 1.0.7.21 and can be used to enable (true) or disable (false) all highlighting.

void

enable_ids(mixed flag, boolean If)

Whether CSS IDs should be added to each line

void

enable_important_blocks(mixed flag, boolean Tells)

Sets whether context-important blocks are highlighted

void

enable_inner_code_block(mixed flag, boolean Tells)

Sets whether to force a surrounding block around the highlighted code or not

void

enable_keyword_links(mixed enable, boolean If)

Turns linking of keywords on or off.

void

enable_line_numbers(mixed flag, mixed nth_row, int How, int Defines)

Sets whether line numbers should be displayed.

void

enable_multiline_span(mixed flag, boolean Wether)

Sets wether spans and other HTML markup generated by GeSHi can span over multiple lines or not.

void

enable_strict_mode(mixed mode, boolean Whether)

Enables/disables strict highlighting.

string|false

error()

Returns an error message associated with the last GeSHi operation, or false if no error has occured

string

get_language_name()

Gets a human-readable language name (thanks to Simon Patterson for the idea :))

void

get_language_name_from_extension(mixed extension, mixed lookup, string The, array A)

Given a file extension, this method returns either a valid geshi language name, or the empty string if it couldn't be found

bool

get_multiline_span()

Get current setting for multiline spans, see GeSHi->enable_multiline_span().

int

get_real_tab_width()

Returns the tab width to use, based on the current language and user preference

static string

get_stylesheet(mixed economy_mode, boolean Whether)

Returns a stylesheet for the highlighted code.

double

get_time()

Gets the time taken to parse the code

void

highlight_lines_extra(mixed lines, mixed style, mixed An, string A)

Specifies which lines to highlight extraThe extra style parameter was added in 1.0.7.21.

void

load_from_file(mixed file_name, mixed lookup, string The, array A)

Given a file name, this method loads its contents in, and attempts to set the language automatically.

void

optimize_keyword_group(mixed key, int The)

compile optimized regexp list for keyword group

static void

parse_code()

Returns the code in $this->source, highlighted and surrounded by the nessecary HTML.

void

remove_keyword(mixed key, mixed word, mixed recompile, string The, bool Wether)

Removes a keyword from a keyword group

void

remove_keyword_group(mixed key, int The)

Removes a keyword group

void

set_brackets_highlighting(mixed flag, boolean Whether)

Turns highlighting on/off for bracketsThis method is DEPRECATED: use set_symbols_highlighting instead.

void

set_brackets_style(mixed style, mixed preserve_defaults, string The, boolean Whether)

Sets the styles for brackets.

void

set_case_keywords(mixed case, int A)

Sets the case that keywords should use when found.

void

set_case_sensitivity(mixed key, mixed case, int The, boolean Whether)

Sets whether a set of keywords are checked for in a case sensitive manner

void

set_code_style(mixed style, mixed preserve_defaults, string The, boolean Whether)

Sets the style for the actual code.

void

set_comments_highlighting(mixed key, mixed flag, int The, boolean Whether)

Turns highlighting on/off for comment groups

void

set_comments_style(mixed key, mixed style, mixed preserve_defaults, string The, boolean Whether)

Sets the styles for comment groups.

void

set_encoding(mixed encoding, string The)

Sets the encoding used for htmlspecialchars(), for international support.

void

set_escape_characters_highlighting(mixed flag, boolean Whether)

Turns highlighting on/off for escaped characters

void

set_escape_characters_style(mixed style, mixed preserve_defaults, mixed group, string The, boolean Whether)

Sets the styles for escaped characters.

void

set_footer_content(mixed content, string The)

Sets the content of the footer block

void

set_footer_content_style(mixed style, string The)

Sets the style for the footer content

void

set_header_content(mixed content, string The)

Sets the content of the header block

void

set_header_content_style(mixed style, string The)

Sets the style for the header content

void

set_header_type(mixed type, int The)

Sets the type of header to be used.

void

set_highlight_lines_extra_style(mixed styles, string The)

Sets the style for extra-highlighted lines

void

set_important_styles(mixed styles, string The)

Sets styles for important parts of the code

void

set_keyword_group_highlighting(mixed key, mixed flag, int The, boolean Whether)

Turns highlighting on/off for a keyword group

void

set_keyword_group_style(mixed key, mixed style, mixed preserve_defaults, string The, boolean Whether)

Sets the style for a keyword group.

void

set_language(mixed language, mixed force_reset, string The)

Sets the language for this object

void

set_language_path(mixed path, string The)

Sets the path to the directory containing the language files.

void

set_line_ending(mixed line_ending, string The)

Sets the line-ending

void

set_line_style(mixed style1, mixed style2, mixed preserve_defaults, string The, boolean If)

Sets the styles for the line numbers.

void

set_link_styles(mixed type, mixed styles, int A, string The)

Sets styles for links in code

void

set_link_target(mixed target, string The)

Sets the target for links in code

void

set_methods_highlighting(mixed flag, boolean Whether)

Turns highlighting on/off for methods

void

set_methods_style(mixed key, mixed style, mixed preserve_defaults, string The, boolean Whether)

Sets the styles for methods.

void

set_numbers_highlighting(mixed flag, boolean Whether)

Turns highlighting on/off for numbers

void

set_numbers_style(mixed style, mixed preserve_defaults, string The, boolean Whether)

Sets the styles for numbers.

void

set_overall_class(mixed class, string The)

Sets the overall classname for this block of code.

void

set_overall_id(mixed id, string The)

Sets the overall id for this block of code.

void

set_overall_style(mixed style, mixed preserve_defaults, string The, boolean Whether)

Sets the styles for the code that will be outputted when this object is parsed.

void

set_regexps_highlighting(mixed key, mixed flag, int The, boolean Whether)

Turns highlighting on/off for regexps

void

set_regexps_style(mixed key, mixed style, mixed preserve_defaults, string The, boolean Whether)

Sets the styles for regexps.

void

set_source(mixed source, string The)

Sets the source code for this object

void

set_strings_highlighting(mixed flag, boolean Whether)

Turns highlighting on/off for strings

void

set_strings_style(mixed style, mixed preserve_defaults, string The, boolean Whether)

Sets the styles for strings.

void

set_symbols_highlighting(mixed flag, boolean Whether)

Turns highlighting on/off for symbols

void

set_symbols_style(mixed style, mixed preserve_defaults, mixed group, string The, boolean Whether, int Tells)

Sets the styles for symbols.

void

set_tab_width(mixed width, int The)

Sets how many spaces a tab is substituted forWidths below zero are ignored

void

set_url_for_keyword_group(mixed group, mixed url, string The)

Sets the base URL to be used for keywords

void

set_use_language_tab_width(mixed use, boolean Whether)

Sets whether or not to use tab-stop width specifed by language

void

start_line_numbers_at(mixed number, int The)

Sets what number line numbers should start at.

Field Detail

geshi.php at line 404

add_ids

public boolean $add_ids = false

Whether CSS IDs should be added to the code


geshi.php at line 491

allow_multiline_span

public boolean $allow_multiline_span = true

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.


geshi.php at line 448

code_style

public string $code_style = 'font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;'

The style for the actual code


geshi.php at line 389

enable_important_blocks

public boolean $enable_important_blocks = false

Whether important blocks should be recognised or not

Deprecated.
Todo:
REMOVE THIS FUNCTIONALITY!

geshi.php at line 522

encoding

public string $encoding = 'utf-8'

The encoding to use for entity encoding NOTE: Used with Escape Char Sequences to fix UTF-8 handling (cf. SF#2037598)


geshi.php at line 286

error

public string $error = false

The error message associated with an error

Todo:
check err reporting works

geshi.php at line 292

error_messages

public array $error_messages = array(...)

Possible error messages


geshi.php at line 356 public string $footer_content = ''

The content of the footer block


geshi.php at line 368 public string $footer_content_style = ''

The style of the footer block


geshi.php at line 375

force_code_block

public boolean $force_code_block = false

Tells if a block around the highlighted source should be forced if not using line numbering


geshi.php at line 350

header_content

public string $header_content = ''

The content of the header block


geshi.php at line 362

header_content_style

public string $header_content_style = ''

The style of the header block


geshi.php at line 321

header_type

public int $header_type = GESHI_HEADER_PRE

The type of header to use. Can be one of the following values:

- GESHI_HEADER_PRE: Source is outputted in a "pre" HTML element. - GESHI_HEADER_DIV: Source is outputted in a "div" HTML element. - GESHI_HEADER_NONE: No header is outputted.


geshi.php at line 410

highlight_extra_lines

public array $highlight_extra_lines = array()

Lines that should be highlighted extra


geshi.php at line 422

highlight_extra_lines_style

public string $highlight_extra_lines_style = 'background-color: #ffc;'

Styles of extra-highlighted lines


geshi.php at line 416

highlight_extra_lines_styles

public array $highlight_extra_lines_styles = array()

Styles of lines that should be highlighted extra


geshi.php at line 398

important_styles

public string $important_styles = 'font-weight: bold; color: red;'

Styles for important parts of the code

Deprecated.
Todo:
As above - rethink the whole idea of important blocks as it is buggy and will be hard to implement in 1.2

geshi.php at line 528 public boolean $keyword_links = true

Should keywords be linked?


geshi.php at line 267

language

public string $language = ''

The language to use when highlighting


geshi.php at line 273

language_data

public array $language_data = array()

The data for the language used


geshi.php at line 279

language_path

public string $language_path = GESHI_LANG_ROOT

The path to the language files


geshi.php at line 327

lexic_permissions

public array $lexic_permissions = array(...)

Array of permissions for which lexics should be highlighted


geshi.php at line 430

line_ending

public string $line_ending = null

The line ending If null, nl2br() will be used on the result string. Otherwise, all instances of \n will be replaced with $line_ending


geshi.php at line 497

line_nth_row

public int $line_nth_row

The "nth" value for fancy line highlighting


geshi.php at line 484

line_numbers

public boolean $line_numbers = GESHI_NO_LINE_NUMBERS

Flag for how line numbers are displayed


geshi.php at line 436

line_numbers_start

public int $line_numbers_start = 1

Number at which line numbers should start at


geshi.php at line 466

line_style1

public string $line_style1 = 'font-weight: normal; vertical-align:top;'

Line number styles


geshi.php at line 472

line_style2

public string $line_style2 = 'font-weight: bold; vertical-align:top;'

Line number styles for fancy lines


geshi.php at line 381 public array $link_styles = array()

The styles for hyperlinks in the code


geshi.php at line 515 public string $link_target = ''

Default target for keyword links


geshi.php at line 535

loaded_language

public string $loaded_language = ''

Currently loaded language file

Since:
1.0.7.22

geshi.php at line 454

overall_class

public string $overall_class = ''

The overall class for this code block


geshi.php at line 460

overall_id

public string $overall_id = ''

The overall ID for this code block


geshi.php at line 442

overall_style

public string $overall_style = 'font-family:monospace;'

The overall style for this code block


geshi.php at line 543

parse_cache_built

public bool $parse_cache_built = false

Wether the caches needed for parsing are built or not

Since:
1.0.8

geshi.php at line 303

strict_mode

public boolean $strict_mode = false

Whether highlighting is strict or not


geshi.php at line 503

tab_width

public int $tab_width = 8

The size of tab stops


geshi.php at line 478

table_linenumber_style

public string $table_linenumber_style = 'width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;'

Style for line numbers when GESHI_HEADER_PRE_TABLE is chosen


geshi.php at line 344

time

public double $time

The time it took to parse the code


geshi.php at line 309

use_classes

public boolean $use_classes = false

Whether to use CSS classes in output


geshi.php at line 509

use_language_tab_width

public int $use_language_tab_width = false

Should we use language-defined tab stop widths?


Constructor Detail

geshi.php at line 591

GeSHi

public GeSHi(mixed source, mixed language, mixed path, string The)

Creates a new GeSHi object, with source and language

Parameters:
The - source code to highlight
The - language to highlight the source with
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 {@link GeSHi->set_language_path()}
Since:
1.0.0

Method Detail

geshi.php at line 1441

add_keyword

public void add_keyword(mixed key, mixed word, string The)

Adds a keyword to a keyword group for highlighting

Parameters:
The - key of the keyword group to add the keyword to
The - word to add to the keyword group
Since:
1.0.0

geshi.php at line 1487

add_keyword_group

public void add_keyword_group(mixed key, mixed styles, mixed case_sensitive, mixed words, array The, boolean Whether)

Creates a new keyword group

Parameters:
The - key of the keyword group to create
The - styles for the keyword group
Whether - the keyword group is case sensitive ornot
The - words to use for the keyword group
Since:
1.0.0

geshi.php at line 1288

disable_highlighting

public void disable_highlighting()

Disables all highlighting

Since:
1.0.0
Todo:
Rewrite with array traversal
Deprecated:
In favour of enable_highlighting

geshi.php at line 805

enable_classes

public void enable_classes(mixed flag, boolean Whether)

Sets whether CSS classes should be used to highlight the source. Default is off, calling this method with no arguments will turn it on

Parameters:
Whether - to turn classes on or not
Since:
1.0.0

geshi.php at line 1302

enable_highlighting

public void enable_highlighting(mixed flag, boolean A)

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.

Since:
1.0.0
Parameters:
A - flag specifying whether to enable or disable all highlighting
Todo:
Rewrite with array traversal

geshi.php at line 1671

enable_ids

public void enable_ids(mixed flag, boolean If)

Whether CSS IDs should be added to each line

Parameters:
If - true, IDs will be added to each line.
Since:
1.0.2

geshi.php at line 1661

enable_important_blocks

public void enable_important_blocks(mixed flag, boolean Tells)

Sets whether context-important blocks are highlighted

Parameters:
Tells - whether to enable or disable highlighting of important blocks
Todo:
REMOVE THIS SHIZ FROM GESHI!
Deprecated.
Since:
1.0.2

geshi.php at line 1600

enable_inner_code_block

public void enable_inner_code_block(mixed flag, boolean Tells)

Sets whether to force a surrounding block around the highlighted code or not

Parameters:
Tells - whether to enable or disable this feature
Since:
1.0.7.20

geshi.php at line 1775

enable_keyword_links

public void enable_keyword_links(mixed enable, boolean If)

Turns linking of keywords on or off.

Parameters:
If - true, links will be added to keywords
Since:
1.0.2

geshi.php at line 878

enable_line_numbers

public void enable_line_numbers(mixed flag, mixed nth_row, int How, int Defines)

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.

Parameters:
How - line numbers should be displayed
Defines - which lines are fancy
Since:
1.0.0

geshi.php at line 896

enable_multiline_span

public void enable_multiline_span(mixed flag, boolean Wether)

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.

Parameters:
Wether - multiline spans are allowed or not
Since:
1.0.7.22

geshi.php at line 1275

enable_strict_mode

public void enable_strict_mode(mixed mode, boolean Whether)

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.

Parameters:
Whether - to enable strict mode or not
Since:
1.0.0

geshi.php at line 608

error

public string|false error()

Returns an error message associated with the last GeSHi operation, or false if no error has occured

Returns:
An error message if there has been an error, else false
Since:
1.0.0

geshi.php at line 632

get_language_name

public string get_language_name()

Gets a human-readable language name (thanks to Simon Patterson for the idea :))

Returns:
The name for the current language
Since:
1.0.2

geshi.php at line 1329

get_language_name_from_extension

public void get_language_name_from_extension(mixed extension, mixed lookup, string The, array A)

Given a file extension, this method returns either a valid geshi language name, or the empty string if it couldn't be found

Parameters:
The - extension to get a language name for
A - lookup array to use instead of the default one
Since:
1.0.5
Todo:
Re-think about how this method works (maybe make it private and/or make it a extension->lang lookup?)
static?

geshi.php at line 906

get_multiline_span

public bool get_multiline_span()

Get current setting for multiline spans, see GeSHi->enable_multiline_span().

See Also:
enable_multiline_span

geshi.php at line 1258

get_real_tab_width

public int get_real_tab_width()

Returns the tab width to use, based on the current language and user preference

Returns:
Tab width
Since:
1.0.7.20

geshi.php at line 4202

get_stylesheet

public static string get_stylesheet(mixed economy_mode, boolean Whether)

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

Parameters:
Whether - to use economy mode or not
Returns:
A stylesheet built on the data for the current language
Since:
1.0.0

geshi.php at line 3543

get_time

public double get_time()

Gets the time taken to parse the code

Returns:
The time taken to parse the code
Since:
1.0.2

geshi.php at line 1689

highlight_lines_extra

public void highlight_lines_extra(mixed lines, mixed style, mixed An, string A)

Specifies which lines to highlight extra

The extra style parameter was added in 1.0.7.21.

Parameters:
An - array of line numbers to highlight, or just a line number on its own.
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
Since:
1.0.2
Todo:
Some data replication here that could be cut down on

geshi.php at line 1425

load_from_file

public void load_from_file(mixed file_name, mixed lookup, string The, array A)

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' ...
);

Parameters:
The - filename to load the source from
A - lookup array to use instead of the default one
Todo:
Complete rethink of this and above method
Since:
1.0.5

geshi.php at line 1529

optimize_keyword_group

public void optimize_keyword_group(mixed key, int The)

compile optimized regexp list for keyword group

Parameters:
The - key of the keyword group to compile & optimize
Since:
1.0.8

geshi.php at line 2011

parse_code

public static void 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

Since:
1.0.0

geshi.php at line 1466

remove_keyword

public void remove_keyword(mixed key, mixed word, mixed recompile, string The, bool Wether)

Removes a keyword from a keyword group

Parameters:
The - key of the keyword group to remove the keyword from
The - word to remove from the keyword group
Wether - to automatically recompile the optimized regexp list or not. Note: if you set this to false and @see GeSHi->parse_code() was already called once, for the current language, you have to manually call @see GeSHi->optimize_keyword_group() or the removed keyword will stay in cache and still be highlighted! On the other hand it might be too expensive to recompile the regexp list for every removal if you want to remove a lot of keywords.
Since:
1.0.0

geshi.php at line 1512

remove_keyword_group

public void remove_keyword_group(mixed key, int The)

Removes a keyword group

Parameters:
The - key of the keyword group to remove
Since:
1.0.0

geshi.php at line 1036

set_brackets_highlighting

public void set_brackets_highlighting(mixed flag, boolean Whether)

Turns highlighting on/off for brackets

This method is DEPRECATED: use set_symbols_highlighting instead. This method will be remove in 1.2.X

Parameters:
Whether - to turn highlighting for brackets on or off
Since:
1.0.0
Deprecated:
In favour of set_symbols_highlighting

geshi.php at line 1018

set_brackets_style

public void set_brackets_style(mixed style, mixed preserve_defaults, string The, boolean Whether)

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

Parameters:
The - style to make the brackets
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

geshi.php at line 1216

set_case_keywords

public void set_case_keywords(mixed case, int A)

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

Parameters:
A - constant specifying what to do with matched keywords
Since:
1.0.1

geshi.php at line 1202

set_case_sensitivity

public void set_case_sensitivity(mixed key, mixed case, int The, boolean Whether)

Sets whether a set of keywords are checked for in a case sensitive manner

Parameters:
The - key of the keyword group to change the case sensitivity of
Whether - to check in a case sensitive manner or not
Since:
1.0.0

geshi.php at line 824

set_code_style

public void set_code_style(mixed style, mixed preserve_defaults, string The, boolean Whether)

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.

Parameters:
The - style to use for actual code
Whether - to merge the current styles with the new styles
Since:
1.0.2

geshi.php at line 972

set_comments_highlighting

public void set_comments_highlighting(mixed key, mixed flag, int The, boolean Whether)

Turns highlighting on/off for comment groups

Parameters:
The - key of the comment group to turn on or off
Whether - to turn highlighting for that group on or off
Since:
1.0.0

geshi.php at line 957

set_comments_style

public void set_comments_style(mixed key, mixed style, mixed preserve_defaults, string The, boolean Whether)

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

Parameters:
The - key of the comment group to change the styles of
The - style to make the comments
Whether - to merge the new styles with the old or just to overwrite them
Since:
1.0.0

geshi.php at line 1763

set_encoding

public void set_encoding(mixed encoding, string The)

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.

Parameters:
The - encoding to use for the source
Since:
1.0.3

geshi.php at line 1000

set_escape_characters_highlighting

public void set_escape_characters_highlighting(mixed flag, boolean Whether)

Turns highlighting on/off for escaped characters

Parameters:
Whether - to turn highlighting for escape characters on or off
Since:
1.0.0

geshi.php at line 986

set_escape_characters_style

public void set_escape_characters_style(mixed style, mixed preserve_defaults, mixed group, string The, boolean Whether)

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

Parameters:
The - style to make the escape characters
Whether - to merge the new styles with the old or just to overwrite them
Since:
1.0.0

geshi.php at line 1569 public void set_footer_content(mixed content, string The)

Sets the content of the footer block

Parameters:
The - content of the footer block
Since:
1.0.2

geshi.php at line 1589 public void set_footer_content_style(mixed style, string The)

Sets the style for the footer content

Parameters:
The - style for the footer content
Since:
1.0.2

geshi.php at line 1559

set_header_content

public void set_header_content(mixed content, string The)

Sets the content of the header block

Parameters:
The - content of the header block
Since:
1.0.2

geshi.php at line 1579

set_header_content_style

public void set_header_content_style(mixed style, string The)

Sets the style for the header content

Parameters:
The - style for the header content
Since:
1.0.2

geshi.php at line 746

set_header_type

public void set_header_type(mixed type, int The)

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.

Parameters:
The - type of header to be used
Since:
1.0.0

geshi.php at line 1718

set_highlight_lines_extra_style

public void set_highlight_lines_extra_style(mixed styles, string The)

Sets the style for extra-highlighted lines

Parameters:
The - style for extra-highlighted lines
Since:
1.0.2

geshi.php at line 1649

set_important_styles

public void set_important_styles(mixed styles, string The)

Sets styles for important parts of the code

Parameters:
The - styles to use on important parts of the code
Since:
1.0.2

geshi.php at line 942

set_keyword_group_highlighting

public void set_keyword_group_highlighting(mixed key, mixed flag, int The, boolean Whether)

Turns highlighting on/off for a keyword group

Parameters:
The - key of the keyword group to turn on or off
Whether - to turn highlighting for that group on or off
Since:
1.0.0

geshi.php at line 921

set_keyword_group_style

public void set_keyword_group_style(mixed key, mixed style, mixed preserve_defaults, string The, boolean Whether)

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

Parameters:
The - key of the keyword group to change the styles of
The - style to make the keywords
Whether - to merge the new styles with the old or just to overwrite them
Since:
1.0.0

geshi.php at line 659

set_language

public void set_language(mixed language, mixed force_reset, string The)

Sets the language for this object

Note:
since 1.0.8 this function won't reset language-settings by default anymore! if you need this set $force_reset = true
Parameters:
The - name of the language to use
Since:
1.0.0

geshi.php at line 703

set_language_path

public void set_language_path(mixed path, string The)

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.

Parameters:
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.

geshi.php at line 1728

set_line_ending

public void set_line_ending(mixed line_ending, string The)

Sets the line-ending

Parameters:
The - new line-ending
Since:
1.0.2

geshi.php at line 844

set_line_style

public void set_line_style(mixed style1, mixed style2, mixed preserve_defaults, string The, boolean If)

Sets the styles for the line numbers.

Parameters:
The - style for the line numbers that are "normal"
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
If - set, is the flag for whether to merge the "fancy" styles with the current styles or not
Since:
1.0.2

geshi.php at line 1625 public void set_link_styles(mixed type, mixed styles, int A, string The)

Sets styles for links in code

Parameters:
A - constant that specifies what state the style is being set for - e.g. :hover or :visited
The - styles to use for that state
Since:
1.0.2

geshi.php at line 1635 public void set_link_target(mixed target, string The)

Sets the target for links in code

Parameters:
The - target for links in the code, e.g. _blank
Since:
1.0.3

geshi.php at line 1162

set_methods_highlighting

public void set_methods_highlighting(mixed flag, boolean Whether)

Turns highlighting on/off for methods

Parameters:
Whether - to turn highlighting for methods on or off
Since:
1.0.0

geshi.php at line 1148

set_methods_style

public void set_methods_style(mixed key, mixed style, mixed preserve_defaults, string The, boolean Whether)

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

Parameters:
The - key of the object splitter to change the styles of
The - style to make the methods
Whether - to merge the new styles with the old or just to overwrite them
Since:
1.0.0

geshi.php at line 1131

set_numbers_highlighting

public void set_numbers_highlighting(mixed flag, boolean Whether)

Turns highlighting on/off for numbers

Parameters:
Whether - to turn highlighting for numbers on or off
Since:
1.0.0

geshi.php at line 1117

set_numbers_style

public void set_numbers_style(mixed style, mixed preserve_defaults, string The, boolean Whether)

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

Parameters:
The - style to make the numbers
Whether - to merge the new styles with the old or just to overwrite them
Since:
1.0.0

geshi.php at line 783

set_overall_class

public void set_overall_class(mixed class, string The)

Sets the overall classname for this block of code. This class can then be used in a stylesheet to style this object's output

Parameters:
The - class name to use for this block of code
Since:
1.0.0

geshi.php at line 794

set_overall_id

public void set_overall_id(mixed id, string The)

Sets the overall id for this block of code. This id can then be used in a stylesheet to style this object's output

Parameters:
The - ID to use for this block of code
Since:
1.0.0

geshi.php at line 767

set_overall_style

public void set_overall_style(mixed style, mixed preserve_defaults, string The, boolean Whether)

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

Parameters:
The - overall style for the outputted code block
Whether - to merge the styles with the current styles or not
Since:
1.0.0

geshi.php at line 1191

set_regexps_highlighting

public void set_regexps_highlighting(mixed key, mixed flag, int The, boolean Whether)

Turns highlighting on/off for regexps

Parameters:
The - key of the regular expression group to turn on or off
Whether - to turn highlighting for the regular expression group on or off
Since:
1.0.0

geshi.php at line 1176

set_regexps_style

public void set_regexps_style(mixed key, mixed style, mixed preserve_defaults, string The, boolean Whether)

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

Parameters:
The - style to make the regular expression matches
Whether - to merge the new styles with the old or just to overwrite them
Since:
1.0.0

geshi.php at line 645

set_source

public void set_source(mixed source, string The)

Sets the source code for this object

Parameters:
The - source code to highlight
Since:
1.0.0

geshi.php at line 1103

set_strings_highlighting

public void set_strings_highlighting(mixed flag, boolean Whether)

Turns highlighting on/off for strings

Parameters:
Whether - to turn highlighting for strings on or off
Since:
1.0.0

geshi.php at line 1089

set_strings_style

public void set_strings_style(mixed style, mixed preserve_defaults, string The, boolean Whether)

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

Parameters:
The - style to make the escape characters
Whether - to merge the new styles with the old or just to overwrite them
Since:
1.0.0

geshi.php at line 1071

set_symbols_highlighting

public void set_symbols_highlighting(mixed flag, boolean Whether)

Turns highlighting on/off for symbols

Parameters:
Whether - to turn highlighting for symbols on or off
Since:
1.0.0

geshi.php at line 1051

set_symbols_style

public void set_symbols_style(mixed style, mixed preserve_defaults, mixed group, string The, boolean Whether, int Tells)

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

Parameters:
The - style to make the symbols
Whether - to merge the new styles with the old or just to overwrite them
Tells - the group of symbols for which style should be set.
Since:
1.0.1

geshi.php at line 1231

set_tab_width

public void set_tab_width(mixed width, int The)

Sets how many spaces a tab is substituted for

Widths below zero are ignored

Parameters:
The - tab width
Since:
1.0.0

geshi.php at line 1613

set_url_for_keyword_group

public void set_url_for_keyword_group(mixed group, mixed url, string The)

Sets the base URL to be used for keywords

Parameters:
The - key of the keyword group to set the URL for
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

geshi.php at line 1247

set_use_language_tab_width

public void set_use_language_tab_width(mixed use, boolean Whether)

Sets whether or not to use tab-stop width specifed by language

Parameters:
Whether - to use language-specific tab-stop widths
Since:
1.0.7.20

geshi.php at line 1747

start_line_numbers_at

public void start_line_numbers_at(mixed number, int The)

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.

Parameters:
The - number to start line numbers at
Since:
1.0.2

GeSHi