Release diogenes-0.9.22
[diogenes.git] / include / Text / Wiki / Parse / Default / Strong.php
CommitLineData
6855525e
JL
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
38class 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 // original
55 // var $regex = "/\*\*(.*?)\*\*/";
56
57 // alternatives:
58 // var $regex = "/\*\*(()|[^\n]*)\*\*/U";
59 var $regex = "/\*\*(()|.*)\*\*/U";
60
61 /**
62 *
63 * Generates a replacement for the matched text. Token options are:
64 *
65 * 'type' => ['start'|'end'] The starting or ending point of the
66 * emphasized text. The text itself is left in the source.
67 *
68 * @access public
69 *
70 * @param array &$matches The array of matches from parse().
71 *
72 * @return A pair of delimited tokens to be used as a placeholder in
73 * the source text surrounding the text to be emphasized.
74 *
75 */
76
77 function process(&$matches)
78 {
79 $start = $this->wiki->addToken(
80 $this->rule, array('type' => 'start')
81 );
82
83 $end = $this->wiki->addToken(
84 $this->rule, array('type' => 'end')
85 );
86
87 return $start . $matches[1] . $end;
88 }
89}
90?>