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.  */
  20.  
  21. class Text_Wiki_Parse_Emphasis extends Text_Wiki_Parse {
  22.  
  23.  
  24.     /**
  25.      *
  26.      * The regular expression used to parse the source text and find
  27.      * matches conforming to this rule.  Used by the parse() method.
  28.      *
  29.      * @access public
  30.      *
  31.      * @var string 
  32.      *
  33.      * @see parse()
  34.      *
  35.      */
  36.  
  37.     //var $regex =  "/\/\/(.*?)\/\//";
  38.     var $regex =  "/(?:\/\/(.+?)\/\/|(?:(?<=[\W_\xFF])\/(?![ \/]))(.+?)(?:(?<![ \/])\/(?=[\W_\xFF])))/";
  39.  
  40.     /**
  41.      *
  42.      * Generates a replacement for the matched text.  Token options are:
  43.      *
  44.      * 'type' => ['start'|'end'] The starting or ending point of the
  45.      * emphasized text.  The text itself is left in the source.
  46.      *
  47.      * @access public
  48.      *
  49.      * @param array &$matches The array of matches from parse().
  50.      *
  51.      * @return string A pair of delimited tokens to be used as a
  52.      *  placeholder in the source text surrounding the text to be
  53.      *  emphasized.
  54.      *
  55.      */
  56.  
  57.     function process(&$matches)
  58.     {
  59.         $text $matches[1$matches[1$matches[2];
  60.         
  61.         if ($this->wiki->checkInnerTags($text)) {
  62.             return $matches[0];
  63.         }
  64.  
  65.         $start $this->wiki->addToken(
  66.             $this->rule,
  67.             array('type' => 'start')
  68.         );
  69.  
  70.         $end $this->wiki->addToken(
  71.             $this->rule,
  72.             array('type' => 'end')
  73.         );
  74.  
  75.         return $start $text $end;
  76.     }
  77. }
  78. ?>

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