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

Source for file Trim.php

Documentation is available at Trim.php

  1. <?php
  2.  
  3. /**
  4.  *
  5.  * Trim lines in the source text and compress 3 or more newlines to
  6.  * 2 newlines.
  7.  *
  8.  * @category Text
  9.  *
  10.  * @package Text_Wiki
  11.  *
  12.  * @author Paul M. Jones <pmjones@php.net>
  13.  * @author Michele Tomaiuolo <tomamic@yahoo.it>
  14.  *
  15.  */
  16.  
  17. class Text_Wiki_Parse_Trim extends Text_Wiki_Parse {
  18.  
  19.  
  20.     /**
  21.      *
  22.      * Simple parsing method.
  23.      *
  24.      * @access public
  25.      *
  26.      */
  27.  
  28.     function parse()
  29.     {
  30.         // trim lines
  31.         $find "/ *\n */";
  32.         $replace "\n";
  33.         $this->wiki->source = preg_replace($find$replace,
  34.             $this->wiki->source);
  35.  
  36.         // make ordinal numbers superscripted
  37.         $this->wiki->source = preg_replace("/(?<![\w])([\d]+)([\w]+)/""$1^^$2^^",
  38.             $this->wiki->source);
  39.  
  40.         // finally, compress all instances of 3 or more newlines
  41.         // down to two newlines.
  42.         $find "/\n{3,}/m";
  43.         $replace "\n\n";
  44.         $this->wiki->source = preg_replace($find$replace,
  45.             $this->wiki->source);
  46.     }
  47.  
  48. }
  49. ?>

Documentation generated on Mon, 11 Mar 2019 14:55:49 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.