[ Index ]
 

Code source de Serendipity 1.2

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/bundled-libs/Text/Wiki/Parse/Default/ -> Prefilter.php (source)

   1  <?php
   2  // $Id: Prefilter.php,v 1.1 2005/01/31 15:46:52 pmjones Exp $
   3  
   4  
   5  /**
   6  * 
   7  * "Pre-filter" the source text.
   8  * 
   9  * Convert DOS and Mac line endings to Unix, concat lines ending in a
  10  * backslash \ with the next line, convert tabs to 4-spaces, add newlines
  11  * to the top and end of the source text, compress 3 or more newlines to
  12  * 2 newlines.
  13  *
  14  * @author Paul M. Jones <pmjones@ciaweb.net>
  15  *
  16  * @package Text_Wiki
  17  *
  18  */
  19  
  20  class Text_Wiki_Parse_Prefilter extends Text_Wiki_Parse {
  21      
  22      
  23      /**
  24      * 
  25      * Simple parsing method.
  26      *
  27      * @access public
  28      * 
  29      */
  30      
  31      function parse()
  32      {
  33          // convert DOS line endings
  34          $this->wiki->source = str_replace("\r\n", "\n",
  35              $this->wiki->source);
  36          
  37          // convert Macintosh line endings
  38          $this->wiki->source = str_replace("\r", "\n",
  39              $this->wiki->source);
  40          
  41          // concat lines ending in a backslash
  42          $this->wiki->source = str_replace("\\\n", "",
  43              $this->wiki->source);
  44          
  45          // convert tabs to four-spaces
  46          $this->wiki->source = str_replace("\t", "    ",
  47              $this->wiki->source);
  48             
  49          // add extra newlines at the top and end; this
  50          // seems to help many rules.
  51          $this->wiki->source = "\n" . $this->wiki->source . "\n\n";
  52          
  53          // finally, compress all instances of 3 or more newlines
  54          // down to two newlines.
  55          $find = "/\n{3,}/m";
  56          $replace = "\n\n";
  57          $this->wiki->source = preg_replace($find, $replace,
  58              $this->wiki->source);
  59      }
  60  
  61  }
  62  ?>


Généré le : Sat Nov 24 09:00:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics