[ Index ] |
|
Code source de Serendipity 1.2 |
1 <?php 2 /* vim: set expandtab tabstop=4 shiftwidth=4: */ 3 // +----------------------------------------------------------------------+ 4 // | PHP version 4 | 5 // +----------------------------------------------------------------------+ 6 // | Copyright (c) 1997-2003 The PHP Group | 7 // +----------------------------------------------------------------------+ 8 // | This source file is subject to version 2.0 of the PHP license, | 9 // | that is bundled with this package in the file LICENSE, and is | 10 // | available through the world-wide-web at | 11 // | http://www.php.net/license/2_02.txt. | 12 // | If you did not receive a copy of the PHP license and are unable to | 13 // | obtain it through the world-wide-web, please send a note to | 14 // | license@php.net so we can mail you a copy immediately. | 15 // +----------------------------------------------------------------------+ 16 // | Authors: Paul M. Jones <pmjones@ciaweb.net> | 17 // +----------------------------------------------------------------------+ 18 // 19 // $Id: prefilter.php,v 1.3 2004/12/02 10:54:32 nohn Exp $ 20 21 22 /** 23 * 24 * This class implements a Text_Wiki_Rule to "pre-filter" source text so 25 * that line endings are consistently \n, lines ending in a backslash \ 26 * are concatenated with the next line, and tabs are converted to spaces. 27 * 28 * @author Paul M. Jones <pmjones@ciaweb.net> 29 * 30 * @package Text_Wiki 31 * 32 */ 33 34 class Text_Wiki_Rule_prefilter extends Text_Wiki_Rule { 35 36 37 /** 38 * 39 * Simple parsing method to apply the rule directly to the source 40 * text. 41 * 42 * @access public 43 * 44 */ 45 46 function parse() 47 { 48 // convert DOS line endings 49 $this->_wiki->_source = str_replace("\r\n", "\n", 50 $this->_wiki->_source); 51 52 // convert Macintosh line endings 53 $this->_wiki->_source = str_replace("\r", "\n", 54 $this->_wiki->_source); 55 56 // concat lines ending in a backslash 57 $this->_wiki->_source = str_replace("\\\n", "", 58 $this->_wiki->_source); 59 60 // convert tabs to spaces 61 $this->_wiki->_source = str_replace("\t", " ", 62 $this->_wiki->_source); 63 64 // add extra newlines at the top and end; this 65 // seems to help many rules. 66 $this->_wiki->_source = "\n" . $this->_wiki->_source . "\n\n"; 67 68 // finally, compress all instances of 3 or more newlines 69 // down to two newlines. 70 $find = "/\n{3,}/m"; 71 $replace = "\n\n"; 72 $this->_wiki->_source = preg_replace($find, $replace, 73 $this->_wiki->_source); 74 } 75 76 } 77 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Nov 24 09:00:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |