1<?php 2/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker */ 3 4// {{{ Header 5 6/** 7 * BBCode: Parses for superscript text. 8 * 9 * This class implements a Text_Wiki_Rule to find source text marked for 10 * strong emphasis (superscript) text as defined by text surrounded by 11 * [sup] ... [/sup] On parsing, the text itself is left in place, but 12 * the starting and ending tags are replaced with tokens. 13 * 14 * PHP versions 4 and 5 15 * 16 * @category Text 17 * @package Text_Wiki 18 * @author Firman Wandayandi <firman@php.net> 19 * @copyright 2005 bertrand Gugger 20 * @license http://www.gnu.org/copyleft/lgpl.html 21 * GNU Lesser General Public License, version 2.1 22 * @version CVS: $Id$ 23 */ 24 25// }}} 26// {{{ Class: Text_Wiki_Parse_Superscript 27 28/** 29 * Superscript text rule parser class for BBCode. 30 * 31 * @category Text 32 * @package Text_Wiki 33 * @author Firman Wandayandi <firman@php.net> 34 * @copyright 2005 bertrand Gugger 35 * @license http://www.gnu.org/copyleft/lgpl.html 36 * GNU Lesser General Public License, version 2.1 37 * @version Release: @package_version@ 38 */ 39class Text_Wiki_Parse_Superscript extends Text_Wiki_Parse 40{ 41 // {{{ Properties 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 * @var string 49 * @see parse() 50 */ 51 var $regex = "#\[sup](.*?)\[/sup]#i"; 52 53 // {{{ process() 54 55 /** 56 * Generates a replacement for the matched text. Token options are: 57 * - 'type' => ['start'|'end'] The starting or ending point of the 58 * emphasized text. The text itself is left in the source. 59 * 60 * @param array &$matches The array of matches from parse(). 61 * @return A pair of delimited tokens to be used as a placeholder in 62 * the source text surrounding the text to be emphasized. 63 * @access public 64 */ 65 function process(&$matches) 66 { 67 $start = $this->wiki->addToken($this->rule, array('type' => 'start')); 68 $end = $this->wiki->addToken($this->rule, array('type' => 'end')); 69 return $start . $matches[1] . $end; 70 } 71 72 // }}} 73} 74 75// }}} 76 77/* 78 * Local variables: 79 * mode: php 80 * tab-width: 4 81 * c-basic-offset: 4 82 * c-hanging-comment-ender-p: nil 83 * End: 84 */ 85