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

Source for file Center.php

Documentation is available at Center.php

  1. <?php
  2.  
  3. /**
  4.  *
  5.  * Parses for centered text.
  6.  *
  7.  * This class implements a Text_Wiki_Parse to find source text marked to
  8.  * be a center element, as defined by text on a line by itself prefixed
  9.  * with an exclamation mark (!).
  10.  * The centered text itself is left in the source, but is prefixed and
  11.  * suffixed with delimited tokens marking its start and end.
  12.  *
  13.  * @category Text
  14.  *
  15.  * @package Text_Wiki
  16.  *
  17.  * @author Tomaiuolo Michele <tomamic@yahoo.it>
  18.  *
  19.  * @license LGPL
  20.  *
  21.  * @version $Id: Center.php 240476 2007-07-30 14:22:34Z mic $
  22.  *
  23.  */
  24.  
  25. class Text_Wiki_Parse_Center extends Text_Wiki_Parse {
  26.  
  27.  
  28.     /**
  29.      *
  30.      * The regular expression used to parse the source text and find
  31.      * matches conforming to this rule.  Used by the parse() method.
  32.      *
  33.      * @access public
  34.      *
  35.      * @var string 
  36.      *
  37.      * @see parse()
  38.      *
  39.      */
  40.  
  41.     var $regex = '/^! *(.*?)$/m';
  42.  
  43.     /**
  44.      *
  45.      * Generates a replacement for the matched text.  Token options are:
  46.      *
  47.      * 'type' => ['start'|'end'] The starting or ending point of the
  48.      * centered text.  The text itself is left in the source.
  49.      *
  50.      * @access public
  51.      *
  52.      * @param array &$matches The array of matches from parse().
  53.      *
  54.      * @return string A pair of delimited tokens to be used as a
  55.      *  placeholder in the source text surrounding the centered text.
  56.      *
  57.      */
  58.  
  59.     function process(&$matches)
  60.     {
  61.         $start $this->wiki->addToken(
  62.             $this->rule,
  63.             array(
  64.                 'type' => 'start'
  65.             )
  66.         );
  67.  
  68.         $end $this->wiki->addToken(
  69.             $this->rule,
  70.             array(
  71.                 'type' => 'end'
  72.             )
  73.         );
  74.  
  75.         return $start trim($matches[1]$end "\n\n";
  76.     }
  77. }
  78. ?>

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