Subversion Repositories Applications.papyrus

Rev

Rev 1987 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
248 jpm 1
<?php
2
// $Id: Superscript.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
* strong emphasis (bold) as defined by text surrounded by three
9
* single-quotes. On parsing, the text itself is left in place, but the
10
* starting and ending instances of three single-quotes are replaced with
11
* tokens.
12
*
13
* @author Paul M. Jones <pmjones@ciaweb.net>
14
*
15
* @package Text_Wiki
16
*
17
*/
18
 
19
class Text_Wiki_Parse_Superscript extends Text_Wiki_Parse {
20
 
21
 
22
    /**
23
    *
24
    * The regular expression used to parse the source text and find
25
    * matches conforming to this rule.  Used by the parse() method.
26
    *
27
    * @access public
28
    *
29
    * @var string
30
    *
31
    * @see parse()
32
    *
33
    */
34
 
35
    var $regex =  "/\^\^(()|.*)\^\^/U";
36
 
37
 
38
    /**
39
    *
40
    * Generates a replacement for the matched text.  Token options are:
41
    *
42
    * 'type' => ['start'|'end'] The starting or ending point of the
43
    * emphasized text.  The text itself is left in the source.
44
    *
45
    * @access public
46
    *
47
    * @param array &$matches The array of matches from parse().
48
    *
49
    * @return A pair of delimited tokens to be used as a placeholder in
50
    * the source text surrounding the text to be 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
?>