Public Member Functions | |
| TextFormatter ($text=null, $formatter=null) | |
| Initialize a new text formatter instance. | |
| render () | |
| Return the formatted text. | |
Static Public Member Functions | |
| format ($text, $formatter=null) | |
| Formats text using the given formatter. | |
Public Attributes | |
| $default_formatter = 'auto' | |
| The default formatter. | |
Private Attributes | |
| $formatters | |
| List of all available formatters. | |
It provides 4 formatter methods to format the input text: textile, entities, specialchars and raw. The 'textile' formatter formats the text using the rich Textile formatting language. The 'entities' and 'specialchars' formatters escape HTML entities so that the result can safely be displayed in a web browser. The 'raw' formatter returns the unchanged input text (this is useful if the formatter type comes from a database column). Additionally, there's the 'auto' formatter that chooses between textile and raw, depending on the input looking like XHTML (using a very simple heuristic).
Definition at line 37 of file textformatter.lib.php.
| TextFormatter::format | ( | $ | text, | |
| $ | formatter = null | |||
| ) | [static] |
Formats text using the given formatter.
This method is useful if you don't want to instantiate a TextFormatter object. If you want to reuse the textformatter instance, don't use this method.
| $text | String with text to format | |
| $formatter | The name of the formatter to use (optional) |
Definition at line 55 of file textformatter.lib.php.
| TextFormatter::TextFormatter | ( | $ | text = null, |
|
| $ | formatter = null | |||
| ) |
Initialize a new text formatter instance.
Both the text and formatter parameters are optional and can be set later using the 'text' and 'formatter' container properties.
| $text | String with text to format (optional). | |
| $formatter | The name of the formatter to use (optional). |
Definition at line 89 of file textformatter.lib.php.
| TextFormatter::render | ( | ) |
Return the formatted text.
Simple heuristic for the automatic mode: check whether the first non-whitespace character is a < character. If so, assume it's already formatted as HTML and treat it as 'raw'. Otherwise, use textile. To improve speed, only the first 50 characters are considered.
Definition at line 105 of file textformatter.lib.php.
TextFormatter::$formatters [private] |
Initial value:
array(
'auto',
'entities',
'raw',
'specialchars',
'textile',
)
Definition at line 67 of file textformatter.lib.php.
1.5.9