\Text_Wiki_Parse_List

Parses for bulleted and numbered lists.

This class implements a Text_Wiki_Parse to find source text marked as a bulleted or numbered list. In short, if a line starts with ' ' then it is a bullet list item; if a line starts with '# ' then it is a number list item. Spaces in front of the or # indicate an indented sub-list. The list items must be on sequential lines, and may be separated by blank lines to improve readability. Using a non-* non-# non-whitespace character at the beginning of a line ends the list.

Summary

Methods
Properties
Constants
__construct()
parse()
process()
getConf()
getAttrs()
$conf
$regex
$rule
$wiki
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$conf

$conf : string

Configuration options for this parser rule.

Type

string

$regex

$regex : string

The regular expression used to parse the source text and find matches conforming to this rule. Used by the parse() method.

Type

string

$rule

$rule : string

The name of this rule for new token array elements.

Type

string

$wiki

$wiki : object

A reference to the calling Text_Wiki object.

This is needed so that each rule has access to the same source text, token set, URLs, interwiki maps, page names, etc.

Type

object

Methods

__construct()

__construct(  $obj) 

Constructor for this parser rule.

Parameters

$obj

parse()

parse() 

Abstrct method to parse source text for matches.

Applies the rule's regular expression to the source text, passes every match to the process() method, and replaces the matched text with the results of the processing.

process()

process(array  $matches) : \A

Generates a replacement for the matched text. Token options are:

'type' => 'bullet_start' : the start of a bullet list 'bullet_end' : the end of a bullet list 'number_start' : the start of a number list 'number_end' : the end of a number list 'item_start' : the start of item text (bullet or number) 'item_end' : the end of item text (bullet or number) 'unknown' : unknown type of list or item

'level' => the indent level (0 for the first level, 1 for the second, etc)

'count' => the list item number at this level. not needed for xhtml, but very useful for PDF and RTF.

Parameters

array $matches

An array of matches from the parse() method as generated by preg_replace_callback. $matches[0] is the full matched string, $matches[1] is the first matched pattern, $matches[2] is the second matched pattern, and so on.

Returns

\A —

series of text and delimited tokens marking the different list text and list elements.

getConf()

getConf(string  $key, mixed  $default = null) : mixed

Simple method to safely get configuration key values.

Parameters

string $key

The configuration key.

mixed $default

If the key does not exist, return this value instead.

Returns

mixed —

The configuration key value (if it exists) or the default value (if not).

getAttrs()

getAttrs(string  $text) : array

Extract 'attribute="value"' portions of wiki markup.

This kind of markup is typically used only in macros, but is useful anywhere.

The syntax is pretty strict; there can be no spaces between the option name, the equals, and the first double-quote; the value must be surrounded by double-quotes. You can escape characters in the value with a backslash, and the backslash will be stripped for you.

Parameters

string $text

The "attributes" portion of markup.

Returns

array —

An associative array of key-value pairs where the key is the option name and the value is the option value.