Commit | Line | Data |
---|---|---|
6855525e JL |
1 | <?php |
2 | ||
3 | /** | |
4 | * | |
5 | * Parses for bold 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: Bold.php,v 1.3 2005/02/23 17:38:29 pmjones Exp $ | |
16 | * | |
17 | */ | |
18 | ||
19 | /** | |
20 | * | |
21 | * Parses for bold text. | |
22 | * | |
23 | * This class implements a Text_Wiki_Rule to find source text marked for | |
24 | * strong emphasis (bold) as defined by text surrounded by three | |
25 | * single-quotes. On parsing, the text itself is left in place, but the | |
26 | * starting and ending instances of three single-quotes are replaced with | |
27 | * tokens. | |
28 | * | |
29 | * @category Text | |
30 | * | |
31 | * @package Text_Wiki | |
32 | * | |
33 | * @author Paul M. Jones <pmjones@php.net> | |
34 | * | |
35 | */ | |
36 | ||
37 | class Text_Wiki_Parse_Bold extends Text_Wiki_Parse { | |
38 | ||
39 | ||
40 | /** | |
41 | * | |
42 | * The regular expression used to parse the source text and find | |
43 | * matches conforming to this rule. Used by the parse() method. | |
44 | * | |
45 | * @access public | |
46 | * | |
47 | * @var string | |
48 | * | |
49 | * @see parse() | |
50 | * | |
51 | */ | |
52 | ||
53 | var $regex = "/'''(()|[^'].*)'''/U"; | |
54 | ||
55 | ||
56 | /** | |
57 | * | |
58 | * Generates a replacement for the matched text. Token options are: | |
59 | * | |
60 | * 'type' => ['start'|'end'] The starting or ending point of the | |
61 | * emphasized text. The text itself is left in the source. | |
62 | * | |
63 | * @access public | |
64 | * | |
65 | * @param array &$matches The array of matches from parse(). | |
66 | * | |
67 | * @return A pair of delimited tokens to be used as a placeholder in | |
68 | * the source text surrounding the text to be emphasized. | |
69 | * | |
70 | */ | |
71 | ||
72 | function process(&$matches) | |
73 | { | |
74 | $start = $this->wiki->addToken($this->rule, array('type' => 'start')); | |
75 | $end = $this->wiki->addToken($this->rule, array('type' => 'end')); | |
76 | return $start . $matches[1] . $end; | |
77 | } | |
78 | } | |
79 | ?> |