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

Source for file Code.php

Documentation is available at Code.php

  1. <?php
  2. // $Id: Code.php,v 1.2 2004/09/25 19:05:13 pmjones Exp $
  3.  
  4.  
  5. /**
  6. * 
  7. * This class implements a Text_Wiki_Parse to find sections marked as code
  8. * examples.  Blocks are marked as the string <code> on a line by itself,
  9. * followed by the inline code example, and terminated with the string
  10. * </code> on a line by itself.  The code example is run through the
  11. * native PHP highlight_string() function to colorize it, then surrounded
  12. * with <pre>...</pre> tags when rendered as XHTML.
  13. *
  14. * @author Paul M. Jones <pmjones@ciaweb.net>
  15. *
  16. * @package Text_Wiki
  17. *
  18. */
  19.  
  20.     
  21.     
  22.     /**
  23.     * 
  24.     * The regular expression used to find source text matching this
  25.     * rule.
  26.     * 
  27.     * @access public
  28.     * 
  29.     * @var string 
  30.     * 
  31.     */
  32.     
  33.     var $regex = '/^(\<code( .+)?\>)\n(.+)\n(\<\/code\>)(\s|$)/Umsi';
  34.     
  35.     
  36.     /**
  37.     * 
  38.     * Generates a token entry for the matched text.  Token options are:
  39.     * 
  40.     * 'text' => The full matched text, not including the <code></code> tags.
  41.     * 
  42.     * @access public
  43.     *
  44.     * @param array &$matches The array of matches from parse().
  45.     *
  46.     * @return A delimited token number to be used as a placeholder in
  47.     *  the source text.
  48.     *
  49.     */
  50.     
  51.     function process(&$matches)
  52.     {
  53.         // are there additional attribute arguments?
  54.         $args = trim($matches[2]);
  55.         
  56.         if ($args == '') {
  57.             $options = array(
  58.                 'text' => $matches[3],
  59.                 'attr' => array('type' => '')
  60.             );
  61.         } else {
  62.             $options = array(
  63.                 'text' => $matches[3],
  64.                 'attr' => $this->getAttrs($args)
  65.             );
  66.         }
  67.         
  68.         return $this->wiki->addToken($this->rule, $options) . $matches[5];
  69.     }
  70. }
  71. ?>

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