includes/wikiengine/Parse/Mediawiki/Tt.php
changeset 1027 98c052fc3337
parent 1026 f0431eb8161e
child 1028 dde4416dea00
equal deleted inserted replaced
1026:f0431eb8161e 1027:98c052fc3337
     1 <?php
       
     2 
       
     3 /**
       
     4 * 
       
     5 * Find source text marked for teletype (monospace).
       
     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: Tt.php,v 1.3 2005/02/23 17:38:29 pmjones Exp $
       
    16 * 
       
    17 */
       
    18 
       
    19 /**
       
    20 * 
       
    21 * Find source text marked for teletype (monospace).
       
    22 * 
       
    23 * Defined by text surrounded by two curly braces. On parsing, the text
       
    24 * itself is left in place, but the starting and ending instances of
       
    25 * curly braces are replaced with tokens.
       
    26 * 
       
    27 * Token options are:
       
    28 * 
       
    29 * 'type' => ['start'|'end'] The starting or ending point of the
       
    30 * teletype text.  The text itself is left in the source.
       
    31 * 
       
    32 * @category Text
       
    33 * 
       
    34 * @package Text_Wiki
       
    35 * 
       
    36 * @author Paul M. Jones <pmjones@php.net>
       
    37 * 
       
    38 */
       
    39 
       
    40 class Text_Wiki_Parse_Tt extends Text_Wiki_Parse {
       
    41     
       
    42     
       
    43     /**
       
    44     * 
       
    45     * The regular expression used to parse the source text.
       
    46     * 
       
    47     * @access public
       
    48     * 
       
    49     * @var string
       
    50     * 
       
    51     * @see parse()
       
    52     * 
       
    53     */
       
    54     
       
    55     var $regex = "/{{({*?.*}*?)}}/U";
       
    56     
       
    57     
       
    58     /**
       
    59     * 
       
    60     * Generates a replacement for the matched text. 
       
    61     * 
       
    62     * @access public
       
    63     *
       
    64     * @param array &$matches The array of matches from parse().
       
    65     *
       
    66     * @return string A pair of delimited tokens to be used as a
       
    67     * placeholder in the source text surrounding the teletype text.
       
    68     *
       
    69     */
       
    70     
       
    71     function process(&$matches)
       
    72     {
       
    73         $start = $this->wiki->addToken(
       
    74             $this->rule, array('type' => 'start')
       
    75         );
       
    76         
       
    77         $end = $this->wiki->addToken(
       
    78             $this->rule, array('type' => 'end')
       
    79         );
       
    80         
       
    81         return $start . $matches[1] . $end;
       
    82     }
       
    83 }
       
    84 ?>