1
+ − 1
<?php
+ − 2
+ − 3
/**
+ − 4
*
+ − 5
* Parses for strongly-emphasized text.
+ − 6
*
+ − 7
* @category Text
+ − 8
*
+ − 9
* @package Text_Wiki
+ − 10
*
+ − 11
* @author Paul M. Jones <pmjones@php.net>
+ − 12
*
+ − 13
* @license LGPL
+ − 14
*
+ − 15
* @version $Id: Strong.php,v 1.3 2005/02/23 17:38:29 pmjones Exp $
+ − 16
*
+ − 17
*/
+ − 18
+ − 19
+ − 20
/**
+ − 21
*
+ − 22
* Parses for strongly-emphasized text.
+ − 23
*
+ − 24
* This class implements a Text_Wiki_Parse 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 Paul M. Jones <pmjones@php.net>
+ − 35
*
+ − 36
*/
+ − 37
+ − 38
class Text_Wiki_Parse_Strong extends Text_Wiki_Parse {
+ − 39
+ − 40
+ − 41
/**
+ − 42
*
+ − 43
* The regular expression used to parse the source text and find
+ − 44
* matches conforming to this rule. Used by the parse() method.
+ − 45
*
+ − 46
* @access public
+ − 47
*
+ − 48
* @var string
+ − 49
*
+ − 50
* @see parse()
+ − 51
*
+ − 52
*/
+ − 53
+ − 54
var $regex = "/\*\*(.*?)\*\*/";
+ − 55
+ − 56
+ − 57
/**
+ − 58
*
+ − 59
* Generates a replacement for the matched text. Token options are:
+ − 60
*
+ − 61
* 'type' => ['start'|'end'] The starting or ending point of the
+ − 62
* emphasized text. The text itself is left in the source.
+ − 63
*
+ − 64
* @access public
+ − 65
*
+ − 66
* @param array &$matches The array of matches from parse().
+ − 67
*
+ − 68
* @return A pair of delimited tokens to be used as a placeholder in
+ − 69
* the source text surrounding the text to be emphasized.
+ − 70
*
+ − 71
*/
+ − 72
+ − 73
function process(&$matches)
+ − 74
{
+ − 75
$start = $this->wiki->addToken(
+ − 76
$this->rule, array('type' => 'start')
+ − 77
);
+ − 78
+ − 79
$end = $this->wiki->addToken(
+ − 80
$this->rule, array('type' => 'end')
+ − 81
);
+ − 82
+ − 83
return $start . $matches[1] . $end;
+ − 84
}
+ − 85
}
+ − 86
?>