Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: Text/Wiki/Parse/Cowiki/Anchor.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Anchor.php,v
- retrieving revision 1.1
- diff -u -r1.1 Anchor.php
- --- Text/Wiki/Parse/Cowiki/Anchor.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Anchor.php 28 Oct 2008 02:23:51 -0000
- @@ -1,85 +1,73 @@
- <?php
- -
- /**
- -*
- -* Parses for anchor targets.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Manuel Holtgrewe <purestorm at ggnore dot net>
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Anchor.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Parses for anchor targets.
- + *
- + * PHP version 4
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Manuel Holtgrewe <purestorm@ggnore.net>
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Anchor.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* This class implements a Text_Wiki_Parse to add an anchor target name
- -* in the wiki page.
- -*
- -* @author Manuel Holtgrewe <purestorm at ggnore dot net>
- -*
- -* @author Paul M. Jones <pmjones at ciaweb dot net>
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -*/
- -
- -//Not used in CoWiki
- -class Text_Wiki_Parse_Anchor extends Text_Wiki_Parse {
- + * This class implements a Text_Wiki_Parse to add an anchor target name
- + * in the wiki page.
- + *
- + * Not used in Cowiki
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @author Manuel Holtgrewe <purestorm@ggnore.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +class Text_Wiki_Parse_Anchor extends Text_Wiki_Parse
- +{
- /**
- - *
- - * The regular expression used to find source text matching this
- - * rule. Looks like a macro: [[# anchor_name]]
- - *
- - * @access public
- - *
- - * @var string
- - *
- - */
- -
- + * The regular expression used to find source text matching this
- + * rule. Looks like a macro: [[# anchor_name]]
- + *
- + * @access public
- + *
- + * @var string
- + *
- + * @see parse()
- + */
- var $regex = '/(\[\[# )([-_A-Za-z0-9.]+?)( .+)?(\]\])/i';
- /**
- - *
- - * Generates a token entry for the matched text. Token options are:
- - *
- - * 'text' => The full matched text, not including the <code></code> tags.
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return A delimited token number to be used as a placeholder in
- - * the source text.
- - *
- - */
- -
- - function process(&$matches) {
- + * Generates a token entry for the matched text. Token options are:
- + *
- + * 'text' => The full matched text, not including the <code></code> tags.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return A delimited token number to be used as a placeholder in
- + * the source text.
- + */
- + function process(&$matches)
- + {
- $name = $matches[2];
- $text = $matches[3];
- - $start = $this->wiki->addToken(
- - $this->rule,
- - array('type' => 'start', 'name' => $name)
- - );
- + $start = $this->wiki->addToken($this->rule,
- + array('type' => 'start', 'name' => $name));
- - $end = $this->wiki->addToken(
- - $this->rule,
- - array('type' => 'end', 'name' => $name)
- - );
- + $end = $this->wiki->addToken($this->rule,
- + array('type' => 'end', 'name' => $name));
- // done, place the script output directly in the source
- return $start . trim($text) . $end;
- Index: Text/Wiki/Parse/Cowiki/Blockquote.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Blockquote.php,v
- retrieving revision 1.1
- diff -u -r1.1 Blockquote.php
- --- Text/Wiki/Parse/Cowiki/Blockquote.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Blockquote.php 28 Oct 2008 02:23:51 -0000
- @@ -1,180 +1,157 @@
- <?php
- -
- /**
- -*
- -* Parse for block-quoted text.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Blockquote.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Parse for block-quoted text.
- + *
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Parse for block-quoted text.
- -*
- -* Find source text marked as a blockquote, identified by any number of
- -* greater-than signs '>' at the start of the line, followed by a space,
- -* and then the quote text; each '>' indicates an additional level of
- -* quoting.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- -
- -//Not really used in CoWiki...sort of like <posting>
- -class Text_Wiki_Parse_Blockquote extends Text_Wiki_Parse {
- -
- -
- + * Parse for block-quoted text.
- + *
- + * Not really used in CoWiki...sort of like <posting>
- + *
- + * Find source text marked as a blockquote, identified by any number of
- + * greater-than signs '>' at the start of the line, followed by a space,
- + * and then the quote text; each '>' indicates an additional level of
- + * quoting.
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +class Text_Wiki_Parse_Blockquote extends Text_Wiki_Parse
- +{
- +
- /**
- - *
- - * Regex for parsing the source text.
- - *
- - * @access public
- - *
- - * @var string
- - *
- - * @see parse()
- - *
- - */
- -
- + * The regular expression used to parse the source text and find
- + * matches conforming to this rule. Used by the parse() method.
- + *
- + * @access public
- + *
- + * @var string
- + *
- + * @see parse()
- + */
- var $regex = '/\n((\>).*\n)(?!(\>))/Us';
- -
- -
- +
- +
- /**
- - *
- - * Generates a replacement for the matched text.
- - *
- - * Token options are:
- - *
- - * 'type' =>
- - * 'start' : the start of a blockquote
- - * 'end' : the end of a blockquote
- - *
- - * 'level' => the indent level (0 for the first level, 1 for the
- - * second, etc)
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return A series of text and delimited tokens marking the different
- - * list text and list elements.
- - *
- - */
- -
- + * Generates a replacement for the matched text.
- + *
- + * Token options are:
- + *
- + * 'type' =>
- + * 'start' : the start of a blockquote
- + * 'end' : the end of a blockquote
- + *
- + * 'level' => the indent level (0 for the first level, 1 for the
- + * second, etc)
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return A series of text and delimited tokens marking the different
- + * list text and list elements.
- + */
- function process(&$matches)
- {
- // the replacement text we will return to parse()
- $return = '';
- -
- +
- // the list of post-processing matches
- $list = array();
- -
- +
- // $matches[1] is the text matched as a list set by parse();
- // create an array called $list that contains a new set of
- // matches for the various list-item elements.
- - preg_match_all(
- - '=^(\>+) (.*\n)=Ums',
- - $matches[1],
- - $list,
- - PREG_SET_ORDER
- - );
- -
- + preg_match_all('=^(\>+) (.*\n)=Ums',
- + $matches[1],
- + $list,
- + PREG_SET_ORDER);
- +
- // a stack of starts and ends; we keep this so that we know what
- // indent level we're at.
- $stack = array();
- -
- +
- // loop through each list-item element.
- foreach ($list as $key => $val) {
- -
- +
- // $val[0] is the full matched list-item line
- // $val[1] is the number of initial '>' chars (indent level)
- // $val[2] is the quote text
- -
- +
- // we number levels starting at 1, not zero
- $level = strlen($val[1]);
- -
- +
- // get the text of the line
- $text = $val[2];
- -
- +
- // add a level to the list?
- while ($level > count($stack)) {
- -
- +
- // the current indent level is greater than the number
- // of stack elements, so we must be starting a new
- - // level. push the new level onto the stack with a
- + // level. push the new level onto the stack with a
- // dummy value (boolean true)...
- array_push($stack, true);
- -
- +
- $return .= "\n";
- -
- +
- // ...and add a start token to the return.
- - $return .= $this->wiki->addToken(
- - $this->rule,
- - array(
- - 'type' => 'start',
- - 'level' => $level - 1
- - )
- - );
- -
- + $return .= $this->wiki->addToken($this->rule,
- + array('type' => 'start',
- + 'level' => $level - 1));
- +
- $return .= "\n\n";
- }
- -
- +
- // remove a level?
- while (count($stack) > $level) {
- -
- +
- // as long as the stack count is greater than the
- // current indent level, we need to end list types.
- // continue adding end-list tokens until the stack count
- // and the indent level are the same.
- array_pop($stack);
- -
- +
- $return .= "\n\n";
- -
- - $return .= $this->wiki->addToken(
- - $this->rule,
- - array (
- - 'type' => 'end',
- - 'level' => count($stack)
- - )
- - );
- -
- +
- + $return .= $this->wiki->addToken($this->rule,
- + array ('type' => 'end',
- + 'level' => count($stack)));
- +
- $return .= "\n";
- }
- -
- +
- // add the line text.
- $return .= $text;
- }
- -
- +
- // the last line may have been indented. go through the stack
- // and create end-tokens until the stack is empty.
- $return .= "\n";
- -
- +
- while (count($stack) > 0) {
- array_pop($stack);
- - $return .= $this->wiki->addToken(
- - $this->rule,
- - array (
- - 'type' => 'end',
- - 'level' => count($stack)
- - )
- - );
- + $return .= $this->wiki->addToken($this->rule,
- + array ('type' => 'end',
- + 'level' => count($stack)));
- }
- -
- +
- // we're done! send back the replacement text.
- return "\n$return\n\n";
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Bold.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Bold.php,v
- retrieving revision 1.1
- diff -u -r1.1 Bold.php
- --- Text/Wiki/Parse/Cowiki/Bold.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Bold.php 28 Oct 2008 02:23:51 -0000
- @@ -1,79 +1,70 @@
- <?php
- /**
- -*
- -* Parses for bold text.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Bold.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Parses for bold text.
- +*
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Parses for bold text.
- -*
- -* This class implements a Text_Wiki_Rule to find source text marked for
- -* strong emphasis (bold) as defined by text surrounded by three
- -* single-quotes. On parsing, the text itself is left in place, but the
- -* starting and ending instances of three single-quotes are replaced with
- -* tokens.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- + * Parses for bold text.
- + *
- + * This class implements a Text_Wiki_Rule to find source text marked for
- + * strong emphasis (bold) as defined by text surrounded by three
- + * single-quotes. On parsing, the text itself is left in place, but the
- + * starting and ending instances of three single-quotes are replaced with
- + * tokens.
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +class Text_Wiki_Parse_Bold extends Text_Wiki_Parse
- +{
- +
- -class Text_Wiki_Parse_Bold extends Text_Wiki_Parse {
- -
- -
- /**
- - *
- - * The regular expression used to parse the source text and find
- - * matches conforming to this rule. Used by the parse() method.
- - *
- - * @access public
- - *
- - * @var string
- - *
- - * @see parse()
- - *
- - */
- -
- + * The regular expression used to parse the source text and find
- + * matches conforming to this rule. Used by the parse() method.
- + *
- + * @access public
- + *
- + * @var string
- + *
- + * @see parse()
- + */
- var $regex = '/\*(()|.*)\*/U';
- -
- -
- +
- +
- /**
- - *
- - * Generates a replacement for the matched text. Token options are:
- - *
- - * 'type' => ['start'|'end'] The starting or ending point of the
- - * emphasized text. The text itself is left in the source.
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return A pair of delimited tokens to be used as a placeholder in
- - * the source text surrounding the text to be emphasized.
- - *
- - */
- -
- + * Generates a replacement for the matched text. Token options are:
- + *
- + * 'type' => ['start'|'end'] The starting or ending point of the
- + * emphasized text. The text itself is left in the source.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return A delimited token number to be used as a placeholder in
- + * the source text.
- + */
- function process(&$matches)
- {
- $start = $this->wiki->addToken($this->rule, array('type' => 'start'));
- - $end = $this->wiki->addToken($this->rule, array('type' => 'end'));
- + $end = $this->wiki->addToken($this->rule, array('type' => 'end'));
- return $start . $matches[1] . $end;
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Break.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Break.php,v
- retrieving revision 1.1
- diff -u -r1.1 Break.php
- --- Text/Wiki/Parse/Cowiki/Break.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Break.php 28 Oct 2008 02:23:51 -0000
- @@ -1,73 +1,64 @@
- <?php
- -
- /**
- -*
- -* Parses for explicit line breaks.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Break.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Parses for explicit line breaks.
- + *
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Parses for explicit line breaks.
- -*
- -* This class implements a Text_Wiki_Parse to mark forced line breaks in the
- -* source text.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- -
- -//Not used in CoWiki
- -class Text_Wiki_Parse_Break extends Text_Wiki_Parse {
- -
- -
- + * Parses for explicit line breaks.
- + *
- + * Not used in CoWiki
- + *
- + * This class implements a Text_Wiki_Parse to mark forced line breaks in the
- + * source text.
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +class Text_Wiki_Parse_Break extends Text_Wiki_Parse
- +{
- +
- +
- /**
- - *
- - * The regular expression used to parse the source text and find
- - * matches conforming to this rule. Used by the parse() method.
- - *
- - * @access public
- - *
- - * @var string
- - *
- - * @see parse()
- - *
- - */
- -
- + * The regular expression used to parse the source text and find
- + * matches conforming to this rule. Used by the parse() method.
- + *
- + * @access public
- + *
- + * @var string
- + *
- + * @see parse()
- + */
- var $regex = '/ \\\n/';
- -
- -
- +
- +
- /**
- - *
- - * Generates a replacement token for the matched text.
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return string A delimited token to be used as a placeholder in
- - * the source text.
- - *
- - */
- -
- + * Generates a replacement token for the matched text.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @return string A delimited token to be used as a placeholder in
- + * the source text.
- + * @access public
- + */
- function process(&$matches)
- - {
- + {
- return $this->wiki->addToken($this->rule);
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Center.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Center.php,v
- retrieving revision 1.1
- diff -u -r1.1 Center.php
- --- Text/Wiki/Parse/Cowiki/Center.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Center.php 28 Oct 2008 02:23:51 -0000
- @@ -1,79 +1,65 @@
- <?php
- -
- /**
- -*
- -* Parses for centered lines of text.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Center.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Parses for centered lines of text.
- + *
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Parses for centered lines of text.
- -*
- -* This class implements a Text_Wiki_Parse to find lines marked for centering.
- -* The line must start with "= " (i.e., an equal-sign followed by a space).
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- + * Parses for centered lines of text.
- + *
- + * None in CoWiki
- + *
- + * This class implements a Text_Wiki_Parse to find lines marked for centering.
- + * The line must start with "= " (i.e., an equal-sign followed by a space).
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +class Text_Wiki_Parse_Center extends Text_Wiki_Parse
- +{
- +
- -//None in CoWiki
- -class Text_Wiki_Parse_Center extends Text_Wiki_Parse {
- -
- -
- /**
- - *
- - * The regular expression used to find source text matching this
- - * rule.
- - *
- - * @access public
- - *
- - * @var string
- - *
- - */
- -
- + * The regular expression used to parse the source text and find
- + * matches conforming to this rule. Used by the parse() method.
- + *
- + * @access public
- + *
- + * @var string
- + *
- + * @see parse()
- + */
- var $regex = '/\n::(.*?)::\n/';
- -
- +
- /**
- - *
- - * Generates a token entry for the matched text.
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return A delimited token number to be used as a placeholder in
- - * the source text.
- - *
- - */
- -
- + * Generates a token entry for the matched text.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return A delimited token number to be used as a placeholder in
- + * the source text.
- + */
- function process(&$matches)
- {
- - $start = $this->wiki->addToken(
- - $this->rule,
- - array('type' => 'start')
- - );
- -
- - $end = $this->wiki->addToken(
- - $this->rule,
- - array('type' => 'end')
- - );
- -
- + $start = $this->wiki->addToken($this->rule, array('type' => 'start'));
- + $end = $this->wiki->addToken($this->rule, array('type' => 'end'));
- +
- return "\n" . $start . $matches[1] . $end . "\n";
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Code.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Code.php,v
- retrieving revision 1.1
- diff -u -r1.1 Code.php
- --- Text/Wiki/Parse/Cowiki/Code.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Code.php 28 Oct 2008 02:23:51 -0000
- @@ -1,99 +1,91 @@
- <?php
- -
- /**
- -*
- -* Parses for text marked as a code example block.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Code.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Parses for text marked as a code example block.
- + *
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Parses for text marked as a code example block.
- -*
- -* This class implements a Text_Wiki_Parse to find sections marked as code
- -* examples. Blocks are marked as the string <code> on a line by itself,
- -* followed by the inline code example, and terminated with the string
- -* </code> on a line by itself. The code example is run through the
- -* native PHP highlight_string() function to colorize it, then surrounded
- -* with <pre>...</pre> tags when rendered as XHTML.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- -
- -class Text_Wiki_Parse_Code extends Text_Wiki_Parse {
- -
- -
- + * Parses for text marked as a code example block.
- + *
- + * This class implements a Text_Wiki_Parse to find sections marked as code
- + * examples. Blocks are marked as the string <code> on a line by itself,
- + * followed by the inline code example, and terminated with the string
- + * </code> on a line by itself. The code example is run through the
- + * native PHP highlight_string() function to colorize it, then surrounded
- + * with <pre>...</pre> tags when rendered as XHTML.
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +class Text_Wiki_Parse_Code extends Text_Wiki_Parse
- +{
- +
- +
- /**
- - *
- - * The regular expression used to find source text matching this
- - * rule.
- - *
- - * @access public
- - *
- - * @var string
- - *
- - */
- -
- + * The regular expression used to parse the source text and find
- + * matches conforming to this rule. Used by the parse() method.
- + *
- + * @access public
- + *
- + * @var string
- + *
- + * @see parse()
- + */
- var $regex = '/^(<code( [^>]*)?>)\n(.+)\n(<\/code>)(\s|$)/Umsi';
- -
- -
- +
- +
- /**
- - *
- - * Generates a token entry for the matched text. Token options are:
- - *
- - * 'text' => The full matched text, not including the <code></code> tags.
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return A delimited token number to be used as a placeholder in
- - * the source text.
- - *
- - */
- -
- + * Generates a token entry for the matched text. Token options are:
- + *
- + * 'text' => The full matched text, not including the <code></code> tags.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return A delimited token number to be used as a placeholder in
- + * the source text.
- + */
- function process(&$matches)
- {
- // are there additional attribute arguments?
- $args = trim($matches[2]);
- -
- +
- if ($args == '') {
- $options = array(
- 'text' => $matches[3],
- 'attr' => array('type' => '')
- );
- } else {
- - // get the attributes...
- - $attr = $this->getAttrs($args);
- -
- - // ... and make sure we have a 'type'
- - if (!isset($attr['type'])) {
- - $attr['type'] = '';
- - }
- -
- - // retain the options
- + // get the attributes...
- + $attr = $this->getAttrs($args);
- +
- + // ... and make sure we have a 'type'
- + if (!isset($attr['type'])) {
- + $attr['type'] = '';
- + }
- +
- + // retain the options
- $options = array(
- 'text' => $matches[3],
- 'attr' => $attr
- );
- }
- -
- +
- return $this->wiki->addToken($this->rule, $options) . $matches[5];
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Colortext.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Colortext.php,v
- retrieving revision 1.1
- diff -u -r1.1 Colortext.php
- --- Text/Wiki/Parse/Cowiki/Colortext.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Colortext.php 28 Oct 2008 02:23:51 -0000
- @@ -1,90 +1,69 @@
- <?php
- -
- /**
- -*
- -* Parses for colorized text.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Colortext.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Parses for colorized text.
- + *
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Parses for colorized text.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- -
- -//Not used in CoWiki
- -class Text_Wiki_Parse_Colortext extends Text_Wiki_Parse {
- + * Parses for colorized text.
- + * Not used in CoWiki
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +class Text_Wiki_Parse_Colortext extends Text_Wiki_Parse
- +{
- /**
- - *
- - * The regular expression used to parse the source text and find
- - * matches conforming to this rule. Used by the parse() method.
- - *
- - * @access public
- - *
- - * @var string
- - *
- - * @see parse()
- - *
- - */
- -
- + * The regular expression used to parse the source text and find
- + * matches conforming to this rule. Used by the parse() method.
- + *
- + * @access public
- + *
- + * @var string
- + *
- + * @see parse()
- + */
- var $regex = "/~~(.+?):(.+?)~~/";
- /**
- - *
- - * Generates a replacement for the matched text. Token options are:
- - *
- - * 'type' => ['start'|'end'] The starting or ending point of the
- - * emphasized text. The text itself is left in the source.
- - *
- - * 'color' => the color indicator
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return string A pair of delimited tokens to be used as a
- - * placeholder in the source text surrounding the text to be
- - * emphasized.
- - *
- - */
- -
- + * Generates a replacement for the matched text. Token options are:
- + * 'type' => ['start'|'end'] The starting or ending point of the
- + * emphasized text. The text itself is left in the source.
- + * 'color' => the color indicator
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return A delimited token number to be used as a placeholder in
- + * the source text.
- + */
- function process(&$matches)
- {
- - $start = $this->wiki->addToken(
- - $this->rule,
- - array(
- - 'type' => 'start',
- - 'color' => $matches[1]
- - )
- - );
- + $start = $this->wiki->addToken($this->rule,
- + array('type' => 'start',
- + 'color' => $matches[1]));
- - $end = $this->wiki->addToken(
- - $this->rule,
- - array(
- - 'type' => 'end',
- - 'color' => $matches[1]
- - )
- - );
- + $end = $this->wiki->addToken($this->rule,
- + array('type' => 'end',
- + 'color' => $matches[1]));
- return $start . $matches[2] . $end;
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Deflist.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Deflist.php,v
- retrieving revision 1.1
- diff -u -r1.1 Deflist.php
- --- Text/Wiki/Parse/Cowiki/Deflist.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Deflist.php 28 Oct 2008 02:23:51 -0000
- @@ -1,82 +1,73 @@
- <?php
- -
- /**
- -*
- -* Parses for definition lists.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Deflist.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Parses for definition lists.
- + *
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Parses for definition lists.
- -*
- -* This class implements a Text_Wiki_Parse to find source text marked as a
- -* definition list. In short, if a line starts with ':' then it is a
- -* definition list item; another ':' on the same line indicates the end
- -* of the definition term and the beginning of the definition narrative.
- -* The list items must be on sequential lines (no blank lines between
- -* them) -- a blank line indicates the beginning of a new list.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- -
- -//Not used in CoWiki
- -class Text_Wiki_Parse_Deflist extends Text_Wiki_Parse {
- + * Parses for definition lists.
- + *
- + * Not used in CoWiki
- + *
- + * This class implements a Text_Wiki_Parse to find source text marked as a
- + * definition list. In short, if a line starts with ':' then it is a
- + * definition list item; another ':' on the same line indicates the end
- + * of the definition term and the beginning of the definition narrative.
- + * The list items must be on sequential lines (no blank lines between
- + * them) -- a blank line indicates the beginning of a new list.
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +class Text_Wiki_Parse_Deflist extends Text_Wiki_Parse
- +{
- /**
- - *
- - * The regular expression used to parse the source text and find
- - * matches conforming to this rule. Used by the parse() method.
- - *
- - * @access public
- - *
- - * @var string
- - *
- - * @see parse()
- - *
- - */
- -
- + * The regular expression used to parse the source text and find
- + * matches conforming to this rule. Used by the parse() method.
- + *
- + * @access public
- + *
- + * @var string
- + *
- + * @see parse()
- + */
- var $regex = '/\n((; ).*\n)(?!(; |\n))/Us';
- /**
- - *
- - * Generates a replacement for the matched text. Token options are:
- - *
- - * 'type' =>
- - * 'list_start' : the start of a definition list
- - * 'list_end' : the end of a definition list
- - * 'term_start' : the start of a definition term
- - * 'term_end' : the end of a definition term
- - * 'narr_start' : the start of definition narrative
- - * 'narr_end' : the end of definition narrative
- - * 'unknown' : unknown type of definition portion
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return A series of text and delimited tokens marking the different
- - * list text and list elements.
- - *
- - */
- -
- + * Generates a replacement for the matched text. Token options are:
- + *
- + * 'type' =>
- + * 'list_start' : the start of a definition list
- + * 'list_end' : the end of a definition list
- + * 'term_start' : the start of a definition term
- + * 'term_end' : the end of a definition term
- + * 'narr_start' : the start of definition narrative
- + * 'narr_end' : the end of definition narrative
- + * 'unknown' : unknown type of definition portion
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return A series of text and delimited tokens marking the different
- + * list text and list elements.
- + */
- function process(&$matches)
- {
- // the replacement text we will return to parse()
- @@ -92,12 +83,10 @@
- // $matches[1] is the text matched as a list set by parse();
- // create an array called $list that contains a new set of
- // matches for the various definition-list elements.
- - preg_match_all(
- - '/^(; )(.*)?( ; )(.*)?$/Ums',
- - $matches[1],
- - $list,
- - PREG_SET_ORDER
- - );
- + preg_match_all('/^(; )(.*)?( ; )(.*)?$/Ums',
- + $matches[1],
- + $list,
- + PREG_SET_ORDER);
- // add each term and narrative
- foreach ($list as $key => $val) {
- @@ -120,4 +109,4 @@
- return "\n" . $return . "\n\n";
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Delimiter.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Delimiter.php,v
- retrieving revision 1.1
- diff -u -r1.1 Delimiter.php
- --- Text/Wiki/Parse/Cowiki/Delimiter.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Delimiter.php 28 Oct 2008 02:23:51 -0000
- @@ -1,80 +1,67 @@
- <?php
- -
- /**
- -*
- -* Parses for Text_Wiki delimiter characters already in the source text.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Delimiter.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Parses for Text_Wiki delimiter characters already in the source text.
- + *
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Parses for Text_Wiki delimiter characters already in the source text.
- -*
- -* This class implements a Text_Wiki_Parse to find instances of the delimiter
- -* character already embedded in the source text; it extracts them and replaces
- -* them with a delimited token, then renders them as the delimiter itself
- -* when the target format is XHTML.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- + * Parses for Text_Wiki delimiter characters already in the source text.
- + *
- + * This class implements a Text_Wiki_Parse to find instances of the delimiter
- + * character already embedded in the source text; it extracts them and replaces
- + * them with a delimited token, then renders them as the delimiter itself
- + * when the target format is XHTML.
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +
- +class Text_Wiki_Parse_Delimiter extends Text_Wiki_Parse
- +{
- -class Text_Wiki_Parse_Delimiter extends Text_Wiki_Parse {
- -
- /**
- - *
- - * Constructor. Overrides the Text_Wiki_Parse constructor so that we
- - * can set the $regex property dynamically (we need to include the
- - * Text_Wiki $delim character.
- - *
- - * @param object &$obj The calling "parent" Text_Wiki object.
- - *
- - * @param string $name The token name to use for this rule.
- - *
- - */
- -
- - function Text_Wiki_Parse_delimiter(&$obj)
- + * Constructor. Overrides the Text_Wiki_Parse constructor so that we
- + * can set the $regex property dynamically (we need to include the
- + * Text_Wiki $delim character.
- + *
- + * @param object &$obj The calling "parent" Text_Wiki object.
- + */
- + function Text_Wiki_Parse_Delimiter(&$obj)
- {
- parent::Text_Wiki_Parse($obj);
- $this->regex = '/' . $this->wiki->delim . '/';
- }
- -
- -
- +
- +
- /**
- - *
- - * Generates a token entry for the matched text. Token options are:
- - *
- - * 'text' => The full matched text.
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return A delimited token number to be used as a placeholder in
- - * the source text.
- - *
- - */
- -
- + * Generates a token entry for the matched text. Token options are:
- + *
- + * 'text' => The full matched text.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return A delimited token number to be used as a placeholder in
- + * the source text.
- + */
- function process(&$matches)
- - {
- - return $this->wiki->addToken(
- - $this->rule,
- - array('text' => $this->wiki->delim)
- - );
- + {
- + return $this->wiki->addToken($this->rule,
- + array('text' => $this->wiki->delim));
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Embed.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Embed.php,v
- retrieving revision 1.1
- diff -u -r1.1 Embed.php
- --- Text/Wiki/Parse/Cowiki/Embed.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Embed.php 28 Oct 2008 02:23:51 -0000
- @@ -1,50 +1,50 @@
- <?php
- -
- /**
- -*
- -* Embeds the results of a PHP script at render-time.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Embed.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Embeds the results of a PHP script at render-time.
- + *
- + * PHP version 4
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id$
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- /**
- -*
- -* Embeds the results of a PHP script at render-time.
- -*
- -* This class implements a Text_Wiki_Parse to embed the contents of a URL
- -* inside the page at render-time. Typically used to get script output.
- -* This differs from the 'include' rule, which incorporates results at
- -* parse-time; 'embed' output does not get parsed by Text_Wiki, while
- -* 'include' ouput does.
- -*
- -* This rule is inherently not secure; it allows cross-site scripting to
- -* occur if the embedded output has <script> or other similar tags. Be
- -* careful.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- -
- -//Not used in CoWiki
- -class Text_Wiki_Parse_Embed extends Text_Wiki_Parse {
- -
- + * Embeds the results of a PHP script at render-time.
- + *
- + * Not used in CoWiki
- + *
- + * This class implements a Text_Wiki_Parse to embed the contents of a URL
- + * inside the page at render-time. Typically used to get script output.
- + * This differs from the 'include' rule, which incorporates results at
- + * parse-time; 'embed' output does not get parsed by Text_Wiki, while
- + * 'include' ouput does.
- + *
- + * This rule is inherently not secure; it allows cross-site scripting to
- + * occur if the embedded output has <script> or other similar tags. Be
- + * careful.
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +class Text_Wiki_Parse_Embed extends Text_Wiki_Parse
- +{
- +
- var $conf = array(
- 'base' => '/path/to/scripts/'
- );
- -
- +
- var $file = null;
- var $output = null;
- @@ -53,55 +53,48 @@
- /**
- - *
- - * The regular expression used to find source text matching this
- - * rule.
- - *
- - * @access public
- - *
- - * @var string
- - *
- - */
- -
- + * The regular expression used to parse the source text and find
- + * matches conforming to this rule. Used by the parse() method.
- + *
- + * @access public
- + *
- + * @var string
- + *
- + * @see parse()
- + */
- var $regex = '/(\[\[embed )(.+?)( .+?)?(\]\])/i';
- -
- -
- +
- +
- /**
- - *
- - * Generates a token entry for the matched text. Token options are:
- - *
- - * 'text' => The full matched text, not including the <code></code> tags.
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return A delimited token number to be used as a placeholder in
- - * the source text.
- - *
- - */
- -
- + * Generates a token entry for the matched text. Token options are:
- + *
- + * 'text' => The full matched text, not including the <code></code> tags.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return A delimited token number to be used as a placeholder in
- + * the source text.
- + */
- function process(&$matches)
- - {
- + {
- // save the file location
- $this->file = $this->getConf('base', './') . $matches[2];
- -
- +
- // extract attribs as variables in the local space
- $this->vars = $this->getAttrs($matches[3]);
- unset($this->vars['this']);
- extract($this->vars);
- -
- +
- // run the script
- ob_start();
- - include($this->file);
- + include $this->file;
- $this->output = ob_get_contents();
- ob_end_clean();
- -
- +
- // done, place the script output directly in the source
- - return $this->wiki->addToken(
- - $this->rule,
- - array('text' => $this->output)
- - );
- + return $this->wiki->addToken($this->rule,
- + array('text' => $this->output));
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Emphasis.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Emphasis.php,v
- retrieving revision 1.1
- diff -u -r1.1 Emphasis.php
- --- Text/Wiki/Parse/Cowiki/Emphasis.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Emphasis.php 28 Oct 2008 02:23:51 -0000
- @@ -1,81 +1,76 @@
- <?php
- /**
- -*
- -* Parses for emphasized text.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Emphasis.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Parses for emphasized text.
- +*
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Parses for emphasized text.
- -*
- + * Parses for emphasized text.
- +*
- * This class implements a Text_Wiki_Parse to find source text marked for
- * emphasis (italics) as defined by text surrounded by two single-quotes.
- * On parsing, the text itself is left in place, but the starting and ending
- * instances of two single-quotes are replaced with tokens.
- *
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- -
- -class Text_Wiki_Parse_Emphasis extends Text_Wiki_Parse {
- -
- -
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +
- +class Text_Wiki_Parse_Emphasis extends Text_Wiki_Parse
- +{
- +
- +
- /**
- * Setting regex in constructor instead of with var as we need $this->wiki->delim
- + *
- + * @param object &$obj Unknown
- */
- - function Text_Wiki_Parse_Emphasis(&$obj) {
- + function Text_Wiki_Parse_Emphasis(&$obj)
- + {
- parent::Text_Wiki_Parse($obj);
- - //using [^delim] here as CoWiki's Italic syntax is a single / and its other markup is HTML syntax with / in it
- + //using [^delim] here as CoWiki's Italic syntax is a single
- + // and its other markup is HTML syntax with / in it
- // This rule *must* be applied after all HTML style rules
- $this->regex = '!/(()|[^/][^'.$this->wiki->delim.']*)/!U';
- }
- -
- -
- +
- +
- /**
- - *
- - * Generates a replacement for the matched text. Token options are:
- - *
- - * 'type' => ['start'|'end'] The starting or ending point of the
- - * emphasized text. The text itself is left in the source.
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return string A pair of delimited tokens to be used as a
- - * placeholder in the source text surrounding the text to be
- - * emphasized.
- - *
- - */
- -
- + * Generates a replacement for the matched text. Token options are:
- + *
- + * 'type' => ['start'|'end'] The starting or ending point of the
- + * emphasized text. The text itself is left in the source.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return string A pair of delimited tokens to be used as a
- + * placeholder in the source text surrounding the text to be
- + * emphasized.
- + *
- + */
- function process(&$matches)
- {
- - $start = $this->wiki->addToken(
- - $this->rule, array('type' => 'start')
- - );
- -
- - $end = $this->wiki->addToken(
- - $this->rule, array('type' => 'end')
- - );
- -
- + $start = $this->wiki->addToken($this->rule, array('type' => 'start'));
- + $end = $this->wiki->addToken($this->rule, array('type' => 'end'));
- +
- return $start . $matches[1] . $end;
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Freelink.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Freelink.php,v
- retrieving revision 1.1
- diff -u -r1.1 Freelink.php
- --- Text/Wiki/Parse/Cowiki/Freelink.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Freelink.php 28 Oct 2008 02:23:51 -0000
- @@ -1,74 +1,70 @@
- <?php
- /**
- -*
- -* Parses for wiki freelink text.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Freelink.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Parses for wiki freelink text.
- + *
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Parses for freelinked page links.
- -*
- -* This class implements a Text_Wiki_Parse to find source text marked as a
- -* wiki freelink, and automatically create a link to that page.
- -*
- -* A freelink is any page name not conforming to the standard
- -* StudlyCapsStyle for a wiki page name. For example, a page normally
- -* named MyHomePage can be renamed and referred to as ((My Home Page)) --
- -* note the spaces in the page name. You can also make a "nice-looking"
- -* link without renaming the target page; e.g., ((MyHomePage|My Home
- -* Page)). Finally, you can use named anchors on the target page:
- -* ((MyHomePage|My Home Page#Section1)).
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- -
- -//Taken care of in WikiLink (I think)
- -class Text_Wiki_Parse_Freelink extends Text_Wiki_Parse {
- -
- + * Parses for freelinked page links.
- + *
- + * Taken care of in WikiLink (I think)
- + * This class implements a Text_Wiki_Parse to find source text marked as a
- + * wiki freelink, and automatically create a link to that page.
- + *
- + * A freelink is any page name not conforming to the standard
- + * StudlyCapsStyle for a wiki page name. For example, a page normally
- + * named MyHomePage can be renamed and referred to as ((My Home Page)) --
- + * note the spaces in the page name. You can also make a "nice-looking"
- + * link without renaming the target page; e.g., ((MyHomePage|My Home
- + * Page)). Finally, you can use named anchors on the target page:
- + * ((MyHomePage|My Home Page#Section1)).
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +class Text_Wiki_Parse_Freelink extends Text_Wiki_Parse
- +{
- +
- var $regex = '/abcdefghijklmnop\(\)\(\#\*%$%/';
- -
- -
- +
- +
- /**
- - *
- - * Generates a replacement for the matched text. Token options are:
- - *
- - * 'page' => the wiki page name (e.g., HomePage).
- - *
- - * 'text' => alternative text to be displayed in place of the wiki
- - * page name.
- - *
- - * 'anchor' => a named anchor on the target wiki page
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return A delimited token to be used as a placeholder in
- - * the source text, plus any text priot to the match.
- - *
- - */
- -
- + * Generates a replacement for the matched text. Token options are:
- + *
- + * 'page' => the wiki page name (e.g., HomePage).
- + *
- + * 'text' => alternative text to be displayed in place of the wiki
- + * page name.
- + *
- + * 'anchor' => a named anchor on the target wiki page
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return A delimited token to be used as a placeholder in
- + * the source text, plus any text priot to the match.
- + *
- + */
- +
- function process(&$matches)
- {
- return;
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Function.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Function.php,v
- retrieving revision 1.1
- diff -u -r1.1 Function.php
- --- Text/Wiki/Parse/Cowiki/Function.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Function.php 28 Oct 2008 02:23:51 -0000
- @@ -1,38 +1,44 @@
- <?php
- -
- /**
- -*
- -* Parses for an API function documentation block.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Function.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Parses for an API function documentation block.
- + *
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Parses for an API function documentation block.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- -
- -//Not used in CoWIki
- -class Text_Wiki_Parse_Function extends Text_Wiki_Parse {
- + * Parses for an API function documentation block.
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +class Text_Wiki_Parse_Function extends Text_Wiki_Parse
- +{
- + /**
- + * The regular expression used to parse the source text and find
- + * matches conforming to this rule. Used by the parse() method.
- + *
- + * @access public
- + *
- + * @var string
- + *
- + * @see parse()
- + */
- var $regex = '/^(\<function\>)\n(.+)\n(\<\/function\>)(\s|$)/Umsi';
- -
- +
- function process(&$matches)
- {
- // default options
- @@ -43,46 +49,47 @@
- 'params' => array(),
- 'throws' => array()
- );
- -
- +
- // split apart the markup lines and loop through them
- $lines = explode("\n", $matches[2]);
- foreach ($lines as $line) {
- -
- +
- // skip blank lines
- if (trim($line) == '') {
- continue;
- }
- -
- - // find the first ':' on the line; the left part is the
- +
- + // find the first ':' on the line; the left part is the
- // type, the right part is the value. skip lines without
- // a ':' on them.
- $pos = strpos($line, ':');
- if ($pos === false) {
- continue;
- }
- -
- +
- // $type is the line type: name, access, return, param, throws
- // 012345678901234
- // name: something
- $type = trim(substr($line, 0, $pos));
- - $val = trim(substr($line, $pos+1));
- -
- - switch($type) {
- -
- + $val = trim(substr($line, $pos+1));
- +
- + switch ($type) {
- +
- case 'a':
- case 'access':
- $opts['access'] = $val;
- break;
- -
- +
- case 'n':
- case 'name':
- $opts['name'] = $val;
- break;
- -
- +
- case 'p':
- case 'param':
- $tmp = explode(',', $val);
- - $k = count($tmp);
- + $k = count($tmp);
- +
- if ($k == 1) {
- $opts['params'][] = array(
- 'type' => $tmp[0],
- @@ -103,17 +110,17 @@
- );
- }
- break;
- -
- +
- case 'r':
- case 'return':
- case 'returns':
- $opts['return'] = $val;
- break;
- -
- +
- case 't':
- case 'throws':
- $tmp = explode(',', $val);
- - $k = count($tmp);
- + $k = count($tmp);
- if ($k == 1) {
- $opts['throws'][] = array(
- 'type' => $tmp[0],
- @@ -126,17 +133,17 @@
- );
- }
- break;
- -
- +
- default:
- $opts[$type] = $val;
- break;
- -
- +
- }
- }
- -
- +
- // add the token back in place
- return $this->wiki->addToken($this->rule, $opts) . $matches[4];
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Heading.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Heading.php,v
- retrieving revision 1.1
- diff -u -r1.1 Heading.php
- --- Text/Wiki/Parse/Cowiki/Heading.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Heading.php 28 Oct 2008 02:23:51 -0000
- @@ -1,77 +1,71 @@
- <?php
- /**
- -*
- -* Parses for heading text.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Heading.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Parses for heading text.
- +*
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Parses for heading text.
- -*
- + * Parses for heading text.
- +*
- * This class implements a Text_Wiki_Parse to find source text marked to
- * be a heading element, as defined by text on a line by itself prefixed
- * with a number of plus signs (+). The heading text itself is left in
- * the source, but is prefixed and suffixed with delimited tokens marking
- * the start and end of the heading.
- *
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- -
- -class Text_Wiki_Parse_Heading extends Text_Wiki_Parse {
- -
- -
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +
- +class Text_Wiki_Parse_Heading extends Text_Wiki_Parse
- +{
- +
- +
- /**
- - *
- - * The regular expression used to parse the source text and find
- - * matches conforming to this rule. Used by the parse() method.
- - *
- - * @access public
- - *
- - * @var string
- - *
- - * @see parse()
- - *
- - */
- -
- + * The regular expression used to parse the source text and find
- + * matches conforming to this rule. Used by the parse() method.
- + *
- + * @access public
- + *
- + * @var string
- + *
- + * @see parse()
- + */
- var $regex = '/^(\++) (.*)/m';
- -
- +
- var $conf = array(
- 'id_prefix' => 'toc'
- );
- -
- +
- /**
- - *
- - * Generates a replacement for the matched text. Token options are:
- - *
- - * 'type' => ['start'|'end'] The starting or ending point of the
- - * heading text. The text itself is left in the source.
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return string A pair of delimited tokens to be used as a
- - * placeholder in the source text surrounding the heading text.
- - *
- - */
- -
- + * Generates a replacement for the matched text. Token options are:
- + *
- + * 'type' => ['start'|'end'] The starting or ending point of the
- + * heading text. The text itself is left in the source.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return string A pair of delimited tokens to be used as a
- + * placeholder in the source text surrounding the heading text.
- + *
- + */
- +
- function process(&$matches)
- {
- // keep a running count for header IDs. we use this later
- @@ -80,28 +74,24 @@
- if (! isset($id)) {
- $id = 0;
- }
- -
- +
- $prefix = htmlspecialchars($this->getConf('id_prefix'));
- -
- - $start = $this->wiki->addToken(
- - $this->rule,
- - array(
- - 'type' => 'start',
- - 'level' => strlen($matches[1]),
- - 'text' => $matches[2],
- - 'id' => $prefix . $id ++
- - )
- - );
- -
- - $end = $this->wiki->addToken(
- - $this->rule,
- - array(
- - 'type' => 'end',
- - 'level' => strlen($matches[1])
- - )
- - );
- -
- +
- + $start = $this->wiki->addToken($this->rule,
- + array(
- + 'type' => 'start',
- + 'level' => strlen($matches[1]),
- + 'text' => $matches[2],
- + 'id' => $prefix . $id ++
- + ));
- +
- + $end = $this->wiki->addToken($this->rule,
- + array(
- + 'type' => 'end',
- + 'level' => strlen($matches[1])
- + ));
- +
- return $start . $matches[2] . $end . "\n";
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Horiz.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Horiz.php,v
- retrieving revision 1.1
- diff -u -r1.1 Horiz.php
- --- Text/Wiki/Parse/Cowiki/Horiz.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Horiz.php 28 Oct 2008 02:23:52 -0000
- @@ -1,70 +1,64 @@
- <?php
- /**
- -*
- -* Parses for horizontal ruling lines.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Horiz.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Parses for horizontal ruling lines.
- +*
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Parses for horizontal ruling lines.
- -*
- + * Parses for horizontal ruling lines.
- +*
- * This class implements a Text_Wiki_Parse to find source text marked to
- * be a horizontal rule, as defined by four dashed on their own line.
- *
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- -
- -class Text_Wiki_Parse_Horiz extends Text_Wiki_Parse {
- -
- -
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +
- +class Text_Wiki_Parse_Horiz extends Text_Wiki_Parse
- +{
- +
- +
- /**
- - *
- - * The regular expression used to parse the source text and find
- - * matches conforming to this rule. Used by the parse() method.
- - *
- - * @access public
- - *
- - * @var string
- - *
- - * @see parse()
- - *
- - */
- -
- + * The regular expression used to parse the source text and find
- + * matches conforming to this rule. Used by the parse() method.
- + *
- + * @access public
- + *
- + * @var string
- + *
- + * @see parse()
- + */
- var $regex = '/^([-]{3,})$/m';
- -
- -
- +
- +
- /**
- - *
- - * Generates a replacement token for the matched text.
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return string A token marking the horizontal rule.
- - *
- - */
- -
- + * Generates a replacement token for the matched text.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return string A token marking the horizontal rule.
- + *
- + */
- +
- function process(&$matches)
- - {
- + {
- return $this->wiki->addToken($this->rule);
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Html.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Html.php,v
- retrieving revision 1.1
- diff -u -r1.1 Html.php
- --- Text/Wiki/Parse/Cowiki/Html.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Html.php 28 Oct 2008 02:23:52 -0000
- @@ -1,76 +1,70 @@
- <?php
- /**
- -*
- -* Parses for blocks of HTML code.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Html.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Parses for blocks of HTML code.
- +*
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Parses for blocks of HTML code.
- -*
- -* This class implements a Text_Wiki_Parse to find source text marked as
- -* HTML to be redndred as-is. The block start is marked by <html> on its
- -* own line, and the block end is marked by </html> on its own line.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- -
- -//Not used in CoWiki
- -class Text_Wiki_Parse_Html extends Text_Wiki_Parse {
- -
- -
- + * Parses for blocks of HTML code.
- + *
- + * This class implements a Text_Wiki_Parse to find source text marked as
- + * HTML to be redndred as-is. The block start is marked by <html> on its
- + * own line, and the block end is marked by </html> on its own line.
- + *
- + * Not used in CoWiki
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +class Text_Wiki_Parse_Html extends Text_Wiki_Parse
- +{
- +
- +
- /**
- - *
- - * The regular expression used to parse the source text and find
- - * matches conforming to this rule. Used by the parse() method.
- - *
- - * @access public
- - *
- - * @var string
- - *
- - * @see parse()
- - *
- - */
- -
- + * The regular expression used to parse the source text and find
- + * matches conforming to this rule. Used by the parse() method.
- + *
- + * @access public
- + *
- + * @var string
- + *
- + * @see parse()
- + */
- var $regex = '/^\<html\>\n(.+)\n\<\/html\>(\s|$)/Umsi';
- -
- -
- +
- +
- /**
- - *
- - * Generates a replacement for the matched text. Token options are:
- - *
- - * 'text' => The text of the HTML to be rendered as-is.
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return A delimited token to be used as a placeholder in
- - * the source text, plus any text following the HTML block.
- - *
- - */
- -
- + * Generates a replacement for the matched text. Token options are:
- + *
- + * 'text' => The text of the HTML to be rendered as-is.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return A delimited token to be used as a placeholder in
- + * the source text, plus any text following the HTML block.
- + *
- + */
- +
- function process(&$matches)
- - {
- + {
- $options = array('text' => $matches[1]);
- return $this->wiki->addToken($this->rule, $options) . $matches[2];
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Image.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Image.php,v
- retrieving revision 1.1
- diff -u -r1.1 Image.php
- --- Text/Wiki/Parse/Cowiki/Image.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Image.php 28 Oct 2008 02:23:52 -0000
- @@ -1,72 +1,66 @@
- <?php
- -
- /**
- -*
- -* Parses for image placement.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Image.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Parses for image placement.
- + *
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Parses for image placement.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- -
- -//Not used in CoWiki
- -class Text_Wiki_Parse_Image extends Text_Wiki_Parse {
- -
- -
- + * Parses for image placement.
- + *
- + * Not used in CoWiki
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +class Text_Wiki_Parse_Image extends Text_Wiki_Parse
- +{
- +
- +
- /**
- - *
- - * The regular expression used to find source text matching this
- - * rule.
- - *
- - * @access public
- - *
- - * @var string
- - *
- - */
- -
- + * The regular expression used to parse the source text and find
- + * matches conforming to this rule. Used by the parse() method.
- + *
- + * @access public
- + *
- + * @var string
- + *
- + * @see parse()
- + */
- var $regex = '/({img )(.+?)(})/i';
- -
- -
- +
- +
- /**
- - *
- - * Generates a token entry for the matched text. Token options are:
- - *
- - * 'src' => The image source, typically a relative path name.
- - *
- - * 'opts' => Any macro options following the source.
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return A delimited token number to be used as a placeholder in
- - * the source text.
- - *
- - */
- -
- + * Generates a token entry for the matched text. Token options are:
- + *
- + * 'src' => The image source, typically a relative path name.
- + *
- + * 'opts' => Any macro options following the source.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return A delimited token number to be used as a placeholder in
- + * the source text.
- + */
- +
- function process(&$matches)
- {
- $pos = strpos($matches[2], ' ');
- -
- +
- if ($pos === false) {
- $options = array(
- 'src' => $matches[2],
- @@ -78,8 +72,8 @@
- 'attr' => $this->getAttrs(substr($matches[2], $pos+1))
- );
- }
- -
- +
- return $this->wiki->addToken($this->rule, $options);
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Include.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Include.php,v
- retrieving revision 1.1
- diff -u -r1.1 Include.php
- --- Text/Wiki/Parse/Cowiki/Include.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Include.php 28 Oct 2008 02:23:52 -0000
- @@ -1,82 +1,74 @@
- <?php
- -
- /**
- -*
- -* Includes the contents of another PHP script into the source text.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Include.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Includes the contents of another PHP script into the source text.
- + *
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* This class implements a Text_Wiki_Parse to include the results of a
- -* script directly into the source at parse-time; thus, the output of the
- -* script will be parsed by Text_Wiki. This differs from the 'embed'
- -* rule, which incorporates the results at render-time, meaning that the
- -* 'embed' content is not parsed by Text_Wiki.
- -*
- -* DANGER!
- -*
- -* This rule is inherently not secure; it allows cross-site scripting to
- -* occur if the embedded output has <script> or other similar tags. Be
- -* careful.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- -//None in CoWIki
- -class Text_Wiki_Parse_Include extends Text_Wiki_Parse {
- -
- + * This class implements a Text_Wiki_Parse to include the results of a
- + * script directly into the source at parse-time; thus, the output of the
- + * script will be parsed by Text_Wiki. This differs from the 'embed'
- + * rule, which incorporates the results at render-time, meaning that the
- + * 'embed' content is not parsed by Text_Wiki.
- + *
- + * DANGER!
- + *
- + * This rule is inherently not secure; it allows cross-site scripting to
- + * occur if the embedded output has <script> or other similar tags. Be
- + * careful.
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +class Text_Wiki_Parse_Include extends Text_Wiki_Parse
- +{
- +
- var $conf = array(
- 'base' => '/path/to/scripts/'
- );
- -
- +
- var $file = null;
- -
- +
- var $output = null;
- -
- +
- var $vars = null;
- /**
- - *
- - * The regular expression used to find source text matching this
- - * rule.
- - *
- - * @access public
- - *
- - * @var string
- - *
- - */
- -
- + * The regular expression used to parse the source text and find
- + * matches conforming to this rule. Used by the parse() method.
- + *
- + * @access public
- + *
- + * @var string
- + *
- + * @see parse()
- + */
- var $regex = '/(\[\[include )(.+?)( .+?)?(\]\])/i';
- -
- -
- +
- +
- /**
- - *
- - * Includes the results of the script directly into the source; the output
- - * will subsequently be parsed by the remaining Text_Wiki rules.
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return The results of the included script.
- - *
- - */
- -
- + * Includes the results of the script directly into the source; the output
- + * will subsequently be parsed by the remaining Text_Wiki rules.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return The results of the included script.
- + */
- function process(&$matches)
- {
- // save the file location
- @@ -89,12 +81,12 @@
- // run the script
- ob_start();
- - include($this->file);
- + include $this->file;
- $this->output = ob_get_contents();
- ob_end_clean();
- -
- +
- // done, place the script output directly in the source
- return $this->output;
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Interwiki.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Interwiki.php,v
- retrieving revision 1.2
- diff -u -r1.2 Interwiki.php
- --- Text/Wiki/Parse/Cowiki/Interwiki.php 28 Feb 2006 02:26:29 -0000 1.2
- +++ Text/Wiki/Parse/Cowiki/Interwiki.php 28 Oct 2008 02:23:52 -0000
- @@ -1,129 +1,122 @@
- <?php
- -
- /**
- -*
- -* Parses for interwiki links.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Interwiki.php,v 1.2 2006/02/28 02:26:29 justinpatrin Exp $
- -*
- -*/
- + * Parses for interwiki links.
- + *
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Parses for interwiki links.
- -*
- -* This class implements a Text_Wiki_Parse to find source text marked as
- -* an Interwiki link. See the regex for a detailed explanation of the
- -* text matching procedure; e.g., "InterWikiName:PageName".
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- + * Parses for interwiki links.
- + *
- + * This class implements a Text_Wiki_Parse to find source text marked as
- + * an Interwiki link. See the regex for a detailed explanation of the
- + * text matching procedure; e.g., "InterWikiName:PageName".
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +
- +class Text_Wiki_Parse_Interwiki extends Text_Wiki_Parse
- +{
- -class Text_Wiki_Parse_Interwiki extends Text_Wiki_Parse {
- -
- // double-colons wont trip up now
- var $regex = '([A-Za-z0-9_\s\.-:;&~=\/]+)\|((?!\|)[A-Za-z0-9_\/=&~#.:;-\s]*)';
- -
- -
- +
- +
- /**
- - *
- - * Parser. We override the standard parser so we can
- - * find both described interwiki links and standalone links.
- - *
- - * @access public
- - *
- - * @return void
- - *
- - */
- -
- + * Parser. We override the standard parser so we can
- + * find both described interwiki links and standalone links.
- + *
- + * @access public
- + *
- + * @return void
- + *
- + */
- +
- function parse()
- {
- // described interwiki links
- $tmp_regex = '/\(\(' . $this->regex . '(\)\((.+?))?\)\)/';
- - $this->wiki->source = preg_replace_callback(
- - $tmp_regex,
- - array(&$this, 'processDescr'),
- - $this->wiki->source
- - );
- -
- +
- + $this->wiki->source = preg_replace_callback($tmp_regex,
- + array(&$this, 'processDescr'),
- + $this->wiki->source);
- +
- // standalone interwiki links
- $tmp_regex = '/' . $this->regex . '/';
- - $this->wiki->source = preg_replace_callback(
- - $tmp_regex,
- - array(&$this, 'process'),
- - $this->wiki->source
- - );
- -
- +
- + $this->wiki->source = preg_replace_callback($tmp_regex,
- + array(&$this, 'process'),
- + $this->wiki->source);
- +
- }
- -
- -
- +
- +
- /**
- - *
- - * Generates a replacement for the matched standalone interwiki text.
- - * Token options are:
- - *
- - * 'site' => The key name for the Text_Wiki interwiki array map,
- - * usually the name of the interwiki site.
- - *
- - * 'page' => The page on the target interwiki to link to.
- - *
- - * 'text' => The text to display as the link.
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return A delimited token to be used as a placeholder in
- - * the source text, plus any text priot to the match.
- - *
- - */
- -
- + * Generates a replacement for the matched standalone interwiki text.
- + * Token options are:
- + *
- + * 'site' => The key name for the Text_Wiki interwiki array map,
- + * usually the name of the interwiki site.
- + *
- + * 'page' => The page on the target interwiki to link to.
- + *
- + * 'text' => The text to display as the link.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return A delimited token to be used as a placeholder in
- + * the source text, plus any text priot to the match.
- + *
- + */
- +
- function process(&$matches)
- {
- + $result = isset($matches[2]) && strlen($matches[2]);
- +
- $options = array(
- 'site' => $matches[1],
- 'page' => isset($matches[2]) ? $matches[2] : '',
- - 'text' => isset($matches[2]) && strlen($matches[2]) ? $matches[2] : $matches[1]
- + 'text' => $result ? $matches[2] : $matches[1]
- );
- -
- +
- return $this->wiki->addToken($this->rule, $options);
- }
- -
- -
- +
- +
- /**
- - *
- - * Generates a replacement for described interwiki links. Token
- - * options are:
- - *
- - * 'site' => The key name for the Text_Wiki interwiki array map,
- - * usually the name of the interwiki site.
- - *
- - * 'page' => The page on the target interwiki to link to.
- - *
- - * 'text' => The text to display as the link.
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return A delimited token to be used as a placeholder in
- - * the source text, plus any text priot to the match.
- - *
- - */
- -
- + * Generates a replacement for described interwiki links. Token
- + * options are:
- + *
- + * 'site' => The key name for the Text_Wiki interwiki array map,
- + * usually the name of the interwiki site.
- + *
- + * 'page' => The page on the target interwiki to link to.
- + *
- + * 'text' => The text to display as the link.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return A delimited token to be used as a placeholder in
- + * the source text, plus any text priot to the match.
- + *
- + */
- +
- function processDescr(&$matches)
- {
- $options = array(
- @@ -135,8 +128,8 @@
- ? $matches[2]
- : $matches[1]))
- );
- -
- +
- return $this->wiki->addToken($this->rule, $options);
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Italic.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Italic.php,v
- retrieving revision 1.1
- diff -u -r1.1 Italic.php
- --- Text/Wiki/Parse/Cowiki/Italic.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Italic.php 28 Oct 2008 02:23:52 -0000
- @@ -1,79 +1,72 @@
- <?php
- -
- /**
- -*
- -* Parses for italic text.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Italic.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Parses for italic text.
- + *
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Parses for italic text.
- -*
- -* This class implements a Text_Wiki_Parse to find source text marked for
- -* emphasis (italics) as defined by text surrounded by two single-quotes.
- -* On parsing, the text itself is left in place, but the starting and ending
- -* instances of two single-quotes are replaced with tokens.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- + * Parses for italic text.
- + *
- + * This class implements a Text_Wiki_Parse to find source text marked for
- + * emphasis (italics) as defined by text surrounded by two single-quotes.
- + * On parsing, the text itself is left in place, but the starting and ending
- + * instances of two single-quotes are replaced with tokens.
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +
- +class Text_Wiki_Parse_Italic extends Text_Wiki_Parse
- +{
- -class Text_Wiki_Parse_Italic extends Text_Wiki_Parse {
- -
- /**
- * Setting regex in constructor instead of with var as we need $this->wiki->delim
- + *
- + * @param Text_Wiki &$obj Calling class
- */
- - function Text_Wiki_Parse_Italic(&$obj) {
- + function Text_Wiki_Parse_Italic(&$obj)
- + {
- parent::Text_Wiki_Parse($obj);
- - //using [^delim] here as CoWiki's Italic syntax is a single / and its other markup is HTML syntax with / in it
- + //using [^delim] here as CoWiki's Italic syntax is a single
- + // and its other markup is HTML syntax with / in it
- // This rule *must* be applied after all HTML style rules
- $this->regex = '=(?<!<)/(()|[^/]*?)/=';
- }
- -
- +
- /**
- - *
- - * Generates a replacement for the matched text. Token options are:
- - *
- - * 'type' => ['start'|'end'] The starting or ending point of the
- - * emphasized text. The text itself is left in the source.
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return string A pair of delimited tokens to be used as a
- - * placeholder in the source text surrounding the text to be
- - * emphasized.
- - *
- - */
- -
- + * Generates a replacement for the matched text. Token options are:
- + *
- + * 'type' => ['start'|'end'] The starting or ending point of the
- + * emphasized text. The text itself is left in the source.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return string A pair of delimited tokens to be used as a
- + * placeholder in the source text surrounding the text to be
- + * emphasized.
- + */
- function process(&$matches)
- {
- - $start = $this->wiki->addToken(
- - $this->rule, array('type' => 'start')
- - );
- -
- - $end = $this->wiki->addToken(
- - $this->rule, array('type' => 'end')
- - );
- -
- + $start = $this->wiki->addToken($this->rule, array('type' => 'start'));
- + $end = $this->wiki->addToken($this->rule, array('type' => 'end'));
- +
- return $start . $matches[1] . $end;
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/List.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/List.php,v
- retrieving revision 1.1
- diff -u -r1.1 List.php
- --- Text/Wiki/Parse/Cowiki/List.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/List.php 28 Oct 2008 02:23:52 -0000
- @@ -1,127 +1,118 @@
- <?php
- -
- /**
- -*
- -* Parses for bulleted and numbered lists.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: List.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Parses for bulleted and numbered lists.
- + *
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Parses for bulleted and numbered lists.
- -*
- -* This class implements a Text_Wiki_Parse to find source text marked as
- -* a bulleted or numbered list. In short, if a line starts with '* ' then
- -* it is a bullet list item; if a line starts with '# ' then it is a
- -* number list item. Spaces in front of the * or # indicate an indented
- -* sub-list. The list items must be on sequential lines, and may be
- -* separated by blank lines to improve readability. Using a non-* non-#
- -* non-whitespace character at the beginning of a line ends the list.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- -
- -class Text_Wiki_Parse_List extends Text_Wiki_Parse {
- -
- -
- + * Parses for bulleted and numbered lists.
- + *
- + * This class implements a Text_Wiki_Parse to find source text marked as
- + * a bulleted or numbered list. In short, if a line starts with '* ' then
- + * it is a bullet list item; if a line starts with '# ' then it is a
- + * number list item. Spaces in front of the * or # indicate an indented
- + * sub-list. The list items must be on sequential lines, and may be
- + * separated by blank lines to improve readability. Using a non-* non-#
- + * non-whitespace character at the beginning of a line ends the list.
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +class Text_Wiki_Parse_List extends Text_Wiki_Parse
- +{
- +
- +
- /**
- - *
- - * The regular expression used to parse the source text and find
- - * matches conforming to this rule. Used by the parse() method.
- - *
- - * @access public
- - *
- - * @var string
- - *
- - * @see parse()
- - *
- - */
- -
- + * The regular expression used to parse the source text and find
- + * matches conforming to this rule. Used by the parse() method.
- + *
- + * @access public
- + *
- + * @var string
- + *
- + * @see parse()
- + *
- + */
- +
- var $regex = '/\n(( *)[\*#] .*\n(?!( *)(\*|#)+))/Us';
- /**
- - *
- - * Generates a replacement for the matched text. Token options are:
- - *
- - * 'type' =>
- - * 'bullet_start' : the start of a bullet list
- - * 'bullet_end' : the end of a bullet list
- - * 'number_start' : the start of a number list
- - * 'number_end' : the end of a number list
- - * 'item_start' : the start of item text (bullet or number)
- - * 'item_end' : the end of item text (bullet or number)
- - * 'unknown' : unknown type of list or item
- - *
- - * 'level' => the indent level (0 for the first level, 1 for the
- - * second, etc)
- - *
- - * 'count' => the list item number at this level. not needed for
- - * xhtml, but very useful for PDF and RTF.
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return A series of text and delimited tokens marking the different
- - * list text and list elements.
- - *
- - */
- -
- + * Generates a replacement for the matched text. Token options are:
- + *
- + * 'type' =>
- + * 'bullet_start' : the start of a bullet list
- + * 'bullet_end' : the end of a bullet list
- + * 'number_start' : the start of a number list
- + * 'number_end' : the end of a number list
- + * 'item_start' : the start of item text (bullet or number)
- + * 'item_end' : the end of item text (bullet or number)
- + * 'unknown' : unknown type of list or item
- + *
- + * 'level' => the indent level (0 for the first level, 1 for the
- + * second, etc)
- + *
- + * 'count' => the list item number at this level. not needed for
- + * xhtml, but very useful for PDF and RTF.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return A series of text and delimited tokens marking the different
- + * list text and list elements.
- + *
- + */
- function process(&$matches)
- {
- // the replacement text we will return
- $return = '';
- -
- +
- // the list of post-processing matches
- $list = array();
- -
- +
- // a stack of list-start and list-end types; we keep this
- // so that we know what kind of list we're working with
- // (bullet or number) and what indent level we're at.
- $stack = array();
- -
- +
- // the item count is the number of list items for any
- // given list-type on the stack
- $itemcount = array();
- -
- +
- // have we processed the very first list item?
- $pastFirst = false;
- -
- +
- // populate $list with this set of matches. $matches[1] is the
- // text matched as a list set by parse().
- - preg_match_all(
- - '/^( *)([\*#]) (.*)$/Ums',
- - $matches[1],
- - $list,
- - PREG_SET_ORDER
- - );
- -
- + preg_match_all('/^( *)([\*#]) (.*)$/Ums',
- + $matches[1],
- + $list,
- + PREG_SET_ORDER);
- +
- // loop through each list-item element.
- foreach ($list as $key => $val) {
- // $val[0] is the full matched list-item line
- // $val[1] is the type (* or #)
- // $val[2] is the level (number)
- // $val[3] is the list item text
- -
- +
- // how many levels are we indented? (1 means the "root"
- // list level, no indenting.)
- $level = strlen($val[1]) + 1;
- -
- +
- // get the list item type
- if ($val[2] == '*') {
- $type = 'bullet';
- @@ -130,58 +121,51 @@
- } else {
- $type = 'unknown';
- }
- -
- +
- // get the text of the list item
- $text = $val[3];
- // add a level to the list?
- if ($level > count($stack)) {
- -
- +
- // the current indent level is greater than the
- // number of stack elements, so we must be starting
- // a new list. push the new list type onto the
- // stack...
- array_push($stack, $type);
- -
- +
- // ...and add a list-start token to the return.
- - $return .= $this->wiki->addToken(
- - $this->rule,
- - array(
- - 'type' => $type . '_list_start',
- - 'level' => $level - 1
- - )
- - );
- + $options = array('type' => $type . '_list_start',
- + 'level' => $level - 1);
- + $return .= $this->wiki->addToken($this->rule, $options);
- }
- -
- +
- // remove a level from the list?
- while (count($stack) > $level) {
- -
- +
- // so we don't keep counting the stack, we set up a temp
- // var for the count. -1 becuase we're going to pop the
- // stack in the next command. $tmp will then equal the
- // current level of indent.
- $tmp = count($stack) - 1;
- -
- +
- // as long as the stack count is greater than the
- - // current indent level, we need to end list types.
- + // current indent level, we need to end list types.
- // continue adding end-list tokens until the stack count
- // and the indent level are the same.
- - $return .= $this->wiki->addToken(
- - $this->rule,
- - array (
- - 'type' => array_pop($stack) . '_list_end',
- - 'level' => $tmp
- - )
- - );
- -
- + $options = array ('type' => array_pop($stack) . '_list_end',
- + 'level' => $tmp);
- +
- + $return .= $this->wiki->addToken($this->rule, $options);
- +
- // reset to the current (previous) list type so that
- // the new list item matches the proper list type.
- $type = $stack[$tmp - 1];
- -
- +
- // reset the item count for the popped indent level
- unset($itemcount[$tmp + 1]);
- }
- -
- +
- // add to the item count for this list (taking into account
- // which level we are at).
- if (! isset($itemcount[$level])) {
- @@ -191,56 +175,51 @@
- // increment count
- $itemcount[$level]++;
- }
- -
- +
- // is this the very first item in the list?
- - if (! $pastFirst) {
- + if (!$pastFirst) {
- $first = true;
- +
- $pastFirst = true;
- } else {
- $first = false;
- }
- -
- +
- // create a list-item starting token.
- - $start = $this->wiki->addToken(
- - $this->rule,
- - array(
- - 'type' => $type . '_item_start',
- - 'level' => $level,
- - 'count' => $itemcount[$level],
- - 'first' => $first
- - )
- - );
- -
- + $options = array(
- + 'type' => $type . '_item_start',
- + 'level' => $level,
- + 'count' => $itemcount[$level],
- + 'first' => $first
- + );
- +
- + $start = $this->wiki->addToken($this->rule, $options);
- +
- // create a list-item ending token.
- - $end = $this->wiki->addToken(
- - $this->rule,
- - array(
- - 'type' => $type . '_item_end',
- - 'level' => $level,
- - 'count' => $itemcount[$level]
- - )
- - );
- -
- + $end = $this->wiki->addToken($this->rule,
- + array(
- + 'type' => $type . '_item_end',
- + 'level' => $level,
- + 'count' => $itemcount[$level]
- + ));
- +
- // add the starting token, list-item text, and ending token
- // to the return.
- $return .= $start . $text . $end;
- }
- -
- +
- // the last list-item may have been indented. go through the
- // list-type stack and create end-list tokens until the stack
- // is empty.
- while (count($stack) > 0) {
- - $return .= $this->wiki->addToken(
- - $this->rule,
- - array (
- - 'type' => array_pop($stack) . '_list_end',
- - 'level' => count($stack)
- - )
- - );
- + $options = array('type' => array_pop($stack) . '_list_end',
- + 'level' => count($stack));
- +
- + $return .= $this->wiki->addToken($this->rule, $options);
- }
- -
- +
- // we're done! send back the replacement text.
- return "\n" . $return . "\n\n";
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Newline.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Newline.php,v
- retrieving revision 1.1
- diff -u -r1.1 Newline.php
- --- Text/Wiki/Parse/Cowiki/Newline.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Newline.php 28 Oct 2008 02:23:52 -0000
- @@ -1,75 +1,71 @@
- <?php
- /**
- -*
- -* Parses for implied line breaks indicated by newlines.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Newline.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Parses for implied line breaks indicated by newlines.
- +*
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Parses for implied line breaks indicated by newlines.
- -*
- + * Parses for implied line breaks indicated by newlines.
- +*
- * This class implements a Text_Wiki_Parse to mark implied line breaks in the
- * source text, usually a single carriage return in the middle of a paragraph
- * or block-quoted text.
- *
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- -
- -class Text_Wiki_Parse_Newline extends Text_Wiki_Parse {
- -
- -
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +
- +class Text_Wiki_Parse_Newline extends Text_Wiki_Parse
- +{
- +
- +
- /**
- - *
- - * The regular expression used to parse the source text and find
- - * matches conforming to this rule. Used by the parse() method.
- - *
- - * @access public
- - *
- - * @var string
- - *
- - * @see parse()
- - *
- - */
- -
- + *
- + * The regular expression used to parse the source text and find
- + * matches conforming to this rule. Used by the parse() method.
- + *
- + * @access public
- + *
- + * @var string
- + *
- + * @see parse()
- + *
- + */
- +
- var $regex = '/([^\n])\n([^\n])/m';
- -
- -
- +
- +
- /**
- - *
- - * Generates a replacement token for the matched text.
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return string A delimited token to be used as a placeholder in
- - * the source text.
- - *
- - */
- -
- + * Generates a replacement token for the matched text.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return string A delimited token to be used as a placeholder in
- + * the source text.
- + *
- + */
- function process(&$matches)
- - {
- + {
- return $matches[1] .
- $this->wiki->addToken($this->rule) .
- $matches[2];
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Paragraph.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Paragraph.php,v
- retrieving revision 1.1
- diff -u -r1.1 Paragraph.php
- --- Text/Wiki/Parse/Cowiki/Paragraph.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Paragraph.php 28 Oct 2008 02:23:52 -0000
- @@ -1,52 +1,48 @@
- <?php
- -
- /**
- -*
- -* Parses for paragraph blocks.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Paragraph.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Parses for paragraph blocks.
- + *
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Parses for paragraph blocks.
- -*
- -* This class implements a Text_Wiki rule to find sections of the source
- -* text that are paragraphs. A para is any line not starting with a token
- -* delimiter, followed by two newlines.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- + * Parses for paragraph blocks.
- + *
- + * This class implements a Text_Wiki rule to find sections of the source
- + * text that are paragraphs. A para is any line not starting with a token
- + * delimiter, followed by two newlines.
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +class Text_Wiki_Parse_Paragraph extends Text_Wiki_Parse
- +{
- -class Text_Wiki_Parse_Paragraph extends Text_Wiki_Parse {
- -
- /**
- - *
- - * The regular expression used to find source text matching this
- - * rule.
- - *
- - * @access public
- - *
- - * @var string
- - *
- - */
- -
- + * The regular expression used to find source text matching this
- + * rule.
- + *
- + * @access public
- + *
- + * @var string
- + *
- + */
- +
- var $regex = "/^.*?\n\n/m";
- -
- +
- var $conf = array(
- 'skip' => array(
- 'blockquote', // are we sure about this one?
- @@ -59,53 +55,44 @@
- 'toc'
- )
- );
- -
- -
- +
- +
- /**
- - *
- - * Generates a token entry for the matched text. Token options are:
- - *
- - * 'start' => The starting point of the paragraph.
- - *
- - * 'end' => The ending point of the paragraph.
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return A delimited token number to be used as a placeholder in
- - * the source text.
- - *
- - */
- -
- + * Generates a token entry for the matched text. Token options are:
- + *
- + * 'start' => The starting point of the paragraph.
- + *
- + * 'end' => The ending point of the paragraph.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return A delimited token number to be used as a placeholder in
- + * the source text.
- + */
- function process(&$matches)
- {
- $delim = $this->wiki->delim;
- -
- +
- // was anything there?
- if (trim($matches[0]) == '') {
- return '';
- }
- -
- +
- // does the match start with a delimiter?
- - if (substr($matches[0], 0, 1) != $delim) {
- + if (substr($matches[0], 0, 1) != $delim) {
- // no.
- -
- - $start = $this->wiki->addToken(
- - $this->rule, array('type' => 'start')
- - );
- -
- - $end = $this->wiki->addToken(
- - $this->rule, array('type' => 'end')
- - );
- -
- +
- + $start = $this->wiki->addToken($this->rule, array('type' => 'start'));
- + $end = $this->wiki->addToken($this->rule, array('type' => 'end'));
- +
- return $start . trim($matches[0]) . $end;
- }
- -
- +
- // the line starts with a delimiter. read in the delimited
- // token number, check the token, and see if we should
- // skip it.
- -
- +
- // loop starting at the second character (we already know
- // the first is a delimiter) until we find another
- // delimiter; the text between them is a token key number.
- @@ -119,28 +106,24 @@
- $key .= $char;
- }
- }
- -
- +
- // look at the token and see if it's skippable (if we skip,
- // it will not be marked as a paragraph)
- $token_type = strtolower($this->wiki->tokens[$key][0]);
- +
- $skip = $this->getConf('skip', array());
- -
- +
- if (in_array($token_type, $skip)) {
- // this type of token should not have paragraphs applied to it.
- // return the entire matched text.
- return $matches[0];
- } else {
- -
- - $start = $this->wiki->addToken(
- - $this->rule, array('type' => 'start')
- - );
- -
- - $end = $this->wiki->addToken(
- - $this->rule, array('type' => 'end')
- - );
- -
- +
- + $start = $this->wiki->addToken($this->rule, array('type' => 'start'));
- + $end = $this->wiki->addToken($this->rule, array('type' => 'end'));
- +
- return $start . trim($matches[0]) . $end;
- }
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Phplookup.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Phplookup.php,v
- retrieving revision 1.1
- diff -u -r1.1 Phplookup.php
- --- Text/Wiki/Parse/Cowiki/Phplookup.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Phplookup.php 28 Oct 2008 02:23:52 -0000
- @@ -1,73 +1,61 @@
- <?php
- -
- /**
- -*
- -* Find source text marked for lookup in the PHP online manual.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Find source text marked for lookup in the PHP online manual.
- + *
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Find source text marked for lookup in the PHP online manual.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- -//Nine in CoWIki
- -class Text_Wiki_Parse_Phplookup extends Text_Wiki_Parse {
- -
- -
- + * Find source text marked for lookup in the PHP online manual.
- + * Nine in CoWIki
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +class Text_Wiki_Parse_Phplookup extends Text_Wiki_Parse
- +{
- +
- +
- /**
- - *
- - * The regular expression used to parse the source text and find
- - * matches conforming to this rule. Used by the parse() method.
- - *
- - * @access public
- - *
- - * @var string
- - *
- - * @see parse()
- - *
- - */
- -
- + * The regular expression used to parse the source text and find
- + * matches conforming to this rule. Used by the parse() method.
- + *
- + * @access public
- + *
- + * @var string
- + *
- + * @see parse()
- + */
- var $regex = "/\[\[php (.+?)\]\]/";
- -
- -
- +
- +
- /**
- - *
- - * Generates a replacement for the matched text. Token options are:
- - *
- - * 'type' => ['start'|'end'] The starting or ending point of the
- - * teletype text. The text itself is left in the source.
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return string A pair of delimited tokens to be used as a
- - * placeholder in the source text surrounding the teletype text.
- - *
- - */
- -
- + * Generates a replacement for the matched text. Token options are:
- + * 'type' => ['start'|'end'] The starting or ending point of the
- + * teletype text. The text itself is left in the source.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @return string A pair of delimited tokens to be used as a
- + * placeholder in the source text surrounding the teletype text.
- + * @access public
- + */
- function process(&$matches)
- {
- - return $this->wiki->addToken(
- - $this->rule, array('text' => $matches[1])
- - );
- + return $this->wiki->addToken($this->rule, array('text' => $matches[1]));
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Prefilter.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Prefilter.php,v
- retrieving revision 1.1
- diff -u -r1.1 Prefilter.php
- --- Text/Wiki/Parse/Cowiki/Prefilter.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Prefilter.php 28 Oct 2008 02:23:52 -0000
- @@ -1,78 +1,74 @@
- <?php
- -
- /**
- -*
- -* "Pre-filter" the source text.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Prefilter.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * "Pre-filter" the source text.
- + *
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* "Pre-filter" the source text.
- -*
- -* Convert DOS and Mac line endings to Unix, concat lines ending in a
- -* backslash \ with the next line, convert tabs to 4-spaces, add newlines
- -* to the top and end of the source text, compress 3 or more newlines to
- -* 2 newlines.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- -
- -class Text_Wiki_Parse_Prefilter extends Text_Wiki_Parse {
- -
- -
- + * "Pre-filter" the source text.
- + *
- + * Convert DOS and Mac line endings to Unix, concat lines ending in a
- + * backslash \ with the next line, convert tabs to 4-spaces, add newlines
- + * to the top and end of the source text, compress 3 or more newlines to
- + * 2 newlines.
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +class Text_Wiki_Parse_Prefilter extends Text_Wiki_Parse
- +{
- +
- +
- /**
- - *
- - * Simple parsing method.
- - *
- - * @access public
- - *
- - */
- -
- + * Simple parsing method.
- + *
- + * @access public
- + * @return void
- + */
- function parse()
- {
- // convert DOS line endings
- $this->wiki->source = str_replace("\r\n", "\n",
- $this->wiki->source);
- -
- +
- // convert Macintosh line endings
- $this->wiki->source = str_replace("\r", "\n",
- $this->wiki->source);
- -
- +
- // concat lines ending in a backslash
- $this->wiki->source = str_replace("\\\n", "",
- $this->wiki->source);
- -
- +
- // convert tabs to four-spaces
- $this->wiki->source = str_replace("\t", " ",
- $this->wiki->source);
- -
- +
- // add extra newlines at the top and end; this
- // seems to help many rules.
- $this->wiki->source = "\n" . $this->wiki->source . "\n\n";
- -
- +
- // finally, compress all instances of 3 or more newlines
- // down to two newlines.
- - $find = "/\n{3,}/m";
- + $find = "/\n{3,}/m";
- $replace = "\n\n";
- +
- $this->wiki->source = preg_replace($find, $replace,
- $this->wiki->source);
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Raw.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Raw.php,v
- retrieving revision 1.1
- diff -u -r1.1 Raw.php
- --- Text/Wiki/Parse/Cowiki/Raw.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Raw.php 28 Oct 2008 02:23:52 -0000
- @@ -1,72 +1,67 @@
- <?php
- /**
- -*
- -* Parses for text marked as "raw" (i.e., to be rendered as-is).
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Raw.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Parses for text marked as "raw" (i.e., to be rendered as-is).
- +*
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Parses for text marked as "raw" (i.e., to be rendered as-is).
- -*
- + * Parses for text marked as "raw" (i.e., to be rendered as-is).
- +*
- * This class implements a Text_Wiki rule to find sections of the source
- * text that are not to be processed by Text_Wiki. These blocks of "raw"
- * text will be rendered as they were found.
- *
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- -
- -class Text_Wiki_Parse_Raw extends Text_Wiki_Parse {
- -
- -
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +
- +class Text_Wiki_Parse_Raw extends Text_Wiki_Parse
- +{
- +
- +
- /**
- - *
- - * The regular expression used to find source text matching this
- - * rule.
- - *
- - * @access public
- - *
- - * @var string
- - *
- - */
- -
- + * The regular expression used to find source text matching this
- + * rule.
- + *
- + * @access public
- + *
- + * @var string
- + *
- + */
- +
- var $regex = '/<noop>(.*)<\/noop>/U';
- /**
- - *
- - * Generates a token entry for the matched text. Token options are:
- - *
- - * 'text' => The full matched text.
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return A delimited token number to be used as a placeholder in
- - * the source text.
- - *
- - */
- -
- + * Generates a token entry for the matched text. Token options are:
- + *
- + * 'text' => The full matched text.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return A delimited token number to be used as a placeholder in
- + * the source text.
- + */
- +
- function process(&$matches)
- {
- $options = array('text' => strlen($matches[1]) ? $matches[1] : $matches[2]);
- return $this->wiki->addToken($this->rule, $options);
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Revise.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Revise.php,v
- retrieving revision 1.1
- diff -u -r1.1 Revise.php
- --- Text/Wiki/Parse/Cowiki/Revise.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Revise.php 28 Oct 2008 02:23:52 -0000
- @@ -1,131 +1,126 @@
- <?php
- /**
- -*
- -* Parses for text marked as revised (insert/delete).
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Revise.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Parses for text marked as revised (insert/delete).
- +*
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Parses for text marked as revised (insert/delete).
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- -//Not used in CoWiki
- -//Added strikethrough :-)
- -class Text_Wiki_Parse_Revise extends Text_Wiki_Parse {
- -
- -
- + * Parses for text marked as revised (insert/delete).
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +class Text_Wiki_Parse_Revise extends Text_Wiki_Parse
- +{
- +
- +
- /**
- - *
- - * The regular expression used to parse the source text and find
- - * matches conforming to this rule. Used by the parse() method.
- - *
- - * @access public
- - *
- - * @var string
- - *
- - * @see parse()
- - *
- - */
- -
- + * The regular expression used to parse the source text and find
- + * matches conforming to this rule. Used by the parse() method.
- + *
- + * @access public
- + * @var string
- + * @see parse()
- + */
- var $regex = "/\@\@({*?.*}*?)\@\@/U";
- -
- -
- +
- +
- /**
- - *
- - * Config options.
- - *
- - * @access public
- - *
- - * @var array
- - *
- - */
- -
- + * Config options.
- + *
- + * @access public
- + * @var array
- + */
- +
- var $conf = array(
- 'delmark' => '---',
- 'insmark' => '+++'
- );
- + /**
- + * Parse.
- + *
- + * @return void
- + */
- function parse()
- {
- - $this->wiki->source = preg_replace_callback(
- - $this->regex,
- + $this->wiki->source = preg_replace_callback($this->regex,
- array(&$this, 'process'),
- - $this->wiki->source
- - );
- -
- + $this->wiki->source);
- +
- $tmp_regex = '!-(.*?)-!';
- - $this->wiki->source = preg_replace_callback(
- - $tmp_regex,
- +
- + $this->wiki->source = preg_replace_callback($tmp_regex,
- array(&$this, 'processDel'),
- - $this->wiki->source
- - );
- + $this->wiki->source);
- - }
- + }
- - function processDel($matches) {
- + /**
- + * ProcessDel
- + *
- + * @param string[] $matches Matches
- + *
- + * @return object
- + */
- + function processDel($matches)
- + {
- return $this->wiki->addToken($this->rule, array('type' => 'del_start')).
- $matches[1].
- $this->wiki->addToken($this->rule, array('type' => 'del_end'));
- }
- -
- -
- +
- +
- /**
- - *
- - * Generates a replacement for the matched text. Token options are:
- - *
- - * 'type' => ['start'|'end'] The starting or ending point of the
- - * inserted text. The text itself is left in the source.
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return string A pair of delimited tokens to be used as a
- - * placeholder in the source text surrounding the teletype text.
- - *
- - */
- -
- + * Generates a replacement for the matched text. Token options are:
- + * 'type' => ['start'|'end'] The starting or ending point of the
- + * inserted text. The text itself is left in the source.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return string A pair of delimited tokens to be used as a
- + * placeholder in the source text surrounding the teletype text.
- + */
- function process(&$matches)
- {
- $output = '';
- - $src = $matches[1];
- + $src = $matches[1];
- +
- $delmark = $this->getConf('delmark'); // ---
- $insmark = $this->getConf('insmark'); // +++
- -
- +
- // '---' must be before '+++' (if they both appear)
- $del = strpos($src, $delmark);
- $ins = strpos($src, $insmark);
- -
- +
- // if neither is found, return right away
- if ($del === false && $ins === false) {
- return $matches[0];
- }
- -
- +
- // handle text to be deleted
- if ($del !== false) {
- -
- +
- // move forward to the end of the deletion mark
- $del += strlen($delmark);
- -
- +
- if ($ins === false) {
- // there is no insertion text following
- $text = substr($src, $del);
- @@ -134,37 +129,33 @@
- // mitigate the length
- $text = substr($src, $del, $ins - $del);
- }
- -
- - $output .= $this->wiki->addToken(
- - $this->rule, array('type' => 'del_start')
- - );
- -
- +
- + $output .= $this->wiki->addToken($this->rule,
- + array('type' => 'del_start'));
- +
- $output .= $text;
- -
- - $output .= $this->wiki->addToken(
- - $this->rule, array('type' => 'del_end')
- - );
- +
- + $output .= $this->wiki->addToken($this->rule,
- + array('type' => 'del_end'));
- }
- -
- +
- // handle text to be inserted
- if ($ins !== false) {
- -
- +
- // move forward to the end of the insert mark
- $ins += strlen($insmark);
- $text = substr($src, $ins);
- -
- - $output .= $this->wiki->addToken(
- - $this->rule, array('type' => 'ins_start')
- - );
- -
- +
- + $output .= $this->wiki->addToken($this->rule,
- + array('type' => 'ins_start'));
- +
- $output .= $text;
- -
- - $output .= $this->wiki->addToken(
- - $this->rule, array('type' => 'ins_end')
- - );
- +
- + $output .= $this->wiki->addToken($this->rule,
- + array('type' => 'ins_end'));
- }
- -
- +
- return $output;
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Strong.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Strong.php,v
- retrieving revision 1.1
- diff -u -r1.1 Strong.php
- --- Text/Wiki/Parse/Cowiki/Strong.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Strong.php 28 Oct 2008 02:23:52 -0000
- @@ -1,85 +1,75 @@
- <?php
- /**
- -*
- -* Parses for strongly-emphasized text.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Strong.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Parses for strongly-emphasized text.
- +*
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Parses for strongly-emphasized text.
- -*
- -* This class implements a Text_Wiki_Parse to find source text marked for
- -* strong emphasis (bold) as defined by text surrounded by three
- -* single-quotes. On parsing, the text itself is left in place, but the
- -* starting and ending instances of three single-quotes are replaced with
- -* tokens.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- -
- -class Text_Wiki_Parse_Strong extends Text_Wiki_Parse {
- -
- -
- + * Parses for strongly-emphasized text.
- + *
- + * This class implements a Text_Wiki_Parse to find source text marked for
- + * strong emphasis (bold) as defined by text surrounded by three
- + * single-quotes. On parsing, the text itself is left in place, but the
- + * starting and ending instances of three single-quotes are replaced with
- + * tokens.
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +
- +class Text_Wiki_Parse_Strong extends Text_Wiki_Parse
- +{
- +
- +
- /**
- - *
- - * The regular expression used to parse the source text and find
- - * matches conforming to this rule. Used by the parse() method.
- - *
- - * @access public
- - *
- - * @var string
- - *
- - * @see parse()
- - *
- - */
- -
- + * The regular expression used to parse the source text and find
- + * matches conforming to this rule. Used by the parse() method.
- + *
- + * @access public
- + *
- + * @var string
- + *
- + * @see parse()
- + *
- + */
- +
- var $regex = '/\*(.*?)\*/';
- -
- +
- /**
- - *
- - * Generates a replacement for the matched text. Token options are:
- - *
- - * 'type' => ['start'|'end'] The starting or ending point of the
- - * emphasized text. The text itself is left in the source.
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return A pair of delimited tokens to be used as a placeholder in
- - * the source text surrounding the text to be emphasized.
- - *
- - */
- -
- + * Generates a replacement for the matched text. Token options are:
- + *
- + * 'type' => ['start'|'end'] The starting or ending point of the
- + * emphasized text. The text itself is left in the source.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return A pair of delimited tokens to be used as a placeholder in
- + * the source text surrounding the text to be emphasized.
- + *
- + */
- function process(&$matches)
- {
- - $start = $this->wiki->addToken(
- - $this->rule, array('type' => 'start')
- - );
- -
- - $end = $this->wiki->addToken(
- - $this->rule, array('type' => 'end')
- - );
- -
- + $start = $this->wiki->addToken($this->rule, array('type' => 'start'));
- + $end = $this->wiki->addToken($this->rule, array('type' => 'end'));
- +
- return $start . $matches[1] . $end;
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Subscript.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Subscript.php,v
- retrieving revision 1.1
- diff -u -r1.1 Subscript.php
- --- Text/Wiki/Parse/Cowiki/Subscript.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Subscript.php 28 Oct 2008 02:23:52 -0000
- @@ -1,79 +1,64 @@
- <?php
- -
- /**
- -*
- -* Parses for subscripted text.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Subscript.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Parses for subscripted text.
- + *
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Parses for subscripted text.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- -
- -class Text_Wiki_Parse_Subscript extends Text_Wiki_Parse {
- -
- -
- + * Parses for subscripted text.
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +class Text_Wiki_Parse_Subscript extends Text_Wiki_Parse
- +{
- +
- /**
- - *
- - * The regular expression used to parse the source text and find
- - * matches conforming to this rule. Used by the parse() method.
- - *
- - * @access public
- - *
- - * @var string
- - *
- - * @see parse()
- - *
- - */
- -
- + * The regular expression used to parse the source text and find
- + * matches conforming to this rule. Used by the parse() method.
- + *
- + * @access public
- + *
- + * @var string
- + *
- + * @see parse()
- + */
- var $regex = '/<sub>(()|.*)<\/sub>/U';
- -
- -
- +
- +
- /**
- - *
- - * Generates a replacement for the matched text. Token options are:
- - *
- - * 'type' => ['start'|'end'] The starting or ending point of the
- - * emphasized text. The text itself is left in the source.
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return A pair of delimited tokens to be used as a placeholder in
- - * the source text surrounding the text to be emphasized.
- - *
- - */
- -
- + * Generates a replacement for the matched text. Token options are:
- + *
- + * 'type' => ['start'|'end'] The starting or ending point of the
- + * emphasized text. The text itself is left in the source.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return A pair of delimited tokens to be used as a placeholder in
- + * the source text surrounding the text to be emphasized.
- + */
- function process(&$matches)
- {
- - $start = $this->wiki->addToken(
- - $this->rule, array('type' => 'start')
- - );
- -
- - $end = $this->wiki->addToken(
- - $this->rule, array('type' => 'end')
- - );
- -
- +
- + $start = $this->wiki->addToken($this->rule, array('type' => 'start'));
- + $end = $this->wiki->addToken($this->rule, array('type' => 'end'));
- +
- return $start . $matches[1] . $end;
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Superscript.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Superscript.php,v
- retrieving revision 1.1
- diff -u -r1.1 Superscript.php
- --- Text/Wiki/Parse/Cowiki/Superscript.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Superscript.php 28 Oct 2008 02:23:52 -0000
- @@ -1,79 +1,70 @@
- <?php
- /**
- -*
- -* Parses for superscripted text.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Superscript.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Parses for superscripted text.
- +*
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Parses for superscripted text.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- -
- -class Text_Wiki_Parse_Superscript extends Text_Wiki_Parse {
- -
- -
- + * Parses for superscripted text.
- +*
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +
- +class Text_Wiki_Parse_Superscript extends Text_Wiki_Parse
- +{
- +
- +
- /**
- - *
- - * The regular expression used to parse the source text and find
- - * matches conforming to this rule. Used by the parse() method.
- - *
- - * @access public
- - *
- - * @var string
- - *
- - * @see parse()
- - *
- - */
- -
- + * The regular expression used to parse the source text and find
- + * matches conforming to this rule. Used by the parse() method.
- + *
- + * @access public
- + *
- + * @var string
- + *
- + * @see parse()
- + *
- + */
- +
- var $regex = '/<sup>(()|.*)<\/sup>/U';
- -
- -
- +
- +
- /**
- - *
- - * Generates a replacement for the matched text. Token options are:
- - *
- - * 'type' => ['start'|'end'] The starting or ending point of the
- - * emphasized text. The text itself is left in the source.
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return A pair of delimited tokens to be used as a placeholder in
- - * the source text surrounding the text to be emphasized.
- - *
- - */
- -
- + * Generates a replacement for the matched text. Token options are:
- + *
- + * 'type' => ['start'|'end'] The starting or ending point of the
- + * emphasized text. The text itself is left in the source.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return A pair of delimited tokens to be used as a placeholder in
- + * the source text surrounding the text to be emphasized.
- + *
- + */
- +
- function process(&$matches)
- {
- - $start = $this->wiki->addToken(
- - $this->rule, array('type' => 'start')
- - );
- -
- - $end = $this->wiki->addToken(
- - $this->rule, array('type' => 'end')
- - );
- -
- + $start = $this->wiki->addToken($this->rule, array('type' => 'start'));
- + $end = $this->wiki->addToken($this->rule, array('type' => 'end'));
- +
- return $start . $matches[1] . $end;
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Table.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Table.php,v
- retrieving revision 1.1
- diff -u -r1.1 Table.php
- --- Text/Wiki/Parse/Cowiki/Table.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Table.php 28 Oct 2008 02:23:52 -0000
- @@ -1,89 +1,82 @@
- <?php
- -
- /**
- -*
- -* Parses for table markup.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Table.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Parses for table markup.
- + *
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Parses for table markup.
- -*
- -* This class implements a Text_Wiki_Parse to find source text marked as a
- -* set of table rows, where a line start and ends with double-pipes (||)
- -* and uses double-pipes to separate table cells. The rows must be on
- -* sequential lines (no blank lines between them) -- a blank line
- -* indicates the beginning of a new table.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- -
- -class Text_Wiki_Parse_Table extends Text_Wiki_Parse {
- -
- -
- + * Parses for table markup.
- + *
- + * This class implements a Text_Wiki_Parse to find source text marked as a
- + * set of table rows, where a line start and ends with double-pipes (||)
- + * and uses double-pipes to separate table cells. The rows must be on
- + * sequential lines (no blank lines between them) -- a blank line
- + * indicates the beginning of a new table.
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +
- +class Text_Wiki_Parse_Table extends Text_Wiki_Parse
- +{
- +
- +
- /**
- - *
- - * The regular expression used to parse the source text and find
- - * matches conforming to this rule. Used by the parse() method.
- - *
- - * @access public
- - *
- - * @var string
- - *
- - * @see parse()
- - *
- - */
- -
- + * The regular expression used to parse the source text and find
- + * matches conforming to this rule. Used by the parse() method.
- + *
- + * @access public
- + *
- + * @var string
- + *
- + * @see parse()
- + *
- + */
- +
- var $regex = '/\n<table( [^>]*)?>(.*?)<\/table>\n/Us';
- -
- -
- +
- +
- /**
- - *
- - * Generates a replacement for the matched text.
- - *
- - * Token options are:
- - *
- - * 'type' =>
- - * 'table_start' : the start of a bullet list
- - * 'table_end' : the end of a bullet list
- - * 'row_start' : the start of a number list
- - * 'row_end' : the end of a number list
- - * 'cell_start' : the start of item text (bullet or number)
- - * 'cell_end' : the end of item text (bullet or number)
- - *
- - * 'cols' => the number of columns in the table (for 'table_start')
- - *
- - * 'rows' => the number of rows in the table (for 'table_start')
- - *
- - * 'span' => column span (for 'cell_start')
- - *
- - * 'attr' => column attribute flag (for 'cell_start')
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return A series of text and delimited tokens marking the different
- - * table elements and cell text.
- - *
- - */
- -
- + * Generates a replacement for the matched text.
- + *
- + * Token options are:
- + *
- + * 'type' =>
- + * 'table_start' : the start of a bullet list
- + * 'table_end' : the end of a bullet list
- + * 'row_start' : the start of a number list
- + * 'row_end' : the end of a number list
- + * 'cell_start' : the start of item text (bullet or number)
- + * 'cell_end' : the end of item text (bullet or number)
- + *
- + * 'cols' => the number of columns in the table (for 'table_start')
- + *
- + * 'rows' => the number of rows in the table (for 'table_start')
- + *
- + * 'span' => column span (for 'cell_start')
- + *
- + * 'attr' => column attribute flag (for 'cell_start')
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return A series of text and delimited tokens marking the different
- + * table elements and cell text.
- + */
- function process(&$matches)
- {
- if (strlen(trim($matches[1]))) {
- @@ -94,121 +87,102 @@
- // our eventual return value
- $return = '';
- -
- +
- // the number of columns in the table
- $num_cols = 0;
- -
- +
- // the number of rows in the table
- $num_rows = 0;
- -
- +
- // rows are separated by newlines in the matched text
- $rows = explode("\n", $matches[2]);
- -
- +
- // loop through each row
- foreach ($rows as $row) {
- if (!strlen($row)) {
- continue;
- }
- -
- +
- // increase the row count
- ++$num_rows;
- -
- +
- // start a new row
- - $return .= $this->wiki->addToken(
- - $this->rule,
- - array('type' => 'row_start')
- - );
- -
- + $return .= $this->wiki->addToken($this->rule,
- + array('type' => 'row_start'));
- +
- // cells are separated by pipes
- $cells = explode('|', $row);
- -
- +
- // get the number of cells (columns) in this row
- $last = count($cells);
- -
- +
- // is this more than the current column count?
- if ($last - 1 > $num_cols) {
- // increase the column count
- $num_cols = $last - 1;
- }
- -
- +
- // by default, cells span only one column (their own)
- $span = 1;
- -
- +
- for ($i = 1; $i < $last; ++$i) {
- -
- +
- // if there is no content at all, then it's an instance
- // of two sets of || next to each other, indicating a
- // span.
- if ($cells[$i] == '') {
- -
- +
- // add to the span and loop to the next cell
- $span += 1;
- continue;
- -
- +
- } else {
- -
- +
- // this cell has content.
- - $attr = null;
- -
- + $attr = null;
- +
- // start a new cell...
- - $return .= $this->wiki->addToken(
- - $this->rule,
- - array (
- - 'type' => 'cell_start',
- - 'attr' => $attr,
- - 'span' => $span
- - )
- - );
- -
- + $return .= $this->wiki->addToken($this->rule,
- + array('type' => 'cell_start',
- + 'attr' => $attr,
- + 'span' => $span));
- +
- // ...add the content...
- $return .= trim($cells[$i]);
- -
- +
- // ...and end the cell.
- - $return .= $this->wiki->addToken(
- - $this->rule,
- - array (
- - 'type' => 'cell_end',
- - 'attr' => $attr,
- - 'span' => $span
- - )
- - );
- -
- + $return .= $this->wiki->addToken($this->rule,
- + array (
- + 'type' => 'cell_end',
- + 'attr' => $attr,
- + 'span' => $span));
- +
- // reset the span.
- $span = 1;
- }
- -
- +
- }
- -
- +
- // end the row
- - $return .= $this->wiki->addToken(
- - $this->rule,
- - array('type' => 'row_end')
- - );
- -
- + $return .= $this->wiki->addToken($this->rule,
- + array('type' => 'row_end'));
- +
- }
- -
- - // wrap the return value in start and end tokens
- +
- + // wrap the return value in start and end tokens
- $return =
- - $this->wiki->addToken(
- - $this->rule,
- - array(
- - 'type' => 'table_start',
- - 'rows' => $num_rows,
- - 'cols' => $num_cols,
- - 'attr' => $attr
- - )
- - )
- + $this->wiki->addToken($this->rule,
- + array('type' => 'table_start',
- + 'rows' => $num_rows,
- + 'cols' => $num_cols,
- + 'attr' => $attr))
- . $return .
- - $this->wiki->addToken(
- - $this->rule,
- - array(
- - 'type' => 'table_end'
- - )
- - );
- -
- + $this->wiki->addToken($this->rule,
- + array('type' => 'table_end'));
- +
- // we're done!
- return "\n$return\n\n";
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Tighten.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Tighten.php,v
- retrieving revision 1.1
- diff -u -r1.1 Tighten.php
- --- Text/Wiki/Parse/Cowiki/Tighten.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Tighten.php 28 Oct 2008 02:23:52 -0000
- @@ -1,49 +1,44 @@
- <?php
- -
- /**
- -*
- -* The rule removes all remaining newlines.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Tighten.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * The rule removes all remaining newlines.
- + *
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* The rule removes all remaining newlines.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- + * The rule removes all remaining newlines.
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +class Text_Wiki_Parse_Tighten extends Text_Wiki_Parse
- +{
- +
- -class Text_Wiki_Parse_Tighten extends Text_Wiki_Parse {
- -
- -
- /**
- - *
- - * Apply tightening directly to the source text.
- - *
- - * @access public
- - *
- - */
- -
- + * Apply tightening directly to the source text.
- + *
- + * @access public
- + * @return void
- + */
- function parse()
- {
- $this->wiki->source = str_replace("\n", '',
- $this->wiki->source);
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Toc.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Toc.php,v
- retrieving revision 1.1
- diff -u -r1.1 Toc.php
- --- Text/Wiki/Parse/Cowiki/Toc.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Toc.php 28 Oct 2008 02:23:52 -0000
- @@ -1,93 +1,81 @@
- <?php
- /**
- -*
- -* Looks through parsed text and builds a table of contents.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Toc.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Looks through parsed text and builds a table of contents.
- + *
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Looks through parsed text and builds a table of contents.
- -*
- -* This class implements a Text_Wiki_Parse to find all heading tokens and
- -* build a table of contents. The [[toc]] tag gets replaced with a list
- -* of all the level-2 through level-6 headings.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- -
- -
- -class Text_Wiki_Parse_Toc extends Text_Wiki_Parse {
- -
- -
- + * Looks through parsed text and builds a table of contents.
- + *
- + * This class implements a Text_Wiki_Parse to find all heading tokens and
- + * build a table of contents. The [[toc]] tag gets replaced with a list
- + * of all the level-2 through level-6 headings.
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +class Text_Wiki_Parse_Toc extends Text_Wiki_Parse
- +{
- +
- +
- /**
- - *
- - * The regular expression used to parse the source text and find
- - * matches conforming to this rule. Used by the parse() method.
- - *
- - * @access public
- - *
- - * @var string
- - *
- - * @see parse()
- - *
- - */
- -
- + * The regular expression used to parse the source text and find
- + * matches conforming to this rule. Used by the parse() method.
- + *
- + * @access public
- + *
- + * @var string
- + *
- + * @see parse()
- + *
- + */
- var $regex = "/\n<toc( [^>]*?)?>\n/m";
- -
- -
- +
- +
- /**
- - *
- - * Generates a replacement for the matched text.
- - *
- - * Token options are:
- - *
- - * 'type' => ['list_start'|'list_end'|'item_start'|'item_end'|'target']
- - *
- - * 'level' => The heading level (1-6).
- - *
- - * 'count' => Which entry number this is in the list.
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return string A token indicating the TOC collection point.
- - *
- - */
- -
- + * Generates a replacement for the matched text.
- + *
- + * Token options are:
- + *
- + * 'type' => ['list_start'|'list_end'|'item_start'|'item_end'|'target']
- + *
- + * 'level' => The heading level (1-6).
- + *
- + * 'count' => Which entry number this is in the list.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return string A token indicating the TOC collection point.
- + *
- + */
- function process(&$matches)
- {
- $count = 0;
- -
- +
- if (isset($matches[1])) {
- $attr = $this->getAttrs(trim($matches[1]));
- } else {
- $attr = array();
- }
- -
- - return $this->wiki->addToken(
- - $this->rule,
- - array(
- - 'attr' => $attr
- - )
- - );
- +
- + return $this->wiki->addToken($this->rule,
- + array('attr' => $attr));
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Tt.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Tt.php,v
- retrieving revision 1.1
- diff -u -r1.1 Tt.php
- --- Text/Wiki/Parse/Cowiki/Tt.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Tt.php 28 Oct 2008 02:23:52 -0000
- @@ -1,84 +1,75 @@
- <?php
- /**
- -*
- -* Find source text marked for teletype (monospace).
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Tt.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Find source text marked for teletype (monospace).
- +*
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Find source text marked for teletype (monospace).
- -*
- + * Find source text marked for teletype (monospace).
- +*
- * Defined by text surrounded by two curly braces. On parsing, the text
- * itself is left in place, but the starting and ending instances of
- * curly braces are replaced with tokens.
- -*
- +*
- * Token options are:
- -*
- +*
- * 'type' => ['start'|'end'] The starting or ending point of the
- * teletype text. The text itself is left in the source.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- -
- -class Text_Wiki_Parse_Tt extends Text_Wiki_Parse {
- -
- -
- +*
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +
- +class Text_Wiki_Parse_Tt extends Text_Wiki_Parse
- +{
- +
- +
- /**
- - *
- - * The regular expression used to parse the source text.
- - *
- - * @access public
- - *
- - * @var string
- - *
- - * @see parse()
- - *
- - */
- -
- + * The regular expression used to parse the source text.
- + *
- + * @access public
- + *
- + * @var string
- + *
- + * @see parse()
- + *
- + */
- +
- var $regex = "/=({*?.*}*?)=/U";
- -
- -
- +
- +
- /**
- - *
- - * Generates a replacement for the matched text.
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return string A pair of delimited tokens to be used as a
- - * placeholder in the source text surrounding the teletype text.
- - *
- - */
- -
- + * Generates a replacement for the matched text.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return string A pair of delimited tokens to be used as a
- + * placeholder in the source text surrounding the teletype text.
- + *
- + */
- +
- function process(&$matches)
- {
- - $start = $this->wiki->addToken(
- - $this->rule, array('type' => 'start')
- - );
- -
- - $end = $this->wiki->addToken(
- - $this->rule, array('type' => 'end')
- - );
- -
- + $start = $this->wiki->addToken($this->rule, array('type' => 'start'));
- + $end = $this->wiki->addToken($this->rule, array('type' => 'end'));
- +
- return $start . $matches[1] . $end;
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Underline.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Underline.php,v
- retrieving revision 1.1
- diff -u -r1.1 Underline.php
- --- Text/Wiki/Parse/Cowiki/Underline.php 21 Jul 2005 20:56:13 -0000 1.1
- +++ Text/Wiki/Parse/Cowiki/Underline.php 28 Oct 2008 02:23:52 -0000
- @@ -1,79 +1,73 @@
- <?php
- /**
- -*
- -* Parses for bold text.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Underline.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- -*
- -*/
- + * Parses for bold text.
- +*
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Parses for bold text.
- -*
- -* This class implements a Text_Wiki_Rule to find source text marked for
- -* strong emphasis (bold) as defined by text surrounded by three
- -* single-quotes. On parsing, the text itself is left in place, but the
- -* starting and ending instances of three single-quotes are replaced with
- -* tokens.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- -
- -class Text_Wiki_Parse_Underline extends Text_Wiki_Parse {
- -
- -
- + * Parses for bold text.
- + *
- + * This class implements a Text_Wiki_Rule to find source text marked for
- + * strong emphasis (bold) as defined by text surrounded by three
- + * single-quotes. On parsing, the text itself is left in place, but the
- + * starting and ending instances of three single-quotes are replaced with
- + * tokens.
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +
- +class Text_Wiki_Parse_Underline extends Text_Wiki_Parse
- +{
- +
- +
- /**
- - *
- - * The regular expression used to parse the source text and find
- - * matches conforming to this rule. Used by the parse() method.
- - *
- - * @access public
- - *
- - * @var string
- - *
- - * @see parse()
- - *
- - */
- -
- + * The regular expression used to parse the source text and find
- + * matches conforming to this rule. Used by the parse() method.
- + *
- + * @access public
- + *
- + * @var string
- + *
- + * @see parse()
- + *
- + */
- +
- var $regex = '/_(()|.*)_/U';
- -
- -
- +
- +
- /**
- - *
- - * Generates a replacement for the matched text. Token options are:
- - *
- - * 'type' => ['start'|'end'] The starting or ending point of the
- - * emphasized text. The text itself is left in the source.
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return A pair of delimited tokens to be used as a placeholder in
- - * the source text surrounding the text to be emphasized.
- - *
- - */
- -
- + * Generates a replacement for the matched text. Token options are:
- + *
- + * 'type' => ['start'|'end'] The starting or ending point of the
- + * emphasized text. The text itself is left in the source.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + * @return A pair of delimited tokens to be used as a placeholder in
- + * the source text surrounding the text to be emphasized.
- + */
- function process(&$matches)
- {
- $start = $this->wiki->addToken($this->rule, array('type' => 'start'));
- - $end = $this->wiki->addToken($this->rule, array('type' => 'end'));
- + $end = $this->wiki->addToken($this->rule, array('type' => 'end'));
- return $start . $matches[1] . $end;
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Url.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Url.php,v
- retrieving revision 1.2
- diff -u -r1.2 Url.php
- --- Text/Wiki/Parse/Cowiki/Url.php 14 Mar 2006 02:18:54 -0000 1.2
- +++ Text/Wiki/Parse/Cowiki/Url.php 28 Oct 2008 02:23:52 -0000
- @@ -1,80 +1,75 @@
- <?php
- -
- /**
- -*
- -* Parse for URLS in the source text.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Url.php,v 1.2 2006/03/14 02:18:54 justinpatrin Exp $
- -*
- -*/
- + * Parse for URLS in the source text.
- + *
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Parse for URLS in the source text.
- -*
- -* Various URL markings are supported: inline (the URL by itself),
- -* numbered or footnote reference (where the URL is enclosed in square
- -* brackets), and named reference (where the URL is enclosed in square
- -* brackets and has a name included inside the brackets). E.g.:
- -*
- -* inline -- http://example.com
- -* numbered -- [http://example.com]
- -* described -- [http://example.com Example Description]
- -*
- -* When rendering a URL token, this will convert URLs pointing to a .gif,
- -* .jpg, or .png image into an inline <img /> tag (for the 'xhtml'
- -* format).
- -*
- -* Token options are:
- -*
- -* 'type' => ['inline'|'footnote'|'descr'] the type of URL
- -*
- -* 'href' => the URL link href portion
- -*
- -* 'text' => the displayed text of the URL link
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- -
- -class Text_Wiki_Parse_Url extends Text_Wiki_Parse {
- -
- -
- + * Parse for URLS in the source text.
- + *
- + * Various URL markings are supported: inline (the URL by itself),
- + * numbered or footnote reference (where the URL is enclosed in square
- + * brackets), and named reference (where the URL is enclosed in square
- + * brackets and has a name included inside the brackets). E.g.:
- + *
- + * inline -- http://example.com
- + * numbered -- [http://example.com]
- + * described -- [http://example.com Example Description]
- + *
- + * When rendering a URL token, this will convert URLs pointing to a .gif,
- + * .jpg, or .png image into an inline <img /> tag (for the 'xhtml'
- + * format).
- + *
- + * Token options are:
- + *
- + * 'type' => ['inline'|'footnote'|'descr'] the type of URL
- + *
- + * 'href' => the URL link href portion
- + *
- + * 'text' => the displayed text of the URL link
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +class Text_Wiki_Parse_Url extends Text_Wiki_Parse
- +{
- +
- +
- /**
- - *
- - * Keeps a running count of numbered-reference URLs.
- - *
- - * @access public
- - *
- - * @var int
- - *
- - */
- -
- + * Keeps a running count of numbered-reference URLs.
- + *
- + * @access public
- + *
- + * @var int
- + *
- + */
- +
- var $footnoteCount = 0;
- -
- -
- +
- +
- /**
- - *
- - * URL schemes recognized by this rule.
- - *
- - * @access public
- - *
- - * @var array
- - *
- - */
- -
- + * URL schemes recognized by this rule.
- + *
- + * @access public
- + *
- + * @var array
- + *
- + */
- +
- var $conf = array(
- 'schemes' => array(
- 'http://',
- @@ -85,77 +80,77 @@
- 'mailto:'
- )
- );
- -
- -
- +
- +
- /**
- - *
- - * Constructor.
- - *
- - * We override the constructor so we can comment the regex nicely.
- - *
- - * @access public
- - *
- - */
- -
- + * Constructor.
- + *
- + * We override the constructor so we can comment the regex nicely.
- + *
- + * @param Text_Wiki &$obj The calling object
- + *
- + * @access public
- + */
- function Text_Wiki_Parse_Url(&$obj)
- {
- parent::Text_Wiki_Parse($obj);
- -
- +
- // convert the list of recognized schemes to a regex-safe string,
- // where the pattern delim is a slash
- - $tmp = array();
- + $tmp = array();
- $list = $this->getConf('schemes', array());
- foreach ($list as $val) {
- $tmp[] = preg_quote($val, '/');
- }
- $schemes = implode('|', $tmp);
- -
- +
- // build the regex
- $this->regex =
- "($schemes)" . // allowed schemes
- "(" . // start pattern
- - "[^ \\/\"\'\(\)".$this->wiki->delim."]*\\/" . // no spaces, backslashes, slashes, double-quotes, single quotes, or delimiters;
- +
- + // no spaces, backslashes, slashes, double-quotes,
- + // single quotes, or delimiters;
- + "[^ \\/\"\'\(\)".$this->wiki->delim."]*\\/" .
- +
- +
- ")*" . // end pattern
- "[^ \\t\\n\\/\"\'\(\)".$this->wiki->delim."]*" .
- "[A-Za-z0-9\\/?=&~_]";
- }
- -
- -
- +
- +
- /**
- - *
- - * Find three different kinds of URLs in the source text.
- - *
- - * @access public
- - *
- - */
- -
- + * Find three different kinds of URLs in the source text.
- + *
- + * @access public
- + * @return void
- + */
- function parse()
- {
- // -------------------------------------------------------------
- - //
- + //
- // Described-reference (named) URLs.
- - //
- -
- + //
- +
- // the regular expression for this kind of URL
- $tmp_regex = '/\(\((' . $this->regex . ')(\)\(([^\)\(]+))?\)\)/';
- // use a custom callback processing method to generate
- // the replacement text for matches.
- - $this->wiki->source = preg_replace_callback(
- - $tmp_regex,
- - array(&$this, 'processDescr'),
- - $this->wiki->source
- - );
- -
- -
- + $this->wiki->source = preg_replace_callback($tmp_regex,
- + array(&$this, 'processDescr'),
- + $this->wiki->source);
- +
- +
- // -------------------------------------------------------------
- - //
- + //
- // Numbered-reference (footnote-style) URLs.
- - //
- -
- + //
- +
- // the regular expression for this kind of URL
- /*$tmp_regex = '/\(\((' . $this->regex . ')\)\)/U';
- -
- +
- // use a custom callback processing method to generate
- // the replacement text for matches.
- $this->wiki->source = preg_replace_callback(
- @@ -163,41 +158,34 @@
- array(&$this, 'processFootnote'),
- $this->wiki->source
- );*/
- -
- -
- +
- +
- // -------------------------------------------------------------
- - //
- + //
- // Normal inline URLs.
- - //
- -
- + //
- +
- // the regular expression for this kind of URL
- -
- +
- $tmp_regex = '/(^|[^A-Za-z])(' . $this->regex . ')(.*?)/';
- -
- +
- // use the standard callback for inline URLs
- - $this->wiki->source = preg_replace_callback(
- - $tmp_regex,
- - array(&$this, 'process'),
- - $this->wiki->source
- - );
- + $this->wiki->source = preg_replace_callback($tmp_regex,
- + array(&$this, 'process'),
- + $this->wiki->source);
- }
- -
- -
- +
- +
- /**
- - *
- - * Process inline URLs.
- - *
- - * @param array &$matches
- - *
- - * @param array $matches An array of matches from the parse() method
- - * as generated by preg_replace_callback. $matches[0] is the full
- - * matched string, $matches[1] is the first matched pattern,
- - * $matches[2] is the second matched pattern, and so on.
- - *
- - * @return string The processed text replacement.
- - *
- - */
- -
- + * Process inline URLs.
- + *
- + * @param array &$matches An array of matches from the parse() method
- + * as generated by preg_replace_callback. $matches[0] is the full
- + * matched string, $matches[1] is the first matched pattern,
- + * $matches[2] is the second matched pattern, and so on.
- + *
- + * @return string The processed text replacement.
- + */
- function process(&$matches)
- {
- // set options
- @@ -206,76 +194,75 @@
- 'href' => $matches[2],
- 'text' => $matches[2]
- );
- -
- +
- // tokenize
- - return $matches[1] . $this->wiki->addToken($this->rule, $options) . $matches[5];
- + return $matches[1]
- + . $this->wiki->addToken($this->rule, $options)
- + . $matches[5];
- }
- -
- -
- +
- +
- /**
- - *
- - * Process numbered (footnote) URLs.
- - *
- - * Token options are:
- - * @param array &$matches
- - *
- - * @param array $matches An array of matches from the parse() method
- - * as generated by preg_replace_callback. $matches[0] is the full
- - * matched string, $matches[1] is the first matched pattern,
- - * $matches[2] is the second matched pattern, and so on.
- - *
- - * @return string The processed text replacement.
- - *
- - */
- -
- + * Process numbered (footnote) URLs.
- + *
- + * Token options are:
- + *
- + * @param array &$matches An array of matches from the parse() method
- + * as generated by preg_replace_callback. $matches[0] is the full
- + * matched string, $matches[1] is the first matched pattern,
- + * $matches[2] is the second matched pattern, and so on.
- + *
- + * @return string The processed text replacement.
- + *
- + */
- +
- function processFootnote(&$matches)
- {
- - // keep a running count for footnotes
- + // keep a running count for footnotes
- $this->footnoteCount++;
- -
- +
- // set options
- $options = array(
- 'type' => 'footnote',
- 'href' => $matches[1],
- 'text' => $this->footnoteCount
- );
- -
- +
- // tokenize
- return $this->wiki->addToken($this->rule, $options);
- }
- -
- -
- +
- +
- /**
- - *
- - * Process described-reference (named-reference) URLs.
- - *
- - * Token options are:
- - * 'type' => ['inline'|'footnote'|'descr'] the type of URL
- - * 'href' => the URL link href portion
- - * 'text' => the displayed text of the URL link
- - *
- - * @param array &$matches
- - *
- - * @param array $matches An array of matches from the parse() method
- - * as generated by preg_replace_callback. $matches[0] is the full
- - * matched string, $matches[1] is the first matched pattern,
- - * $matches[2] is the second matched pattern, and so on.
- - *
- - * @return string The processed text replacement.
- - *
- - */
- -
- + * Process described-reference (named-reference) URLs.
- + *
- + * Token options are:
- + * 'type' => ['inline'|'footnote'|'descr'] the type of URL
- + * 'href' => the URL link href portion
- + * 'text' => the displayed text of the URL link
- + *
- + * @param array &$matches An array of matches from the parse() method
- + * as generated by preg_replace_callback. $matches[0] is the full
- + * matched string, $matches[1] is the first matched pattern,
- + * $matches[2] is the second matched pattern, and so on.
- + *
- + * @return string The processed text replacement.
- + *
- + */
- +
- function processDescr(&$matches)
- {
- + $result = isset($matches[5]) && strlen($matches[5]);
- +
- // set options
- $options = array(
- 'type' => 'descr',
- 'href' => $matches[1],
- - 'text' => isset($matches[5]) && strlen($matches[5]) ? $matches[5] : $matches[1],
- + 'text' => $result ? $matches[5] : $matches[1],
- );
- // tokenize
- return $this->wiki->addToken($this->rule, $options);
- }
- }
- -?>
- \ No newline at end of file
- +?>
- Index: Text/Wiki/Parse/Cowiki/Wikilink.php
- ===================================================================
- RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Wikilink.php,v
- retrieving revision 1.5
- diff -u -r1.5 Wikilink.php
- --- Text/Wiki/Parse/Cowiki/Wikilink.php 8 Dec 2006 08:23:51 -0000 1.5
- +++ Text/Wiki/Parse/Cowiki/Wikilink.php 28 Oct 2008 02:23:52 -0000
- @@ -1,89 +1,83 @@
- <?php
- -
- /**
- -*
- -* Parse for links to wiki pages.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -* @license LGPL
- -*
- -* @version $Id: Wikilink.php,v 1.5 2006/12/08 08:23:51 justinpatrin Exp $
- -*
- -*/
- + * Parse for links to wiki pages.
- + *
- + * PHP version 4, 5
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
- + * @link http://pear.php.net/package/Text_Wiki
- + */
- /**
- -*
- -* Parse for links to wiki pages.
- -*
- -* Wiki page names are typically in StudlyCapsStyle made of
- -* WordsSmashedTogether.
- -*
- -* You can also create described links to pages in this style:
- -* [WikiPageName nice text link to use for display]
- -*
- -* The token options for this rule are:
- -*
- -* 'page' => the wiki page name.
- -*
- -* 'text' => the displayed link text.
- -*
- -* 'anchor' => a named anchor on the target wiki page.
- -*
- -* @category Text
- -*
- -* @package Text_Wiki
- -*
- -* @author Paul M. Jones <pmjones@php.net>
- -*
- -*/
- + * Parse for links to wiki pages.
- + *
- + * Wiki page names are typically in StudlyCapsStyle made of
- + * WordsSmashedTogether.
- + *
- + * You can also create described links to pages in this style:
- + * [WikiPageName nice text link to use for display]
- + *
- + * The token options for this rule are:
- + *
- + * 'page' => the wiki page name.
- + *
- + * 'text' => the displayed link text.
- + *
- + * 'anchor' => a named anchor on the target wiki page.
- + *
- + * @category Text
- + * @package Text_Wiki
- + * @author Paul M. Jones <pmjones@php.net>
- + * @copyright 2005 Paul M. Jones
- + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- + * @version Release: @package_version@
- + * @link http://pear.php.net/package/Text_Wiki
- + * @see Text_Wiki_Parse::Text_Wiki_Parse()
- + */
- +class Text_Wiki_Parse_Wikilink extends Text_Wiki_Parse
- +{
- -class Text_Wiki_Parse_Wikilink extends Text_Wiki_Parse {
- -
- var $conf = array (
- 'ext_chars' => false,
- 'utf-8' => false
- );
- -
- +
- /**
- - *
- - * Constructor.
- - *
- - * We override the Text_Wiki_Parse constructor so we can
- - * explicitly comment each part of the $regex property.
- - *
- - * @access public
- - *
- - * @param object &$obj The calling "parent" Text_Wiki object.
- - *
- - */
- -
- + * Constructor.
- + *
- + * We override the Text_Wiki_Parse constructor so we can
- + * explicitly comment each part of the $regex property.
- + *
- + * @param object &$obj The calling "parent" Text_Wiki object.
- + *
- + * @access public
- + */
- function Text_Wiki_Parse_Wikilink(&$obj)
- {
- parent::Text_Wiki_Parse($obj);
- if ($this->getConf('utf-8')) {
- - $upper = 'A-Z\p{Lu}';
- - $lower = 'a-z0-9\p{Ll}';
- - $either = 'A-Za-z0-9\p{L}';
- + $upper = 'A-Z\p{Lu}';
- + $lower = 'a-z0-9\p{Ll}';
- + $either = 'A-Za-z0-9\p{L}';
- } else if ($this->getConf('ext_chars')) {
- - // use an extended character set; this should
- - // allow for umlauts and so on. taken from the
- - // Tavi project defaults.php file.
- - $upper = 'A-Z\xc0-\xde';
- - $lower = 'a-z0-9\xdf-\xfe';
- - $either = 'A-Za-z0-9\xc0-\xfe';
- - } else {
- - // the default character set, should be fine
- - // for most purposes.
- - $upper = "A-Z";
- - $lower = "a-z0-9";
- - $either = "A-Za-z0-9";
- - }
- -
- + // use an extended character set; this should
- + // allow for umlauts and so on. taken from the
- + // Tavi project defaults.php file.
- + $upper = 'A-Z\xc0-\xde';
- + $lower = 'a-z0-9\xdf-\xfe';
- + $either = 'A-Za-z0-9\xc0-\xfe';
- + } else {
- + // the default character set, should be fine
- + // for most purposes.
- + $upper = "A-Z";
- + $lower = "a-z0-9";
- + $either = "A-Za-z0-9";
- + }
- +
- // build the regular expression for finding WikiPage names.
- $this->regex =
- "(!?" . // START WikiPage pattern (1)
- @@ -100,61 +94,52 @@
- "[-_$either]" . // 1 dash, alpha, digit, or underscore
- ")?)?)"; // end subpatterns (/4)(/3)(/2)
- }
- -
- -
- +
- +
- /**
- - *
- - * First parses for described links, then for standalone links.
- - *
- - * @access public
- - *
- - * @return void
- - *
- - */
- -
- + * First parses for described links, then for standalone links.
- + *
- + * @access public
- + *
- + * @return void
- + */
- function parse()
- {
- if ($this->getConf('utf-8')) {
- - $either = 'A-Za-z0-9\p{L}';
- + $either = 'A-Za-z0-9\p{L}';
- } else if ($this->getConf('ext_chars')) {
- - $either = "A-Za-z0-9\xc0-\xfe";
- - } else {
- - $either = "A-Za-z0-9";
- - }
- -
- + $either = "A-Za-z0-9\xc0-\xfe";
- + } else {
- + $either = "A-Za-z0-9";
- + }
- +
- // described wiki links
- $tmp_regex = '/\(\(' . /*$this->regex*/ '(['.$either.'\s:\.]*?)((\#['.$either.'\s:\.](['.$either.'\s:\.]*?)?)?)' . '(\)\((.+?))?\)\)/'.($this->getConf('utf-8') ? 'u' : '');
- - $this->wiki->source = preg_replace_callback(
- - $tmp_regex,
- - array(&$this, 'processDescr'),
- - $this->wiki->source
- - );
- -
- +
- + $this->wiki->source = preg_replace_callback($tmp_regex,
- + array(&$this, 'processDescr'),
- + $this->wiki->source);
- +
- if ($this->getConf('camel_case')) {
- // standalone wiki links
- $tmp_regex = '/(^|[^$either\-_])(\)\))?' . $this->regex . '(\(\()?/'.($this->getConf('utf-8') ? 'u' : '');
- - $this->wiki->source = preg_replace_callback(
- - $tmp_regex,
- +
- + $this->wiki->source = preg_replace_callback($tmp_regex,
- array(&$this, 'process'),
- - $this->wiki->source
- - );
- + $this->wiki->source);
- }
- }
- -
- -
- +
- +
- /**
- - *
- - * Generate a replacement for described links.
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return A delimited token to be used as a placeholder in
- - * the source text, plus any text priot to the match.
- - *
- - */
- -
- + * Generate a replacement for described links.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @return A delimited token to be used as a placeholder in
- + * the source text, plus any text priot to the match.
- + * @access public
- + */
- function processDescr(&$matches)
- {
- // set the options
- @@ -166,31 +151,27 @@
- if ($options['text'] == $options['page']) {
- $options['text'] = '';
- }
- -
- +
- // create and return the replacement token and preceding text
- return $this->wiki->addToken($this->rule,
- array_merge(array('type' => 'start'), $options)).
- $options['text'].
- $this->wiki->addToken($this->rule,
- array_merge(array('type' => 'end'), $options));
- -
- +
- }
- -
- -
- +
- +
- /**
- - *
- - * Generate a replacement for standalone links.
- - *
- - *
- - * @access public
- - *
- - * @param array &$matches The array of matches from parse().
- - *
- - * @return A delimited token to be used as a placeholder in
- - * the source text, plus any text prior to the match.
- - *
- - */
- -
- + * Generate a replacement for standalone links.
- + *
- + * @param array &$matches The array of matches from parse().
- + *
- + * @access public
- + *
- + * @return A delimited token to be used as a placeholder in
- + * the source text, plus any text prior to the match.
- + */
- function process(&$matches)
- {
- // when prefixed with !, it's explicitly not a wiki link.
- @@ -204,7 +185,7 @@
- if ($matches[2] == '))' && $matches[7] == '((') {
- return $matches[1] . $matches[3] . $matches[4];
- }
- -
- +
- // set the options
- $options = array(
- 'page' => $matches[3],
- @@ -224,4 +205,4 @@
- $matches[7];
- }
- }
- -?>
- \ No newline at end of file
- +?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement