summaryrefslogtreecommitdiff
path: root/pear/Text/Wiki/Parse/Creole/Address.php
blob: 5e1eca12eaa7dfd349e705cbc1c041421ab1448c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php

/**
 *
 * Parses for signatures.
 * This class implements a Text_Wiki rule to find sections of the source
 * text that are signatures. A signature is any line starting with exactly
 * two - signs.
 *
 * @category Text
 *
 * @package Text_Wiki
 *
 * @author Michele Tomaiuolo <tomamic@yahoo.it>
 *
 * @license LGPL
 *
 * @version $Id: Address.php 222265 2006-10-23 13:11:27Z mic $
 *
 */

class Text_Wiki_Parse_Address extends Text_Wiki_Parse {

    /**
     *
     * The regular expression used to find source text matching this
     * rule.
     *
     * @access public
     *
     * @var string
     *
     */

    var $regex = '/^--([^-].*)$/m';

    /**
     *
     * Generates a token entry for the matched text. Token options are:
     *
     * 'start' => The starting point of the signature.
     *
     * 'end' => The ending point of the signature.
     *
     * @access public
     *
     * @param array &$matches The array of matches from parse().
     *
     * @return A delimited token number to be used as a placeholder in
     * the source text.
     *
     */

    function process(&$matches)
    {
        $start = $this->wiki->addToken(
            $this->rule, array('type' => 'start')
        );

        $end = $this->wiki->addToken(
            $this->rule, array('type' => 'end')
        );

        return "\n" . $start . trim($matches[1]) . $end;
    }
}
?>