1<?php
2/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker */
3
4// {{{ Header
5
6/**
7 * BBCode: Parses for subscript text.
8 *
9 * This class implements a Text_Wiki_Rule to find source text marked for
10 * strong emphasis (subscript) text as defined by text surrounded by
11 * [sub] ... [/sub] On parsing, the text itself is left in place, but
12 * the starting and ending tags are replaced with tokens.
13 *
14 * PHP versions 4 and 5
15 *
16 * @category Text
17 * @package Text_Wiki
18 * @author Firman Wandayandi <firman@php.net>
19 * @copyright 2005 bertrand Gugger
20 * @license http://www.gnu.org/copyleft/lgpl.html
21 *          GNU Lesser General Public License, version 2.1
22 * @version CVS: $Id$
23 */
24
25// }}}
26// {{{ Class: Text_Wiki_Parse_Subscript
27
28/**
29 * Subscript text rule parser class for BBCode.
30 *
31 * @category Text
32 * @package Text_Wiki
33 * @author Firman Wandayandi <firman@php.net>
34 * @copyright 2005 bertrand Gugger
35 * @license http://www.gnu.org/copyleft/lgpl.html
36 *          GNU Lesser General Public License, version 2.1
37 * @version Release: @package_version@
38 */
39class Text_Wiki_Parse_Subscript extends Text_Wiki_Parse
40{
41    // {{{ Properties
42
43    /**
44     * The regular expression used to parse the source text and find
45     * matches conforming to this rule. Used by the parse() method.
46     *
47     * @access public
48     * @var string
49     * @see parse()
50     */
51    var $regex = "#\[sub](.*?)\[/sub]#i";
52
53    // }}}
54    // {{{ process()
55
56    /**
57     * Generates a replacement for the matched text.  Token options are:
58     * - 'type' => ['start'|'end'] The starting or ending point of the
59     * emphasized text.  The text itself is left in the source.
60     *
61     * @param array &$matches The array of matches from parse().
62     * @return A pair of delimited tokens to be used as a placeholder in
63     * the source text surrounding the text to be emphasized.
64     * @access public
65     */
66    function process(&$matches)
67    {
68        $start = $this->wiki->addToken($this->rule, array('type' => 'start'));
69        $end = $this->wiki->addToken($this->rule, array('type' => 'end'));
70        return $start . $matches[1] . $end;
71    }
72
73    // }}}
74}
75
76// }}}
77
78/*
79 * Local variables:
80 * mode: php
81 * tab-width: 4
82 * c-basic-offset: 4
83 * c-hanging-comment-ender-p: nil
84 * End:
85 */
86