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 / Strong.php < prev    next >
Encoding:
PHP Script  |  2008-07-02  |  1.8 KB  |  86 lines

  1. <?php
  2.  
  3. /**
  4. * Parses for strongly-emphasized text.
  5. * @category Text
  6. * @package Text_Wiki
  7. * @author Paul M. Jones <pmjones@php.net>
  8. * @license LGPL
  9. * @version $Id: Strong.php,v 1.3 2005/02/23 17:38:29 pmjones Exp $
  10. */
  11.  
  12.  
  13. /**
  14. * Parses for strongly-emphasized text.
  15. * This class implements a Text_Wiki_Parse to find source text marked for
  16. * strong emphasis (bold) as defined by text surrounded by three
  17. * single-quotes. On parsing, the text itself is left in place, but the
  18. * starting and ending instances of three single-quotes are replaced with
  19. * tokens.
  20. *
  21. * @category Text
  22. * @package Text_Wiki
  23. * @author Paul M. Jones <pmjones@php.net>
  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 A 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.         $start = $this->wiki->addToken(
  64.             $this->rule, array('type' => 'start')
  65.         );
  66.         
  67.         $end = $this->wiki->addToken(
  68.             $this->rule, array('type' => 'end')
  69.         );
  70.         
  71.         return $start . $matches[1] . $end;
  72.     }
  73. }
  74. ?>