Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
248 jpm 1
<?php
2
 
3
/**
4
*
5
* Find source text marked for teletype (monospace).
6
*
7
* Defined by text surrounded by two curly braces. On parsing, the text
8
* itself is left in place, but the starting and ending instances of
9
* curly braces are replaced with tokens.
10
*
11
* Token options are:
12
*
13
* 'type' => ['start'|'end'] The starting or ending point of the
14
* teletype text.  The text itself is left in the source.
15
*
16
*
17
* $Id: Tt.php,v 1.1 2005-01-20 19:43:20 jpm Exp $
18
*
19
* @author Paul M. Jones <pmjones@ciaweb.net>
20
*
21
* @package Text_Wiki
22
*
23
*/
24
 
25
class Text_Wiki_Parse_Tt extends Text_Wiki_Parse {
26
 
27
 
28
    /**
29
    *
30
    * The regular expression used to parse the source text.
31
    *
32
    * @access public
33
    *
34
    * @var string
35
    *
36
    * @see parse()
37
    *
38
    */
39
 
40
    var $regex = "/{{({*?.*}*?)}}/U";
41
 
42
 
43
    /**
44
    *
45
    * Generates a replacement for the matched text.
46
    *
47
    * @access public
48
    *
49
    * @param array &$matches The array of matches from parse().
50
    *
51
    * @return string A pair of delimited tokens to be used as a
52
    * placeholder in the source text surrounding the teletype text.
53
    *
54
    */
55
 
56
    function process(&$matches)
57
    {
58
        $start = $this->wiki->addToken(
59
            $this->rule, array('type' => 'start')
60
        );
61
 
62
        $end = $this->wiki->addToken(
63
            $this->rule, array('type' => 'end')
64
        );
65
 
66
        return $start . $matches[1] . $end;
67
    }
68
}
69
?>