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

Source for file Heading.php

Documentation is available at Heading.php

  1. <?php
  2. // $Id: Heading.php,v 1.1 2004/06/06 15:44:34 pmjones Exp $
  3.  
  4.  
  5. /**
  6. * This class implements a Text_Wiki_Parse to find source text marked to
  7. * be a heading element, as defined by text on a line by itself prefixed
  8. * with a number of plus signs (+). The heading text itself is left in
  9. * the source, but is prefixed and suffixed with delimited tokens marking
  10. * the start and end of the heading.
  11. *
  12. @author Paul M. Jones <pmjones@ciaweb.net>
  13. *
  14. @package Text_Wiki
  15. *
  16. */
  17.  
  18.     
  19.     
  20.     /**
  21.     * 
  22.     * The regular expression used to parse the source text and find
  23.     * matches conforming to this rule.  Used by the parse() method.
  24.     * 
  25.     * @access public
  26.     * 
  27.     * @var string 
  28.     * 
  29.     * @see parse()
  30.     * 
  31.     */
  32.     
  33.     var $regex = '/^(\+{1,6}) (.*)/m';
  34.     
  35.     
  36.     /**
  37.     * 
  38.     * Generates a replacement for the matched text.  Token options are:
  39.     * 
  40.     * 'type' => ['start'|'end'] The starting or ending point of the
  41.     * heading text.  The text itself is left in the source.
  42.     * 
  43.     * @access public
  44.     *
  45.     * @param array &$matches The array of matches from parse().
  46.     *
  47.     * @return string A pair of delimited tokens to be used as a
  48.     *  placeholder in the source text surrounding the heading text.
  49.     *
  50.     */
  51.     
  52.     function process(&$matches)
  53.     {
  54.         $start $this->wiki->addToken(
  55.             $this->rule
  56.             array(
  57.                 'type' => 'start',
  58.                 'level' => strlen($matches[1]),
  59.                 'text' => $matches[2]
  60.             )
  61.         );
  62.         
  63.         $end $this->wiki->addToken(
  64.             $this->rule
  65.             array(
  66.                 'type' => 'end',
  67.                 'level' => strlen($matches[1])
  68.             )
  69.         );
  70.         
  71.         return $start $matches[2$end "\n";
  72.     }
  73. }
  74. ?>

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