1
|
1 |
<?php
|
|
2 |
|
|
3 |
/**
|
|
4 |
*
|
|
5 |
* Parses for Text_Wiki delimiter characters already in the source text.
|
|
6 |
*
|
|
7 |
* @category Text
|
|
8 |
*
|
|
9 |
* @package Text_Wiki
|
|
10 |
*
|
|
11 |
* @author Paul M. Jones <pmjones@php.net>
|
|
12 |
*
|
|
13 |
* @license LGPL
|
|
14 |
*
|
|
15 |
* @version $Id: Delimiter.php,v 1.3 2005/02/23 17:38:29 pmjones Exp $
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
/**
|
|
20 |
*
|
|
21 |
* Parses for Text_Wiki delimiter characters already in the source text.
|
|
22 |
*
|
|
23 |
* This class implements a Text_Wiki_Parse to find instances of the delimiter
|
|
24 |
* character already embedded in the source text; it extracts them and replaces
|
|
25 |
* them with a delimited token, then renders them as the delimiter itself
|
|
26 |
* when the target format is XHTML.
|
|
27 |
*
|
|
28 |
* @category Text
|
|
29 |
*
|
|
30 |
* @package Text_Wiki
|
|
31 |
*
|
|
32 |
* @author Paul M. Jones <pmjones@php.net>
|
|
33 |
*
|
|
34 |
*/
|
|
35 |
|
|
36 |
class Text_Wiki_Parse_Delimiter extends Text_Wiki_Parse {
|
|
37 |
|
|
38 |
/**
|
|
39 |
*
|
|
40 |
* Constructor. Overrides the Text_Wiki_Parse constructor so that we
|
|
41 |
* can set the $regex property dynamically (we need to include the
|
|
42 |
* Text_Wiki $delim character.
|
|
43 |
*
|
|
44 |
* @param object &$obj The calling "parent" Text_Wiki object.
|
|
45 |
*
|
|
46 |
* @param string $name The token name to use for this rule.
|
|
47 |
*
|
|
48 |
*/
|
|
49 |
|
|
50 |
function Text_Wiki_Parse_delimiter(&$obj)
|
|
51 |
{
|
|
52 |
parent::Text_Wiki_Parse($obj);
|
|
53 |
$this->regex = '/' . $this->wiki->delim . '/';
|
|
54 |
}
|
|
55 |
|
|
56 |
|
|
57 |
/**
|
|
58 |
*
|
|
59 |
* Generates a token entry for the matched text. Token options are:
|
|
60 |
*
|
|
61 |
* 'text' => The full matched text.
|
|
62 |
*
|
|
63 |
* @access public
|
|
64 |
*
|
|
65 |
* @param array &$matches The array of matches from parse().
|
|
66 |
*
|
|
67 |
* @return A delimited token number to be used as a placeholder in
|
|
68 |
* the source text.
|
|
69 |
*
|
|
70 |
*/
|
|
71 |
|
|
72 |
function process(&$matches)
|
|
73 |
{
|
|
74 |
return $this->wiki->addToken(
|
|
75 |
$this->rule,
|
|
76 |
array('text' => $this->wiki->delim)
|
|
77 |
);
|
|
78 |
}
|
|
79 |
}
|
|
80 |
?> |