Users' API.
More...
Static Public Member Functions |
static | __guess_language_cmp ($a, $b) |
static | cache_errors () |
| Returns a list of cache errors encountered during the most recent highlight.
|
static | formatter () |
| Gets a formatter instance.
|
static | guess_language ($src, $confidence=0.05, $default= 'plain') |
| Attempts to guess the language of a piece of source code.
|
static | guess_language_full ($src) |
| Attempts to guess the language of a piece of source code.
|
static | head_html () |
| Gets the markup you need to include in your web page.
|
static | highlight ($scanner, $source, $cache_or_settings=null) |
| Highlights a string according to the current settings.
|
static | highlight_file ($scanner, $file, $cache_or_settings=null) |
| Highlights a file according to the current setings.
|
static | register_scanner ($language_code, $classname, $readable_language, $path, $dependencies=null) |
| Registers a scanner.
|
static | root () |
| Get the full filesystem path to Luminous.
|
static | scanners () |
| Gets a list of registered scanners.
|
static | set ($option, $value=null) |
| Sets the given option to the given value.
|
static | setting ($option) |
| Gets a setting's value.
|
static | theme ($theme) |
| Reads a CSS theme file Gets the CSS-string content of a theme file. Use this function for reading themes as it involves security checks against reading arbitrary files.
|
static | theme_exists ($theme) |
| Checks whether a theme exists.
|
static | themes () |
| Gets a list of installed themes.
|
Detailed Description
Member Function Documentation
static luminous::__guess_language_cmp |
( |
|
$a, |
|
|
|
$b |
|
) |
| |
|
static |
static luminous::cache_errors |
( |
| ) |
|
|
static |
Returns a list of cache errors encountered during the most recent highlight.
- Returns
- An array of errors the cache encountered (which may be empty), or
FALSE
if the cache is not enabled
static luminous::formatter |
( |
| ) |
|
|
static |
Gets a formatter instance.
- Returns
- an instance of a LuminousFormatter according to the current format setting
This shouldn't be necessary for general usage, it is only implemented for testing.
static luminous::guess_language |
( |
|
$src, |
|
|
|
$confidence = 0.05 , |
|
|
|
$default = 'plain' |
|
) |
| |
|
static |
Attempts to guess the language of a piece of source code.
- Parameters
-
$src | The source code whose language is to be guessed |
$confidence | The desired confidence level: if this is 0.05 but the best guess has a confidence of 0.04, then $default is returned. Note that the confidence level returned by scanners is quite arbitrary, so don't set this to '1' thinking that'll give you better results. A realistic confidence is likely to be quite low, because a scanner will only return 1 if it's able to pick out a shebang (#!) line or something else definitive. If there exists no such identifier, a 'strong' confidence which is right most of the time might be as low as 0.1. Therefore it is recommended to keep this between 0.01 and 0.10. |
$default | The default name to return in the event that no scanner thinks this source belongs to them (at the desired confidence). |
- Returns
- A valid code for the best scanner, or $default.
This is a wrapper around luminous::guess_language_full
static luminous::guess_language_full |
( |
|
$src | ) |
|
|
static |
Attempts to guess the language of a piece of source code.
- Parameters
-
$src | The source code whose language is to be guessed |
- Returns
- An array - the array is ordered by probability, with the most probable language coming first in the array. Each array element is an array which represents a language (scanner), and has the keys:
'language'
=> Human-readable language description,
'codes'
=> valid codes for the language (array),
'p'
=> the probability (between 0.0 and 1.0 inclusive),
note that 'language'
and 'codes'
are the key => value pair from luminous::scanners()
- Warning
- Language guessing is inherently unreliable but should be right about 80% of the time on common languages. Bear in mind that guessing is going to be severely hampered in the case that one language is used to generate code in another language.
Usage for this function will be something like this:
- See Also
- luminous::guess_language
static luminous::head_html |
( |
| ) |
|
|
static |
Gets the markup you need to include in your web page.
- Returns
- a string representing everything that needs to be printed in the <head> section of a website.
This is influenced by the following settings: relative-root, include-javascript, include-jquery theme
static luminous::highlight |
( |
|
$scanner, |
|
|
|
$source, |
|
|
|
$cache_or_settings = null |
|
) |
| |
|
static |
Highlights a string according to the current settings.
- Parameters
-
$scanner | The scanner to use, this can either be a langauge code, or it can be an instance of LuminousScanner. |
$source | The source string |
$cache | Whether or not to use the cache |
- Returns
- the highlighted source code.
To specify different output formats or other options, see set().
static luminous::highlight_file |
( |
|
$scanner, |
|
|
|
$file, |
|
|
|
$cache_or_settings = null |
|
) |
| |
|
static |
Highlights a file according to the current setings.
- Parameters
-
$scanner | The scanner to use, this can either be a langauge code, or it can be an instance of LuminousScanner. |
$file | the source string |
$cache | Whether or not to use the cache |
- Returns
- the highlighted source code.
To specify different output formats or other options, see set().
static luminous::register_scanner |
( |
|
$language_code, |
|
|
|
$classname, |
|
|
|
$readable_language, |
|
|
|
$path, |
|
|
|
$dependencies = null |
|
) |
| |
|
static |
Registers a scanner.
Registers a scanner with Luminous's scanner table. Utilising this function means that Luminous will handle instantiation and inclusion of the scanner's source file in a lazy-manner.
- Parameters
-
$language_code | A string or array of strings designating the aliases by which this scanner may be accessed |
$classname | The class name of the scanner, as string. If you leave this as 'null', it will be treated as a dummy file (you can use this to handle a set of non-circular include rules, if you run into problems). |
$readable_language | A human readable language name |
$path | The path to the source file containing your scanner |
dependencies | An array of other scanners which this scanner depends on (as sub-scanners, or superclasses). Each item in the array should be a $language_code for another scanner. |
static luminous::root |
( |
| ) |
|
|
static |
Get the full filesystem path to Luminous.
- Returns
- what Luminous thinks its location is on the filesystem
static luminous::scanners |
( |
| ) |
|
|
static |
Gets a list of registered scanners.
- Returns
- a list of scanners currently registered. The list is in the format:
language_name => codes,
where language_name is a string, and codes is an array of strings.
The array is sorted alphabetically by key.
static luminous::set |
( |
|
$option, |
|
|
|
$value = null |
|
) |
| |
|
static |
Sets the given option to the given value.
- Parameters
-
$option | The name of the setting (corresponds to an attribute name in LuminousOptions) |
$value | The new value of the setting |
- Exceptions
-
Exception | if the option is unrecognised (and in various other validation failures), |
InvalidArgumentException | if the argument fails the type-validation check |
- Note
- This function can also accept multiple settings if $option is a map of option_name=>value
Options are stored in LuminousOptions, which provides documentation of each option.
- Note
- as of 0.7 this is a thin wrapper around LuminousOptions::set()
- See Also
- LuminousOptions::set
static luminous::setting |
( |
|
$option | ) |
|
|
static |
Gets a setting's value.
- Parameters
-
$option | The name of the setting (corresponds to an attribute name in LuminousOptions) |
- Returns
- The value of the given setting
- Exceptions
-
Exception | if the option is unrecognised |
Options are stored in LuminousOptions, which provides documentation of each option.
- See Also
- LuminousOptions
static luminous::theme |
( |
|
$theme | ) |
|
|
static |
Reads a CSS theme file Gets the CSS-string content of a theme file. Use this function for reading themes as it involves security checks against reading arbitrary files.
- Parameters
-
$theme | The name of the theme to retrieve, which may or may not include the .css suffix. |
- Returns
- the content of a theme; this is the actual CSS text.
static luminous::theme_exists |
( |
|
$theme | ) |
|
|
static |
Checks whether a theme exists.
- Parameters
-
$theme | the name of a theme, which should be suffixed with .css |
- Returns
TRUE
if a theme exists in style/, else FALSE
static luminous::themes |
( |
| ) |
|
|
static |
Gets a list of installed themes.
- Returns
- the list of theme files present in style/. Each theme will simply be a filename, and will end in .css, and will not have any directory prefix.
The documentation for this class was generated from the following file: