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

Source for file italic.php

Documentation is available at italic.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2003 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.0 of the PHP license,       |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available through the world-wide-web at                              |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Paul M. Jones <pmjones@ciaweb.net>                          |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: italic.php,v 1.1 2004/01/31 15:52:08 pmjones Exp $
  20.  
  21.  
  22. /**
  23. * This class implements a Text_Wiki_Rule to find source text marked for
  24. * emphasis (italics) as defined by text surrounded by two single-quotes.
  25. * On parsing, the text itself is left in place, but the starting and ending
  26. * instances of two single-quotes are replaced with tokens.
  27. *
  28. @author Paul M. Jones <pmjones@ciaweb.net>
  29. *
  30. @package Text_Wiki
  31. *
  32. */
  33.  
  34.     
  35.     
  36.     /**
  37.     * 
  38.     * The regular expression used to parse the source text and find
  39.     * matches conforming to this rule.  Used by the parse() method.
  40.     * 
  41.     * @access public
  42.     * 
  43.     * @var string 
  44.     * 
  45.     * @see parse()
  46.     * 
  47.     */
  48.     
  49.     var $regex = "/''(()|[^'].*)''/U";
  50.     
  51.     
  52.     /**
  53.     * 
  54.     * Generates a replacement for the matched text.  Token options are:
  55.     * 
  56.     * 'type' => ['start'|'end'] The starting or ending point of the
  57.     * emphasized text.  The text itself is left in the source.
  58.     * 
  59.     * @access public
  60.     *
  61.     * @param array &$matches The array of matches from parse().
  62.     *
  63.     * @return string A pair of delimited tokens to be used as a
  64.     *  placeholder in the source text surrounding the text to be
  65.     *  emphasized.
  66.     *
  67.     */
  68.     
  69.     function process(&$matches)
  70.     {
  71.         $start $this->addToken(array('type' => 'start'));
  72.         $end $this->addToken(array('type' => 'end'));
  73.         return $start $matches[1$end;
  74.     }
  75.     
  76.     
  77.     /**
  78.     * 
  79.     * Renders a token into text matching the requested format.
  80.     * 
  81.     * @access public
  82.     * 
  83.     * @param array $options The "options" portion of the token (second
  84.     *  element).
  85.     * 
  86.     * @return string The text rendered from the token options.
  87.     * 
  88.     */
  89.     
  90.     function renderXhtml($options)
  91.     {
  92.         if ($options['type'== 'start'{
  93.             return '<i>';
  94.         }
  95.         
  96.         if ($options['type'== 'end'{
  97.             return '</i>';
  98.         }
  99.     }
  100. }
  101. ?>

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