[ 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: emphasis.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 find source text marked for 25 * emphasis (italics) as defined by text surrounded by two single-quotes. 26 * On parsing, the text itself is left in place, but the starting and ending 27 * instances of two single-quotes are replaced with tokens. 28 * 29 * @author Paul M. Jones <pmjones@ciaweb.net> 30 * 31 * @package Text_Wiki 32 * 33 */ 34 35 class Text_Wiki_Rule_emphasis extends Text_Wiki_Rule { 36 37 38 /** 39 * 40 * The regular expression used to parse the source text and find 41 * matches conforming to this rule. Used by the parse() method. 42 * 43 * @access public 44 * 45 * @var string 46 * 47 * @see parse() 48 * 49 */ 50 51 var $regex = "/\/\/(()|.*)\/\//U"; 52 53 54 /** 55 * 56 * Generates a replacement for the matched text. Token options are: 57 * 58 * 'type' => ['start'|'end'] The starting or ending point of the 59 * emphasized text. The text itself is left in the source. 60 * 61 * @access public 62 * 63 * @param array &$matches The array of matches from parse(). 64 * 65 * @return string A pair of delimited tokens to be used as a 66 * placeholder in the source text surrounding the text to be 67 * emphasized. 68 * 69 */ 70 71 function process(&$matches) 72 { 73 $start = $this->addToken(array('type' => 'start')); 74 $end = $this->addToken(array('type' => 'end')); 75 return $start . $matches[1] . $end; 76 } 77 78 79 /** 80 * 81 * Renders a token into text matching the requested format. 82 * 83 * @access public 84 * 85 * @param array $options The "options" portion of the token (second 86 * element). 87 * 88 * @return string The text rendered from the token options. 89 * 90 */ 91 92 function renderXhtml($options) 93 { 94 if ($options['type'] == 'start') { 95 return '<em>'; 96 } 97 98 if ($options['type'] == 'end') { 99 return '</em>'; 100 } 101 } 102 } 103 ?>
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 |
![]() |