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 / Bold.php < prev    next >
Encoding:
PHP Script  |  2008-07-02  |  1.7 KB  |  79 lines

  1. <?php
  2.  
  3. /**
  4. * Parses for bold text.
  5. * @category Text
  6. * @package Text_Wiki
  7. * @author Paul M. Jones <pmjones@php.net>
  8. * @license LGPL
  9. * @version $Id: Bold.php,v 1.3 2005/02/23 17:38:29 pmjones Exp $
  10. */
  11.  
  12. /**
  13. * Parses for bold text.
  14. * This class implements a Text_Wiki_Rule to find source text marked for
  15. * strong emphasis (bold) as defined by text surrounded by three
  16. * single-quotes. On parsing, the text itself is left in place, but the
  17. * starting and ending instances of three single-quotes are replaced with
  18. * tokens.
  19. *
  20. * @category Text
  21. * @package Text_Wiki
  22. * @author Paul M. Jones <pmjones@php.net>
  23. */
  24.  
  25. class Text_Wiki_Parse_Bold 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 =  "/'''(()|[^'].*)'''/U";
  42.     
  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 A pair of delimited tokens to be used as a placeholder in
  56.     * the source text surrounding the text to be emphasized.
  57.     *
  58.     */
  59.     
  60.     function process(&$matches)
  61.     {
  62.         $start = $this->wiki->addToken($this->rule, array('type' => 'start'));
  63.         $end = $this->wiki->addToken($this->rule, array('type' => 'end'));
  64.         return $start . $matches[1] . $end;
  65.     }
  66. }
  67. ?>