1<?php 2// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: 3/** 4 * BBCode: Parses for italic text. 5 * 6 * This class implements a Text_Wiki_Rule to find source text marked for 7 * strong emphasis (italic) as defined by text surrounded by [i] ... [/i] 8 * On parsing, the text itself is left in place, but the starting and ending 9 * tags are replaced with tokens. 10 * 11 * PHP versions 4 and 5 12 * 13 * @category Text 14 * @package Text_Wiki 15 * @author Bertrand Gugger <bertrand@toggg.com> 16 * @copyright 2005 bertrand Gugger 17 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 18 * @version CVS: $Id$ 19 * @link http://pear.php.net/package/Text_Wiki 20 */ 21 22/** 23 * Italic text rule parser class for BBCode. 24 * 25 * @category Text 26 * @package Text_Wiki 27 * @author Bertrand Gugger <bertrand@toggg.com> 28 * @copyright 2005 bertrand Gugger 29 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 30 * @version Release: @package_version@ 31 * @link http://pear.php.net/package/Text_Wiki 32 * @see Text_Wiki_Parse::Text_Wiki_Parse() 33 */ 34class Text_Wiki_Parse_Italic extends Text_Wiki_Parse { 35 36 /** 37 * The regular expression used to parse the source text and find 38 * matches conforming to this rule. Used by the parse() method. 39 * 40 * @access public 41 * @var string 42 * @see parse() 43 */ 44 var $regex = "#\[i](.*?)\[/i]#i"; 45 46 /** 47 * Generates a replacement for the matched text. Token options are: 48 * - 'type' => ['start'|'end'] The starting or ending point of the 49 * emphasized text. The text itself is left in the source. 50 * 51 * @param array &$matches The array of matches from parse(). 52 * @return A pair of delimited tokens to be used as a placeholder in 53 * the source text surrounding the text to be emphasized. 54 * @access public 55 */ 56 function process(&$matches) 57 { 58 $start = $this->wiki->addToken($this->rule, array('type' => 'start')); 59 $end = $this->wiki->addToken($this->rule, array('type' => 'end')); 60 return $start . $matches[1] . $end; 61 } 62} 63