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

Source for file Footnote.php

Documentation is available at Footnote.php

  1. <?php
  2.  
  3. /**
  4.  *
  5.  * Parses for bold text.
  6.  *
  7.  * This class implements a Text_Wiki_Rule to find source text marked for
  8.  * strong emphasis (bold) as defined by text surrounded by two
  9.  * stars. On parsing, the text itself is left in place, but the
  10.  * starting and ending instances of two stars are replaced with
  11.  * tokens.
  12.  *
  13.  * @category Text
  14.  *
  15.  * @package Text_Wiki
  16.  *
  17.  * @author Paul M. Jones <pmjones@php.net>
  18.  * @author Michele Tomaiuolo <tomamic@yahoo.it>
  19.  *
  20.  * @license LGPL
  21.  *
  22.  * @version $Id: Footnote.php 236407 2007-05-26 17:47:24Z mic $
  23.  *
  24.  */
  25.  
  26. class Text_Wiki_Parse_Footnote extends Text_Wiki_Parse {
  27.  
  28.  
  29.     /**
  30.      *
  31.      * The regular expression used to parse the source text and find
  32.      * matches conforming to this rule.  Used by the parse() method.
  33.      *
  34.      * @access public
  35.      *
  36.      * @var string 
  37.      *
  38.      * @see parse()
  39.      *
  40.      */
  41.  
  42.     var $regex =  "/(\n)*\[([0-9]+)\]/";
  43.  
  44.  
  45.     /**
  46.      *
  47.      * Generates a replacement for the matched text.  Token options are:
  48.      *
  49.      * 'type' => ['start'|'end'] The starting or ending point of the
  50.      * emphasized text.  The text itself is left in the source.
  51.      *
  52.      * @access public
  53.      *
  54.      * @param array &$matches The array of matches from parse().
  55.      *
  56.      * @return pair of delimited tokens to be used as a placeholder in
  57.      *  the source text surrounding the text to be emphasized.
  58.      *
  59.      */
  60.  
  61.     function process(&$matches)
  62.     {
  63.         $id $matches[2];
  64.         
  65.         if ($matches[1== "\n"{
  66.             $matches[1"\n\n";
  67.             $name = "fn$id";
  68.             $href = "#ref$id";
  69.         }
  70.         else {
  71.             $name = "ref$id";
  72.             $href = "#fn$id";
  73.         }
  74.         
  75.         $token $this->wiki->addToken(
  76.             'Url',
  77.             array('text' => "[$id]"'href' => $href'name' => $name'type' => 'inline')
  78.         );
  79.  
  80.         return $matches[1$token;
  81.     }
  82. }
  83. ?>

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