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