Text_Wiki
[ class tree: Text_Wiki ] [ index: Text_Wiki ] [ all elements ]

Source for file Subscript.php

Documentation is available at Subscript.php

  1. <?php
  2.  
  3. /**
  4.  *
  5.  * Parses for italic text.
  6.  *
  7.  * This class implements a Text_Wiki_Parse to find source text marked for
  8.  * superscript as defined by text surrounded by two '^'.
  9.  * On parsing, the text itself is left in place, but the starting and ending
  10.  * instances of two '^' are replaced with tokens.
  11.  *
  12.  * @category Text
  13.  *
  14.  * @package Text_Wiki
  15.  *
  16.  * @author Paul M. Jones <pmjones@php.net>
  17.  * @author Michele Tomaiuolo <tomamic@yahoo.it>
  18.  *
  19.  */
  20.  
  21. class Text_Wiki_Parse_Subscript extends Text_Wiki_Parse {
  22.  
  23.  
  24.     /**
  25.      *
  26.      * The regular expression used to parse the source text and find
  27.      * matches conforming to this rule.  Used by the parse() method.
  28.      *
  29.      * @access public
  30.      *
  31.      * @var string 
  32.      *
  33.      * @see parse()
  34.      *
  35.      */
  36.  
  37.     var $regex =  "/\,\,(.*?)\,\,/";
  38.  
  39.     /**
  40.      *
  41.      * Generates a replacement for the matched text.  Token options are:
  42.      *
  43.      * 'type' => ['start'|'end'] The starting or ending point of the
  44.      * superscript text.  The text itself is left in the source.
  45.      *
  46.      * @access public
  47.      *
  48.      * @param array &$matches The array of matches from parse().
  49.      *
  50.      * @return string A pair of delimited tokens to be used as a
  51.      *  placeholder in the source text surrounding the text to be
  52.      *  superscripted.
  53.      *
  54.      */
  55.  
  56.     function process(&$matches)
  57.     {
  58.         if ($this->wiki->checkInnerTags($matches[1])) {
  59.             return $matches[0];
  60.         }
  61.  
  62.         $start $this->wiki->addToken(
  63.             $this->rule,
  64.             array('type' => 'start')
  65.         );
  66.  
  67.         $end $this->wiki->addToken(
  68.             $this->rule,
  69.             array('type' => 'end')
  70.         );
  71.  
  72.         return $start $matches[1$end;
  73.     }
  74. }
  75. ?>

Documentation generated on Mon, 11 Mar 2019 15:40:31 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.