includes/wikiengine/Parse/Mediawiki/Subscript.php
changeset 1027 98c052fc3337
parent 1026 f0431eb8161e
child 1028 dde4416dea00
equal deleted inserted replaced
1026:f0431eb8161e 1027:98c052fc3337
     1 <?php
       
     2 
       
     3 /**
       
     4 * 
       
     5 * Parses for subscripted text.
       
     6 * 
       
     7 * @category Text
       
     8 * 
       
     9 * @package Text_Wiki
       
    10 * 
       
    11 * @author Paul M. Jones <pmjones@php.net>
       
    12 * 
       
    13 * @license LGPL
       
    14 * 
       
    15 * @version $Id: Subscript.php,v 1.1 2005/02/24 17:24:56 pmjones Exp $
       
    16 * 
       
    17 */
       
    18 
       
    19 /**
       
    20 * 
       
    21 * Parses for subscripted text.
       
    22 * 
       
    23 * @category Text
       
    24 * 
       
    25 * @package Text_Wiki
       
    26 * 
       
    27 * @author Paul M. Jones <pmjones@php.net>
       
    28 * 
       
    29 */
       
    30 
       
    31 class Text_Wiki_Parse_Subscript extends Text_Wiki_Parse {
       
    32     
       
    33     
       
    34     /**
       
    35     * 
       
    36     * The regular expression used to parse the source text and find
       
    37     * matches conforming to this rule.  Used by the parse() method.
       
    38     * 
       
    39     * @access public
       
    40     * 
       
    41     * @var string
       
    42     * 
       
    43     * @see parse()
       
    44     * 
       
    45     */
       
    46     
       
    47     var $regex =  "/,,(()|.*),,/U";
       
    48     
       
    49     
       
    50     /**
       
    51     * 
       
    52     * Generates a replacement for the matched text.  Token options are:
       
    53     * 
       
    54     * 'type' => ['start'|'end'] The starting or ending point of the
       
    55     * emphasized text.  The text itself is left in the source.
       
    56     * 
       
    57     * @access public
       
    58     *
       
    59     * @param array &$matches The array of matches from parse().
       
    60     *
       
    61     * @return A pair of delimited tokens to be used as a placeholder in
       
    62     * the source text surrounding the text to be emphasized.
       
    63     *
       
    64     */
       
    65     
       
    66     function process(&$matches)
       
    67     {
       
    68         $start = $this->wiki->addToken(
       
    69             $this->rule, array('type' => 'start')
       
    70         );
       
    71         
       
    72         $end = $this->wiki->addToken(
       
    73             $this->rule, array('type' => 'end')
       
    74         );
       
    75         
       
    76         return $start . $matches[1] . $end;
       
    77     }
       
    78 }
       
    79 ?>