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

Source for file Preformatted.php

Documentation is available at Preformatted.php

  1. <?php
  2.  
  3. /**
  4.  *
  5.  * Parses for preformatted text.
  6.  *
  7.  * @category Text
  8.  *
  9.  * @package Text_Wiki
  10.  *
  11.  * @author Tomaiuolo Michele <tomamic@yahoo.it>
  12.  *
  13.  * @license LGPL
  14.  *
  15.  * @version $Id: Preformatted.php,v 1.3 2007/05/28 13:36:57 mic Exp $
  16.  *
  17.  */
  18.  
  19. class Text_Wiki_Parse_Preformatted extends Text_Wiki_Parse {
  20.  
  21.  
  22.     /**
  23.      *
  24.      * The regular expression used to parse the source text and find
  25.      * matches conforming to this rule. Used by the parse() method.
  26.      *
  27.      * @access public
  28.      *
  29.      * @var string 
  30.      *
  31.      * @see parse()
  32.      *
  33.      */
  34.  
  35.     var $regex = '/\n{{{\n(.*)\n}}}\n/Us';
  36.  
  37.     /**
  38.      *
  39.      * Generates a replacement for the matched text. Token options are:
  40.      *
  41.      * 'text' => The preformatted text.
  42.      *
  43.      * @access public
  44.      *
  45.      * @param array &$matches The array of matches from parse().
  46.      *
  47.      * @return string A token to be used as a placeholder
  48.      *  in the source text for the preformatted text.
  49.      *
  50.      */
  51.  
  52.     function process(&$matches)
  53.     {
  54.         // any sequence of closing curly braces separated
  55.         // by some spaces, will have one space removed
  56.         $find "/} ( *)(?=})/";
  57.         $replace "}$1";
  58.         $matches[1preg_replace($find$replace$matches[1]);
  59.     
  60.         // > any line consisting of only indented three closing curly braces
  61.         // > will have one space removed from the indentation
  62.         // > -- http://www.wikicreole.org/wiki/AddNoWikiEscapeProposal
  63.         $find "/\n( *) }}}/";
  64.         $replace "\n$1}}}";
  65.         $matches[1preg_replace($find$replace$matches[1]);
  66.     
  67.         $find "/\n(~*)~}}}/";
  68.         $replace "\n$1}}}";
  69.         $matches[1preg_replace($find$replace$matches[1]);
  70.     
  71.         $find "/\n([\\\]*)[\\\]}}}/";
  72.         $replace "\n$1}}}";
  73.         $matches[1preg_replace($find$replace$matches[1]);
  74.     
  75.         $token $this->wiki->addToken(
  76.             $this->rule,
  77.             array('text' => $matches[1])
  78.         );
  79.         return "\n\n" $token "\n\n";
  80.     }
  81. }
  82. ?>

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