equal
deleted
inserted
replaced
1 <?php |
|
2 |
|
3 /** |
|
4 * |
|
5 * Parses for anchor targets. |
|
6 * |
|
7 * @category Text |
|
8 * |
|
9 * @package Text_Wiki |
|
10 * |
|
11 * @author Manuel Holtgrewe <purestorm at ggnore dot net> |
|
12 * |
|
13 * @author Paul M. Jones <pmjones@php.net> |
|
14 * |
|
15 * @license LGPL |
|
16 * |
|
17 * @version $Id: Anchor.php,v 1.3 2005/02/23 17:38:29 pmjones Exp $ |
|
18 * |
|
19 */ |
|
20 |
|
21 /** |
|
22 * |
|
23 * This class implements a Text_Wiki_Parse to add an anchor target name |
|
24 * in the wiki page. |
|
25 * |
|
26 * @author Manuel Holtgrewe <purestorm at ggnore dot net> |
|
27 * |
|
28 * @author Paul M. Jones <pmjones at ciaweb dot net> |
|
29 * |
|
30 * @category Text |
|
31 * |
|
32 * @package Text_Wiki |
|
33 * |
|
34 */ |
|
35 |
|
36 class Text_Wiki_Parse_Anchor extends Text_Wiki_Parse { |
|
37 |
|
38 |
|
39 /** |
|
40 * |
|
41 * The regular expression used to find source text matching this |
|
42 * rule. Looks like a macro: [[# anchor_name]] |
|
43 * |
|
44 * @access public |
|
45 * |
|
46 * @var string |
|
47 * |
|
48 */ |
|
49 |
|
50 var $regex = '/(\[\[# )([-_A-Za-z0-9.]+?)( .+)?(\]\])/i'; |
|
51 |
|
52 |
|
53 /** |
|
54 * |
|
55 * Generates a token entry for the matched text. Token options are: |
|
56 * |
|
57 * 'text' => The full matched text, not including the <code></code> tags. |
|
58 * |
|
59 * @access public |
|
60 * |
|
61 * @param array &$matches The array of matches from parse(). |
|
62 * |
|
63 * @return A delimited token number to be used as a placeholder in |
|
64 * the source text. |
|
65 * |
|
66 */ |
|
67 |
|
68 function process(&$matches) { |
|
69 |
|
70 $name = $matches[2]; |
|
71 $text = $matches[3]; |
|
72 |
|
73 $start = $this->wiki->addToken( |
|
74 $this->rule, |
|
75 array('type' => 'start', 'name' => $name) |
|
76 ); |
|
77 |
|
78 $end = $this->wiki->addToken( |
|
79 $this->rule, |
|
80 array('type' => 'end', 'name' => $name) |
|
81 ); |
|
82 |
|
83 // done, place the script output directly in the source |
|
84 return $start . trim($text) . $end; |
|
85 } |
|
86 } |
|
87 ?> |
|