Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

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