1<?php 2 3/** 4* 5* Parses for bold text. 6* 7* @category Text 8* 9* @package Text_Wiki 10* 11* @author Justin Patrin <papercrane@reversefold.com> 12* @author Paul M. Jones <pmjones@php.net> 13* 14* @license LGPL 15* 16* @version $Id$ 17* 18*/ 19 20/** 21* 22* Parses for bold text. 23* 24* This class implements a Text_Wiki_Rule to find source text marked for 25* strong emphasis (bold) as defined by text surrounded by three 26* single-quotes. On parsing, the text itself is left in place, but the 27* starting and ending instances of three single-quotes are replaced with 28* tokens. 29* 30* @category Text 31* 32* @package Text_Wiki 33* 34* @author Justin Patrin <papercrane@reversefold.com> 35* @author Paul M. Jones <pmjones@php.net> 36* 37*/ 38 39class Text_Wiki_Parse_Bold extends Text_Wiki_Parse { 40 41 42 /** 43 * 44 * The regular expression used to parse the source text and find 45 * matches conforming to this rule. Used by the parse() method. 46 * 47 * @access public 48 * 49 * @var string 50 * 51 * @see parse() 52 * 53 */ 54 55 var $regex = '/__(|[^_].*?)__/'; 56 57 58 /** 59 * 60 * Generates a replacement for the matched text. Token options are: 61 * 62 * 'type' => ['start'|'end'] The starting or ending point of the 63 * emphasized text. The text itself is left in the source. 64 * 65 * @access public 66 * 67 * @param array &$matches The array of matches from parse(). 68 * 69 * @return A pair of delimited tokens to be used as a placeholder in 70 * the source text surrounding the text to be emphasized. 71 * 72 */ 73 74 function process(&$matches) 75 { 76 $start = $this->wiki->addToken($this->rule, array('type' => 'start')); 77 $end = $this->wiki->addToken($this->rule, array('type' => 'end')); 78 return $start . $matches[1] . $end; 79 } 80} 81?>