home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / PEAR / Text / Wiki / Parse / Default / Italic.php < prev    next >
Encoding:
PHP Script  |  2008-07-02  |  1.8 KB  |  85 lines

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