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

Source for file Prefilter.php

Documentation is available at Prefilter.php

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

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