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

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