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

Source for file Emphasis.php

Documentation is available at Emphasis.php

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

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