Source for file Parse.php
Documentation is available at Parse.php
* Baseline rule class for extension into a "real" parser component.
* Text_Wiki_Rule classes do not stand on their own; they are called by a
* Text_Wiki object, typcially in the transform()method. Each rule class
* performs three main activities: parse, process, and render.
* The parse() method takes a regex and applies it to the whole block of
* source text at one time. Each match is sent as $matches to the
* The process() method acts on the matched text from the source, and
* then processes the source text is some way. This may mean the
* creation of a delimited token using addToken(). In every case, the
* process() method returns the text that should replace the matched text
* @author Paul M. Jones <pmjones@ciaweb.net>
* $Id: Parse.php,v 1.2 2004/09/25 19:05:13 pmjones Exp $
* Configuration options for this parser rule.
* Regular expression to find matching text for this rule.
* The name of this rule for new token array elements.
* 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.
* Constructor for this parser rule.
* @param object &$obj The calling "parent" Text_Wiki object.
// set the reference to the calling Text_Wiki object;
// this allows us access to the shared source text, token
// set the name of this rule; generally used when adding
// to the tokens array. strip off the Text_Wiki_Parse_ portion.
// override config options for the rule if specified
if (isset ($this->wiki->parseConf [$this->rule]) &&
* 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.
* @see Text_Wiki_Parse::process()
array (&$this, 'process'),
* Abstract method to generate replacements for matched text.
* @param 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.
* @return string The processed text replacement; defaults to the
* full matched string (i.e., no changes to the text).
* @see Text_Wiki_Parse::parse()
* Simple method to safely get configuration key values.
* @param string $key The configuration key.
* @param mixed $default If the key does not exist, return this value
* @return mixed The configuration key value (if it exists) or the
* default value (if not).
function getConf($key, $default = null )
if (isset ($this->conf[$key])) {
return $this->conf[$key];
* Extract 'attribute="value"' portions of wiki markup.
* This kind of markup is typically used only in macros, but is useful
* 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
* @param string $text The "attributes" portion of markup.
* @return array An associative array of key-value pairs where the
* key is the option name and the value is the option value.
// loop through the sections
foreach ($tmp as $i => $val) {
// first element is always the first key
// find the last double-quote in the value.
// the part to the left is the value for the last key,
// the part to the right is the next key name
Documentation generated on Mon, 11 Mar 2019 14:22:33 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|