Text_Wiki
[ class tree: Text_Wiki ] [ index: Text_Wiki ] [ all elements ]

Source for file Strong.php

Documentation is available at Strong.php

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

Documentation generated on Mon, 11 Mar 2019 14:55:48 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.