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 242126 2007-09-03 21:17:00Z mic $
  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.     //var $regex =  "/(?:\*\*(.+?)\*\*|(?:(?<=[\W_\xFF])\*(?![ \*]))(.+?)(?:(?<![ \*])\*(?=[\W_\xFF])))/";
  44.  
  45.  
  46.     /**
  47.      *
  48.      * Generates a replacement for the matched text.  Token options are:
  49.      *
  50.      * 'type' => ['start'|'end'] The starting or ending point of the
  51.      * emphasized text.  The text itself is left in the source.
  52.      *
  53.      * @access public
  54.      *
  55.      * @param array &$matches The array of matches from parse().
  56.      *
  57.      * @return pair of delimited tokens to be used as a placeholder in
  58.      *  the source text surrounding the text to be emphasized.
  59.      *
  60.      */
  61.  
  62.     function process(&$matches)
  63.     {
  64.         $text $matches[1];
  65.         //$text = $matches[1] ? $matches[1] : $matches[2];
  66.         
  67.         if ($this->wiki->checkInnerTags($text)) {
  68.             return $matches[0];
  69.         }
  70.  
  71.         $start $this->wiki->addToken(
  72.             $this->rule,
  73.             array('type' => 'start')
  74.         );
  75.  
  76.         $end $this->wiki->addToken(
  77.             $this->rule,
  78.             array('type' => 'end')
  79.         );
  80.  
  81.         return $start $text $end;
  82.     }
  83. }
  84. ?>

Documentation generated on Mon, 11 Mar 2019 15:40:31 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.