1
0
mirror of synced 2025-01-29 19:41:45 +03:00
This commit is contained in:
zYne 2007-02-22 21:41:25 +00:00
parent 28f361a637
commit 83677290e8
189 changed files with 14743 additions and 0 deletions

1444
vendor/Text/Wiki.php vendored Normal file

File diff suppressed because it is too large Load Diff

27
vendor/Text/Wiki/Default.php vendored Normal file
View File

@ -0,0 +1,27 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Parse structured wiki text and render into arbitrary formats such as XHTML.
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Justin Patrin <justinpatrin@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Default.php,v 1.1 2006/03/01 16:58:17 justinpatrin Exp $
* @link http://pear.php.net/package/Text_Wiki
*/
require_once('Text/Wiki.php');
/**
* This is the parser for the Default ruleset. For now, this simply extends Text_Wiki.
*
* @category Text
* @package Text_Wiki
* @version Release: @package_version@
* @author Justin Patrin <justinpatrin@php.net>
*/
class Text_Wiki_Default extends Text_Wiki {
}

93
vendor/Text/Wiki/Mediawiki.php vendored Normal file
View File

@ -0,0 +1,93 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Parse structured wiki text and render into arbitrary formats such as XHTML.
* This is the Text_Wiki extension for Mediawiki markup
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Mediawiki.php,v 1.8 2006/02/25 09:59:34 toggg Exp $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* "master" class for handling the management and convenience
*/
require_once('Text/Wiki.php');
/**
* Base Text_Wiki handler class extension for Mediawiki markup
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @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::Text_Wiki()
*/
class Text_Wiki_Mediawiki extends Text_Wiki {
var $rules = array(
'Prefilter',
'Delimiter',
// 'Code',
// 'Plugin',
// 'Function',
// 'Html',
'Raw',
// 'Preformatted',
// 'Include',
// 'Embed',
// 'Page',
// 'Anchor',
'Heading',
'Toc',
// 'Titlebar',
'Horiz',
'Break',
// 'Blockquote',
'List',
'Deflist',
'Table',
// 'Box',
// 'Image', // done by Wikilink but still possible to disable/configure
// 'Phplookup',
// 'Center',
'Newline',
'Paragraph',
'Url',
// 'Freelink',
// 'Colortext',
'Wikilink',
// 'Strong', ** will be only fake inserted by Emphasis if needed for render
// 'Bold',
'Emphasis',
// 'Italic',
// 'Underline',
// 'Tt',
// 'Superscript',
// 'Subscript',
// 'Specialchar',
// 'Revise',
// 'Interwiki', // done by Wikilink but still possible to disable/configure
'Tighten'
);
/**
* Constructor: just adds the path to Mediawiki rules
*
* @access public
* @param array $rules The set of rules to load for this object.
*/
function Text_Wiki_Mediawiki($rules = null) {
parent::Text_Wiki($rules);
$this->addPath('parse', $this->fixPath(dirname(__FILE__)).'Parse/Mediawiki');
}
}
?>

264
vendor/Text/Wiki/Parse.php vendored Normal file
View File

@ -0,0 +1,264 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Baseline rule class for extension into a "real" parser component.
*
* PHP versions 4 and 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: Parse.php,v 1.5 2005/07/29 08:57:29 toggg Exp $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* Baseline rule class for extension into a "real" parser component.
*
* Text_Wiki_Rule classes do not stand on their own; they are called by a
* Text_Wiki object, typcially in the transform() method. Each rule class
* performs three main activities: parse, process, and render.
*
* The parse() method takes a regex and applies it to the whole block of
* source text at one time. Each match is sent as $matches to the
* process() method.
*
* The process() method acts on the matched text from the source, and
* then processes the source text is some way. This may mean the
* creation of a delimited token using addToken(). In every case, the
* process() method returns the text that should replace the matched text
* from parse().
*
* @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 Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Parse {
/**
*
* Configuration options for this parser rule.
*
* @access public
*
* @var string
*
*/
var $conf = array();
/**
*
* Regular expression to find matching text for this rule.
*
* @access public
*
* @var string
*
* @see parse()
*
*/
var $regex = null;
/**
*
* The name of this rule for new token array elements.
*
* @access public
*
* @var string
*
*/
var $rule = null;
/**
*
* A reference to the calling Text_Wiki object.
*
* This is needed so that each rule has access to the same source
* text, token set, URLs, interwiki maps, page names, etc.
*
* @access public
*
* @var object
*/
var $wiki = null;
/**
*
* Constructor for this parser rule.
*
* @access public
*
* @param object &$obj The calling "parent" Text_Wiki object.
*
*/
function Text_Wiki_Parse(&$obj)
{
// set the reference to the calling Text_Wiki object;
// this allows us access to the shared source text, token
// array, etc.
$this->wiki =& $obj;
// set the name of this rule; generally used when adding
// to the tokens array. strip off the Text_Wiki_Parse_ portion.
// text_wiki_parse_
// 0123456789012345
$tmp = substr(get_class($this), 16);
$this->rule = ucwords(strtolower($tmp));
// override config options for the rule if specified
if (isset($this->wiki->parseConf[$this->rule]) &&
is_array($this->wiki->parseConf[$this->rule])) {
$this->conf = array_merge(
$this->conf,
$this->wiki->parseConf[$this->rule]
);
}
}
/**
*
* Abstrct method to parse source text for matches.
*
* Applies the rule's regular expression to the source text, passes
* every match to the process() method, and replaces the matched text
* with the results of the processing.
*
* @access public
*
* @see Text_Wiki_Parse::process()
*
*/
function parse()
{
$this->wiki->source = preg_replace_callback(
$this->regex,
array(&$this, 'process'),
$this->wiki->source
);
}
/**
*
* Abstract method to generate replacements for matched text.
*
* @access public
*
* @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; defaults to the
* full matched string (i.e., no changes to the text).
*
* @see Text_Wiki_Parse::parse()
*
*/
function process(&$matches)
{
return $matches[0];
}
/**
*
* Simple method to safely get configuration key values.
*
* @access public
*
* @param string $key The configuration key.
*
* @param mixed $default If the key does not exist, return this value
* instead.
*
* @return mixed The configuration key value (if it exists) or the
* default value (if not).
*
*/
function getConf($key, $default = null)
{
if (isset($this->conf[$key])) {
return $this->conf[$key];
} else {
return $default;
}
}
/**
*
* Extract 'attribute="value"' portions of wiki markup.
*
* This kind of markup is typically used only in macros, but is useful
* anywhere.
*
* The syntax is pretty strict; there can be no spaces between the
* option name, the equals, and the first double-quote; the value
* must be surrounded by double-quotes. You can escape characters in
* the value with a backslash, and the backslash will be stripped for
* you.
*
* @access public
*
* @param string $text The "attributes" portion of markup.
*
* @return array An associative array of key-value pairs where the
* key is the option name and the value is the option value.
*
*/
function getAttrs($text)
{
// find the =" sections;
$tmp = explode('="', trim($text));
// basic setup
$k = count($tmp) - 1;
$attrs = array();
$key = null;
// loop through the sections
foreach ($tmp as $i => $val) {
// first element is always the first key
if ($i == 0) {
$key = trim($val);
continue;
}
// find the last double-quote in the value.
// the part to the left is the value for the last key,
// the part to the right is the next key name
$pos = strrpos($val, '"');
$attrs[$key] = stripslashes(substr($val, 0, $pos));
$key = trim(substr($val, $pos+1));
}
return $attrs;
}
}
?>

View File

@ -0,0 +1,87 @@
<?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.3 2005/02/23 17:38:29 pmjones Exp $
*
*/
/**
*
* 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
*
*/
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
*
*/
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) {
$name = $matches[2];
$text = $matches[3];
$start = $this->wiki->addToken(
$this->rule,
array('type' => 'start', '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;
}
}
?>

View File

@ -0,0 +1,179 @@
<?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.3 2005/02/23 17:38:29 pmjones Exp $
*
*/
/**
*
* 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>
*
*/
class Text_Wiki_Parse_Blockquote extends Text_Wiki_Parse {
/**
*
* Regex for parsing the source text.
*
* @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.
*
*/
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
);
// 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
// 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 .= "\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 .= "\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)
)
);
}
// we're done! send back the replacement text.
return "\n$return\n\n";
}
}
?>

79
vendor/Text/Wiki/Parse/Default/Bold.php vendored Normal file
View File

@ -0,0 +1,79 @@
<?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.3 2005/02/23 17:38:29 pmjones Exp $
*
*/
/**
*
* 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_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()
*
*/
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.
*
*/
function process(&$matches)
{
$start = $this->wiki->addToken($this->rule, array('type' => 'start'));
$end = $this->wiki->addToken($this->rule, array('type' => 'end'));
return $start . $matches[1] . $end;
}
}
?>

View File

@ -0,0 +1,72 @@
<?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.3 2005/02/23 17:38:29 pmjones Exp $
*
*/
/**
*
* 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>
*
*/
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()
*
*/
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.
*
*/
function process(&$matches)
{
return $this->wiki->addToken($this->rule);
}
}
?>

View File

@ -0,0 +1,78 @@
<?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.3 2005/02/23 17:38:29 pmjones Exp $
*
*/
/**
*
* 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>
*
*/
class Text_Wiki_Parse_Center extends Text_Wiki_Parse {
/**
*
* The regular expression used to find source text matching this
* rule.
*
* @access public
*
* @var string
*
*/
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.
*
*/
function process(&$matches)
{
$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";
}
}
?>

99
vendor/Text/Wiki/Parse/Default/Code.php vendored Normal file
View File

@ -0,0 +1,99 @@
<?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.10 2006/02/21 14:33:53 toggg Exp $
*
*/
/**
*
* 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 {
/**
*
* The regular expression used to find source text matching this
* rule.
*
* @access public
*
* @var string
*
*/
/* var $regex = '/^(\<code( .+)?\>)\n(.+)\n(\<\/code\>)(\s|$)/Umsi';*/
var $regex = ';^<code(\s[^>]*)?>((?:(?R)|.)*?)\n</code>(\s|$);msi';
/**
*
* 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)
{
// are there additional attribute arguments?
$args = trim($matches[1]);
if ($args == '') {
$options = array(
'text' => $matches[2],
'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
$options = array(
'text' => $matches[2],
'attr' => $attr
);
}
return $this->wiki->addToken($this->rule, $options) . $matches[3];
}
}
?>

View File

@ -0,0 +1,89 @@
<?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.3 2005/02/23 17:38:29 pmjones Exp $
*
*/
/**
*
* Parses for colorized text.
*
* @category Text
*
* @package Text_Wiki
*
* @author Paul M. Jones <pmjones@php.net>
*
*/
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()
*
*/
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.
*
*/
function process(&$matches)
{
$start = $this->wiki->addToken(
$this->rule,
array(
'type' => 'start',
'color' => $matches[1]
)
);
$end = $this->wiki->addToken(
$this->rule,
array(
'type' => 'end',
'color' => $matches[1]
)
);
return $start . $matches[2] . $end;
}
}
?>

View File

@ -0,0 +1,122 @@
<?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.3 2005/02/23 17:38:29 pmjones Exp $
*
*/
/**
*
* 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>
*
*/
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()
*
*/
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.
*
*/
function process(&$matches)
{
// the replacement text we will return to parse()
$return = '';
// the list of post-processing matches
$list = array();
// start the deflist
$options = array('type' => 'list_start');
$return .= $this->wiki->addToken($this->rule, $options);
// $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
);
// add each term and narrative
foreach ($list as $key => $val) {
$return .= (
$this->wiki->addToken($this->rule, array('type' => 'term_start')) .
trim($val[2]) .
$this->wiki->addToken($this->rule, array('type' => 'term_end')) .
$this->wiki->addToken($this->rule, array('type' => 'narr_start')) .
trim($val[4]) .
$this->wiki->addToken($this->rule, array('type' => 'narr_end'))
);
}
// end the deflist
$options = array('type' => 'list_end');
$return .= $this->wiki->addToken($this->rule, $options);
// done!
return "\n" . $return . "\n\n";
}
}
?>

View File

@ -0,0 +1,80 @@
<?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.3 2005/02/23 17:38:29 pmjones Exp $
*
*/
/**
*
* 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>
*
*/
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)
{
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.
*
*/
function process(&$matches)
{
return $this->wiki->addToken(
$this->rule,
array('text' => $this->wiki->delim)
);
}
}
?>

106
vendor/Text/Wiki/Parse/Default/Embed.php vendored Normal file
View File

@ -0,0 +1,106 @@
<?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.3 2005/02/23 17:38:29 pmjones Exp $
*
*/
/**
*
* 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>
*
*/
class Text_Wiki_Parse_Embed 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
*
*/
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.
*
*/
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);
$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)
);
}
}
?>

View File

@ -0,0 +1,85 @@
<?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.3 2005/02/23 17:38:29 pmjones Exp $
*
*/
/**
*
* 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 {
/**
*
* 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 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')
);
return $start . $matches[1] . $end;
}
}
?>

View File

@ -0,0 +1,127 @@
<?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.4 2005/10/19 23:43:53 toggg Exp $
*
*/
/**
*
* 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>
*
*/
class Text_Wiki_Parse_Freelink extends Text_Wiki_Parse {
/**
*
* 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.
*
*/
function Text_Wiki_Parse_Freelink(&$obj)
{
parent::Text_Wiki_Parse($obj);
$this->regex =
'/' . // START regex
"\\(\\(" . // double open-parens
"(" . // START freelink page patter
"[-A-Za-z0-9 _+\\/.,;:!?'\"\\[\\]\\{\\}&\xc0-\xff]+" . // 1 or more of just about any character
")" . // END freelink page pattern
"(" . // START display-name
"\|" . // a pipe to start the display name
"[-A-Za-z0-9 _+\\/.,;:!?'\"\\[\\]\\{\\}&\xc0-\xff]+" . // 1 or more of just about any character
")?" . // END display-name pattern 0 or 1
"(" . // START pattern for named anchors
"\#" . // a hash mark
"[A-Za-z]" . // 1 alpha
"[-A-Za-z0-9_:.]*" . // 0 or more alpha, digit, underscore
")?" . // END named anchors pattern 0 or 1
"()\\)\\)" . // double close-parens
'/'; // END regex
}
/**
*
* 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.
*
*/
function process(&$matches)
{
// use nice variable names
$page = $matches[1];
$text = $matches[2];
$anchor = $matches[3];
// is the page given a new text appearance?
if (trim($text) == '') {
// no
$text = $page;
} else {
// yes, strip the leading | character
$text = substr($text, 1);
}
// set the options
$options = array(
'page' => $page,
'text' => $text,
'anchor' => $anchor
);
// return a token placeholder
return $this->wiki->addToken($this->rule, $options);
}
}
?>

View File

@ -0,0 +1,141 @@
<?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.3 2005/02/23 17:38:29 pmjones Exp $
*
*/
/**
*
* Parses for an API function documentation block.
*
* @category Text
*
* @package Text_Wiki
*
* @author Paul M. Jones <pmjones@php.net>
*
*/
class Text_Wiki_Parse_Function extends Text_Wiki_Parse {
var $regex = '/^(\<function\>)\n(.+)\n(\<\/function\>)(\s|$)/Umsi';
function process(&$matches)
{
// default options
$opts = array(
'name' => null,
'access' => null,
'return' => null,
'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
// 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) {
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);
if ($k == 1) {
$opts['params'][] = array(
'type' => $tmp[0],
'descr' => null,
'default' => null
);
} elseif ($k == 2) {
$opts['params'][] = array(
'type' => $tmp[0],
'descr' => $tmp[1],
'default' => null
);
} else {
$opts['params'][] = array(
'type' => $tmp[0],
'descr' => $tmp[1],
'default' => $tmp[2]
);
}
break;
case 'r':
case 'return':
case 'returns':
$opts['return'] = $val;
break;
case 't':
case 'throws':
$tmp = explode(',', $val);
$k = count($tmp);
if ($k == 1) {
$opts['throws'][] = array(
'type' => $tmp[0],
'descr' => null
);
} else {
$opts['throws'][] = array(
'type' => $tmp[0],
'descr' => $tmp[1]
);
}
break;
default:
$opts[$type] = $val;
break;
}
}
// add the token back in place
return $this->wiki->addToken($this->rule, $opts) . $matches[4];
}
}
?>

View File

@ -0,0 +1,107 @@
<?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.3 2005/02/23 17:38:29 pmjones Exp $
*
*/
/**
*
* 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 {
/**
*
* 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 = '/^(\+{1,6}) (.*)/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.
*
*/
function process(&$matches)
{
// keep a running count for header IDs. we use this later
// when constructing TOC entries, etc.
static $id;
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])
)
);
return $start . $matches[2] . $end . "\n";
}
}
?>

View File

@ -0,0 +1,70 @@
<?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.3 2005/02/23 17:38:29 pmjones Exp $
*
*/
/**
*
* 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 {
/**
*
* 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 = '/^([-]{4,})$/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.
*
*/
function process(&$matches)
{
return $this->wiki->addToken($this->rule);
}
}
?>

75
vendor/Text/Wiki/Parse/Default/Html.php vendored Normal file
View File

@ -0,0 +1,75 @@
<?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.3 2005/02/23 17:38:29 pmjones Exp $
*
*/
/**
*
* 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>
*
*/
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()
*
*/
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.
*
*/
function process(&$matches)
{
$options = array('text' => $matches[1]);
return $this->wiki->addToken($this->rule, $options) . $matches[2];
}
}
?>

136
vendor/Text/Wiki/Parse/Default/Image.php vendored Normal file
View File

@ -0,0 +1,136 @@
<?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.5 2005/09/12 11:34:44 toggg Exp $
*
*/
/**
*
* Parses for image placement.
*
* @category Text
*
* @package Text_Wiki
*
* @author Paul M. Jones <pmjones@php.net>
*
*/
class Text_Wiki_Parse_Image extends Text_Wiki_Parse {
/**
* URL schemes recognized by this rule.
*
* @access public
* @var array
*/
var $conf = array(
'schemes' => 'http|https|ftp|gopher|news',
'host_regexp' => '(?:[^.\s/"\'<\\\#delim#\ca-\cz]+\.)*[a-z](?:[-a-z0-9]*[a-z0-9])?\.?',
'path_regexp' => '(?:/[^\s"<\\\#delim#\ca-\cz]*)?'
);
/**
*
* The regular expression used to find source text matching this
* rule.
*
* @access public
*
* @var string
*
*/
var $regex = '/(\[\[image\s+)(.+?)(\]\])/i';
/**
* The regular expressions used to check ecternal urls
*
* @access public
* @var string
* @see parse()
*/
var $url = '';
/**
* Constructor.
* We override the constructor to build up the url regex from config
*
* @param object &$obj the base conversion handler
* @return The parser object
* @access public
*/
function Text_Wiki_Parse_Image(&$obj)
{
$default = $this->conf;
parent::Text_Wiki_Parse($obj);
// convert the list of recognized schemes to a regex OR,
$schemes = $this->getConf('schemes', $default['schemes']);
$this->url = str_replace( '#delim#', $this->wiki->delim,
'#(?:' . (is_array($schemes) ? implode('|', $schemes) : $schemes) . ')://'
. $this->getConf('host_regexp', $default['host_regexp'])
. $this->getConf('path_regexp', $default['path_regexp']) .'#');
}
/**
*
* 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.
*
*/
function process(&$matches)
{
$pos = strpos($matches[2], ' ');
if ($pos === false) {
$options = array(
'src' => $matches[2],
'attr' => array());
} else {
// everything after the space is attribute arguments
$options = array(
'src' => substr($matches[2], 0, $pos),
'attr' => $this->getAttrs(substr($matches[2], $pos+1))
);
// check the scheme case of external link
if (array_key_exists('link', $options['attr'])) {
// external url ?
if (($pos = strpos($options['attr']['link'], '://')) !== false) {
if (!preg_match($this->url, $options['attr']['link'])) {
return $matches[0];
}
} elseif (in_array('Wikilink', $this->wiki->disable)) {
return $matches[0]; // Wikilink disabled
}
}
}
return $this->wiki->addToken($this->rule, $options);
}
}
?>

View File

@ -0,0 +1,100 @@
<?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.3 2005/02/23 17:38:29 pmjones Exp $
*
*/
/**
*
* 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>
*
*/
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
*
*/
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.
*
*/
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);
$this->output = ob_get_contents();
ob_end_clean();
// done, place the script output directly in the source
return $this->output;
}
}
?>

View File

@ -0,0 +1,138 @@
<?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.4 2005/02/23 17:38:29 pmjones Exp $
*
*/
/**
*
* 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>
*
*/
class Text_Wiki_Parse_Interwiki extends Text_Wiki_Parse {
// double-colons wont trip up now
var $regex = '([A-Za-z0-9_]+):((?!:)[A-Za-z0-9_\/=&~#.:;-]+)';
/**
*
* 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
);
// standalone interwiki links
$tmp_regex = '/' . $this->regex . '/';
$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.
*
*/
function process(&$matches)
{
$options = array(
'site' => $matches[1],
'page' => $matches[2],
'text' => $matches[0]
);
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.
*
*/
function processDescr(&$matches)
{
$options = array(
'site' => $matches[1],
'page' => $matches[2],
'text' => $matches[3]
);
return $this->wiki->addToken($this->rule, $options);
}
}
?>

View File

@ -0,0 +1,85 @@
<?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.3 2005/02/23 17:38:29 pmjones Exp $
*
*/
/**
*
* 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>
*
*/
class Text_Wiki_Parse_Italic 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 = "/''(()|[^'].*)''/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.
*
*/
function process(&$matches)
{
$start = $this->wiki->addToken(
$this->rule, array('type' => 'start')
);
$end = $this->wiki->addToken(
$this->rule, array('type' => 'end')
);
return $start . $matches[1] . $end;
}
}
?>

248
vendor/Text/Wiki/Parse/Default/List.php vendored Normal file
View File

@ -0,0 +1,248 @@
<?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.7 2005/11/06 20:44:09 toggg Exp $
*
*/
/**
*
* 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 {
/**
*
* 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)(?!\2 |(?: {1,}((?:\*|#) |\n)))/Usm';
/**
*
* 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.
*
*/
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(
'=^( {0,})(\*|#) (.*)$=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 number of initial spaces (indent level)
// $val[2] is the list item type (* or #)
// $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';
} elseif ($val[2] == '#') {
$type = 'number';
} 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
)
);
}
// 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.
// 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
)
);
// 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])) {
// first count
$itemcount[$level] = 0;
} else {
// increment count
$itemcount[$level]++;
}
// is this the very first item in the list?
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
)
);
// create a list-item ending token.
$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 . $val[3] . $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)
)
);
}
// we're done! send back the replacement text.
return "\n\n" . $return . "\n\n";
}
}
?>

View File

@ -0,0 +1,75 @@
<?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.3 2005/02/23 17:38:29 pmjones Exp $
*
*/
/**
*
* 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 {
/**
*
* 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.
*
*/
function process(&$matches)
{
return $matches[1] .
$this->wiki->addToken($this->rule) .
$matches[2];
}
}
?>

View File

@ -0,0 +1,146 @@
<?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.3 2005/02/23 17:38:29 pmjones Exp $
*
*/
/**
*
* 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>
*
*/
class Text_Wiki_Parse_Paragraph extends Text_Wiki_Parse {
/**
*
* 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?
'code',
'heading',
'horiz',
'deflist',
'table',
'list',
'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.
*
*/
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) {
// no.
$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.
$key = '';
$len = strlen($matches[0]);
for ($i = 1; $i < $len; $i++) {
$char = $matches[0]{$i};
if ($char == $delim) {
break;
} else {
$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')
);
return $start . trim($matches[0]) . $end;
}
}
}
?>

View File

@ -0,0 +1,73 @@
<?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.3 2005/02/23 17:38:29 pmjones Exp $
*
*/
/**
*
* Find source text marked for lookup in the PHP online manual.
*
* @category Text
*
* @package Text_Wiki
*
* @author Paul M. Jones <pmjones@php.net>
*
*/
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()
*
*/
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.
*
*/
function process(&$matches)
{
return $this->wiki->addToken(
$this->rule, array('text' => $matches[1])
);
}
}
?>

View File

@ -0,0 +1,78 @@
<?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.3 2005/02/23 17:38:29 pmjones Exp $
*
*/
/**
*
* "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 {
/**
*
* Simple parsing method.
*
* @access public
*
*/
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";
$replace = "\n\n";
$this->wiki->source = preg_replace($find, $replace,
$this->wiki->source);
}
}
?>

73
vendor/Text/Wiki/Parse/Default/Raw.php vendored Normal file
View File

@ -0,0 +1,73 @@
<?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.3 2005/02/23 17:38:29 pmjones Exp $
*
*/
/**
*
* 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 {
/**
*
* The regular expression used to find source text matching this
* rule.
*
* @access public
*
* @var string
*
*/
var $regex = "/``(.*)``/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.
*
*/
function process(&$matches)
{
$options = array('text' => $matches[1]);
return $this->wiki->addToken($this->rule, $options);
}
}
?>

View File

@ -0,0 +1,145 @@
<?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.3 2005/02/23 17:38:29 pmjones Exp $
*
*/
/**
*
* Parses for text marked as revised (insert/delete).
*
* @category Text
*
* @package Text_Wiki
*
* @author Paul M. Jones <pmjones@php.net>
*
*/
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()
*
*/
var $regex = "/\@\@({*?.*}*?)\@\@/U";
/**
*
* Config options.
*
* @access public
*
* @var array
*
*/
var $conf = array(
'delmark' => '---',
'insmark' => '+++'
);
/**
*
* 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.
*
*/
function process(&$matches)
{
$output = '';
$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);
} else {
// there is insertion text following,
// mitigate the length
$text = substr($src, $del, $ins - $del);
}
$output .= $this->wiki->addToken(
$this->rule, array('type' => 'del_start')
);
$output .= $text;
$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 .= $text;
$output .= $this->wiki->addToken(
$this->rule, array('type' => 'ins_end')
);
}
return $output;
}
}
?>

View File

@ -0,0 +1,157 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Default: Parses for smileys / emoticons tags
*
* This class implements a Text_Wiki_Rule to find source text marked as
* smileys defined by symbols as ':)' , ':-)' or ':smile:'
* The symbol is replaced with a token.
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @copyright 2005 bertrand Gugger
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Smiley.php,v 1.6 2005/10/04 08:17:51 toggg Exp $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* Smiley rule parser class for Default.
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @copyright 2005 bertrand Gugger
* @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_Smiley extends Text_Wiki_Parse {
/**
* Configuration keys for this rule
* 'smileys' => array Smileys recognized by this rule, symbols key definitions:
* 'symbol' => array ( 'name', 'description' [, 'variante', ...] ) as
* ':)' => array('smile', 'Smile'),
* ':D' => array('biggrin', 'Very Happy',':grin:'),
* the eventual elements after symbol and description are variantes
*
* 'auto_nose' => boolean enabling the auto nose feature:
* auto build a variante for 2 chars symbols by inserting a '-' as ':)' <=> ':-)'
*
* @access public
* @var array 'config-key' => mixed config-value
*/
var $conf = array(
'smileys' => array(
':D' => array('biggrin', 'Very Happy', ':grin:'),
':)' => array('smile', 'Smile', '(:'),
':(' => array('sad', 'Sad', '):'),
':o' => array('surprised', 'Surprised', ':eek:', 'o:'),
':shock:' => array('eek', 'Shocked'),
':?' => array('confused', 'Confused', ':???:'),
'8)' => array('cool', 'Cool', '(8'),
':lol:' => array('lol', 'Laughing'),
':x' => array('mad', 'Mad'),
':P' => array('razz', 'Razz'),
':oops:' => array('redface', 'Embarassed'),
':cry:' => array('cry', 'Crying or Very sad'),
':evil:' => array('evil', 'Evil or Very Mad'),
':twisted:' => array('twisted', 'Twisted Evil'),
':roll:' => array('rolleyes', 'Rolling Eyes'),
';)' => array('wink', 'Wink', '(;'),
':!:' => array('exclaim', 'Exclamation'),
':?:' => array('question', 'Question'),
':idea:' => array('idea', 'Idea'),
':arrow:' => array('arrow', 'Arrow'),
':|' => array('neutral', 'Neutral', '|:'),
':mrgreen:' => array('mrgreen', 'Mr. Green'),
),
'auto_nose' => true
);
/**
* Definition array of smileys, variantes references their model
* 'symbol' => array ( 'name', 'description')
*
* @access private
* @var array 'config-key' => mixed config-value
*/
var $_smileys = array();
/**
* Constructor.
* We override the constructor to build up the regex from config
*
* @param object &$obj the base conversion handler
* @return The parser object
* @access public
*/
function Text_Wiki_Parse_Smiley(&$obj)
{
$default = $this->conf;
parent::Text_Wiki_Parse($obj);
// read the list of smileys to sort out variantes and :xxx: while building the regexp
$this->_smileys = $this->getConf('smileys', $default['smileys']);
$autoNose = $this->getConf('auto_nose', $default['auto_nose']);
$reg1 = $reg2 = '';
$sep1 = ':(?:';
$sep2 = '';
foreach ($this->_smileys as $smiley => $def) {
for ($i = 1; $i < count($def); $i++) {
if ($i > 1) {
$cur = $def[$i];
$this->_smileys[$cur] = &$this->_smileys[$smiley];
} else {
$cur = $smiley;
}
$len = strlen($cur);
if (($cur{0} == ':') && ($len > 2) && ($cur{$len - 1} == ':')) {
$reg1 .= $sep1 . preg_quote(substr($cur, 1, -1), '#');
$sep1 = '|';
continue;
}
if ($autoNose && ($len === 2)) {
$variante = $cur{0} . '-' . $cur{1};
$this->_smileys[$variante] = &$this->_smileys[$smiley];
$cur = preg_quote($cur{0}, '#') . '-?' . preg_quote($cur{1}, '#');
} else {
$cur = preg_quote($cur, '#');
}
$reg2 .= $sep2 . $cur;
$sep2 = '|';
}
}
$delim = '[\n\r\s' . $this->wiki->delim . '$^]';
$this->regex = '#(?<=' . $delim .
')(' . ($reg1 ? $reg1 . '):' . ($reg2 ? '|' : '') : '') . $reg2 .
')(?=' . $delim . ')#i';
}
/**
* Generates a replacement token for the matched text. Token options are:
* 'symbol' => the original marker
* 'name' => the name of the smiley
* 'desc' => the description of the smiley
*
* @param array &$matches The array of matches from parse().
* @return string Delimited token representing the smiley
* @access public
*/
function process(&$matches)
{
// tokenize
return $this->wiki->addToken($this->rule,
array(
'symbol' => $matches[1],
'name' => $this->_smileys[$matches[1]][0],
'desc' => $this->_smileys[$matches[1]][1]
));
}
}
?>

View File

@ -0,0 +1,86 @@
<?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.3 2005/02/23 17:38:29 pmjones Exp $
*
*/
/**
*
* 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 {
/**
*
* 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.
*
*/
function process(&$matches)
{
$start = $this->wiki->addToken(
$this->rule, array('type' => 'start')
);
$end = $this->wiki->addToken(
$this->rule, array('type' => 'end')
);
return $start . $matches[1] . $end;
}
}
?>

View File

@ -0,0 +1,79 @@
<?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/02/24 17:24:56 pmjones Exp $
*
*/
/**
*
* 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 {
/**
*
* 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.
*
*/
function process(&$matches)
{
$start = $this->wiki->addToken(
$this->rule, array('type' => 'start')
);
$end = $this->wiki->addToken(
$this->rule, array('type' => 'end')
);
return $start . $matches[1] . $end;
}
}
?>

View File

@ -0,0 +1,79 @@
<?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.3 2005/02/23 17:38:29 pmjones Exp $
*
*/
/**
*
* 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 {
/**
*
* 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.
*
*/
function process(&$matches)
{
$start = $this->wiki->addToken(
$this->rule, array('type' => 'start')
);
$end = $this->wiki->addToken(
$this->rule, array('type' => 'end')
);
return $start . $matches[1] . $end;
}
}
?>

226
vendor/Text/Wiki/Parse/Default/Table.php vendored Normal file
View File

@ -0,0 +1,226 @@
<?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.3 2005/02/23 17:38:29 pmjones Exp $
*
*/
/**
*
* 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 {
/**
*
* 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' =>
* '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.
*
*/
function process(&$matches)
{
// 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[1]);
// loop through each row
foreach ($rows as $row) {
// increase the row count
$num_rows ++;
// start a new row
$return .= $this->wiki->addToken(
$this->rule,
array('type' => 'row_start')
);
// cells are separated by double-pipes
$cell = explode("||", $row);
// get the number of cells (columns) in this row
$last = count($cell) - 1;
// is this more than the current column count?
// (we decrease by 1 because we never use cell zero)
if ($last - 1 > $num_cols) {
// increase the column count
$num_cols = $last - 1;
}
// by default, cells span only one column (their own)
$span = 1;
// ignore cell zero, and ignore the "last" cell; cell zero
// is before the first double-pipe, and the "last" cell is
// after the last double-pipe. both are always empty.
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 ($cell[$i] == '') {
// add to the span and loop to the next cell
$span += 1;
continue;
} else {
// this cell has content.
// find any special "attr"ibute cell markers
if (substr($cell[$i], 0, 2) == '> ') {
// right-align
$attr = 'right';
$cell[$i] = substr($cell[$i], 2);
} elseif (substr($cell[$i], 0, 2) == '= ') {
// center-align
$attr = 'center';
$cell[$i] = substr($cell[$i], 2);
} elseif (substr($cell[$i], 0, 2) == '< ') {
// left-align
$attr = 'left';
$cell[$i] = substr($cell[$i], 2);
} elseif (substr($cell[$i], 0, 2) == '~ ') {
$attr = 'header';
$cell[$i] = substr($cell[$i], 2);
} else {
$attr = null;
}
// start a new cell...
$return .= $this->wiki->addToken(
$this->rule,
array (
'type' => 'cell_start',
'attr' => $attr,
'span' => $span
)
);
// ...add the content...
$return .= trim($cell[$i]);
// ...and end the cell.
$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')
);
}
// 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
)
)
. $return .
$this->wiki->addToken(
$this->rule,
array(
'type' => 'table_end'
)
);
// we're done!
return "\n$return\n\n";
}
}
?>

View File

@ -0,0 +1,49 @@
<?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.3 2005/02/23 17:38:29 pmjones Exp $
*
*/
/**
*
* The rule removes all remaining newlines.
*
* @category Text
*
* @package Text_Wiki
*
* @author Paul M. Jones <pmjones@php.net>
*
*/
class Text_Wiki_Parse_Tighten extends Text_Wiki_Parse {
/**
*
* Apply tightening directly to the source text.
*
* @access public
*
*/
function parse()
{
$this->wiki->source = str_replace("\n", '',
$this->wiki->source);
}
}
?>

130
vendor/Text/Wiki/Parse/Default/Toc.php vendored Normal file
View File

@ -0,0 +1,130 @@
<?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.4 2005/05/28 21:33:02 pmjones Exp $
*
*/
/**
*
* 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 {
/**
*
* 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.
*
*/
function process(&$matches)
{
$count = 0;
if (isset($matches[1])) {
$attr = $this->getAttrs(trim($matches[1]));
} else {
$attr = array();
}
$output = $this->wiki->addToken(
$this->rule,
array(
'type' => 'list_start',
'level' => 0,
'attr' => $attr
)
);
foreach ($this->wiki->getTokens('Heading') as $key => $val) {
if ($val[1]['type'] != 'start') {
continue;
}
$options = array(
'type' => 'item_start',
'id' => $val[1]['id'],
'level' => $val[1]['level'],
'count' => $count ++
);
$output .= $this->wiki->addToken($this->rule, $options);
$output .= $val[1]['text'];
$output .= $this->wiki->addToken(
$this->rule,
array(
'type' => 'item_end',
'level' => $val[1]['level']
)
);
}
$output .= $this->wiki->addToken(
$this->rule, array(
'type' => 'list_end',
'level' => 0
)
);
return "\n$output\n";
}
}
?>

84
vendor/Text/Wiki/Parse/Default/Tt.php vendored Normal file
View File

@ -0,0 +1,84 @@
<?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.3 2005/02/23 17:38:29 pmjones Exp $
*
*/
/**
*
* 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 {
/**
*
* 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.
*
*/
function process(&$matches)
{
$start = $this->wiki->addToken(
$this->rule, array('type' => 'start')
);
$end = $this->wiki->addToken(
$this->rule, array('type' => 'end')
);
return $start . $matches[1] . $end;
}
}
?>

View File

@ -0,0 +1,79 @@
<?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/10 20:40:20 justinpatrin Exp $
*
*/
/**
*
* 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 {
/**
*
* 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.
*
*/
function process(&$matches)
{
$start = $this->wiki->addToken($this->rule, array('type' => 'start'));
$end = $this->wiki->addToken($this->rule, array('type' => 'end'));
return $start . $matches[1] . $end;
}
}
?>

281
vendor/Text/Wiki/Parse/Default/Url.php vendored Normal file
View File

@ -0,0 +1,281 @@
<?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.3 2005/02/23 17:38:29 pmjones Exp $
*
*/
/**
*
* 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 {
/**
*
* 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
*
*/
var $conf = array(
'schemes' => array(
'http://',
'https://',
'ftp://',
'gopher://',
'news://',
'mailto:'
)
);
/**
*
* Constructor.
*
* We override the constructor so we can comment the regex nicely.
*
* @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();
$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;
")*" . // end pattern
"[^ \\t\\n\\/\"\'{$this->wiki->delim}]*" .
"[A-Za-z0-9\\/?=&~_]";
}
/**
*
* Find three different kinds of URLs in the source text.
*
* @access public
*
*/
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
);
// -------------------------------------------------------------
//
// 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(
$tmp_regex,
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
);
}
/**
*
* 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.
*
*/
function process(&$matches)
{
// set options
$options = array(
'type' => 'inline',
'href' => $matches[2],
'text' => $matches[2]
);
// tokenize
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.
*
*/
function processFootnote(&$matches)
{
// 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.
*
*/
function processDescr(&$matches)
{
// set options
$options = array(
'type' => 'descr',
'href' => $matches[1],
'text' => $matches[4]
);
// tokenize
return $this->wiki->addToken($this->rule, $options);
}
}
?>

View File

@ -0,0 +1,197 @@
<?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 2005/09/14 14:29:38 toggg Exp $
*
*/
/**
*
* 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>
*
*/
class Text_Wiki_Parse_Wikilink extends Text_Wiki_Parse {
var $conf = array (
'ext_chars' => 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.
*
*/
function Text_Wiki_Parse_Wikilink(&$obj)
{
parent::Text_Wiki_Parse($obj);
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";
}
// build the regular expression for finding WikiPage names.
$this->regex =
"(!?" . // START WikiPage pattern (1)
"[$upper]" . // 1 upper
"[$either]*" . // 0+ alpha or digit
"[$lower]+" . // 1+ lower or digit
"[$upper]" . // 1 upper
"[$either]*" . // 0+ or more alpha or digit
")" . // END WikiPage pattern (/1)
"((\#" . // START Anchor pattern (2)(3)
"[$either]" . // 1 alpha
"(" . // start sub pattern (4)
"[-_$either:.]*" . // 0+ dash, alpha, digit, underscore, colon, dot
"[-_$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
*
*/
function parse()
{
// described wiki links
$tmp_regex = '/\[' . $this->regex . ' (.+?)\]/';
$this->wiki->source = preg_replace_callback(
$tmp_regex,
array(&$this, 'processDescr'),
$this->wiki->source
);
// standalone wiki links
if ($this->getConf('ext_chars')) {
$either = "A-Za-z0-9\xc0-\xfe";
} else {
$either = "A-Za-z0-9";
}
$tmp_regex = "/(^|[^{$either}\-_]){$this->regex}/";
$this->wiki->source = preg_replace_callback(
$tmp_regex,
array(&$this, 'process'),
$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.
*
*/
function processDescr(&$matches)
{
// set the options
$options = array(
'page' => $matches[1],
'text' => $matches[5],
'anchor' => $matches[3]
);
// create and return the replacement token and preceding text
return $this->wiki->addToken($this->rule, $options); // . $matches[7];
}
/**
*
* 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.
*
*/
function process(&$matches)
{
// when prefixed with !, it's explicitly not a wiki link.
// return everything as it was.
if ($matches[2]{0} == '!') {
return $matches[1] . substr($matches[2], 1) . $matches[3];
}
// set the options
$options = array(
'page' => $matches[2],
'text' => $matches[2] . $matches[3],
'anchor' => $matches[3]
);
// create and return the replacement token and preceding text
return $matches[1] . $this->wiki->addToken($this->rule, $options);
}
}
?>

View File

@ -0,0 +1,278 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
*
* Mediawiki: Parse for definition lists.
*
* @category Text
* @package Text_Wiki
* @author Justin Patrin <papercrane@reversefold.com>
* @author Paul M. Jones <pmjones@php.net>
* @author Moritz Venn <ritzmo@php.net>
* @license LGPL
* @version $Id: Deflist.php,v 1.1 2006/03/29 18:41:43 ritzmo Exp $
*
*/
/**
*
* Parses for definition lists.
*
* This class implements a Text_Wiki_Parse to find source text marked as a
* definition list.
* If a line starts with ';' or ':' it is considered a part of a definition
* list. ';' indicates the term to be defined and ':' indicates its definition.
* As in Mediawiki we also allow definition lists to only consist of one
* item-type.
*
* @category Text
* @package Text_Wiki
*
* @author Justin Patrin <papercrane@reversefold.com>
* @author Paul M. Jones <pmjones@php.net>
* @author Moritz Venn <ritzmo@php.net>
*
*/
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()
*
*/
var $regex = '/\n((?:\;|\:)+.*?\n(?!(?:\;|\:)+))/s';
/**
*
* 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
*
* '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.
*
*/
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(
'/^((;|:)+)(.*?)$/ms',
$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]);
// get the list item type
if ($val[2] == ';') {
$type = 'term';
} elseif ($val[2] == ':') {
$type = 'narr';
} 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);
// The new list has to be opened in an item (use current type)
if ($level > 1) {
$return .= $this->wiki->addToken(
$this->rule,
array(
'type' => $type . '_start',
'level' => $level - 1
)
);
}
// ...and add a list-start token to the return.
$return .= $this->wiki->addToken(
$this->rule,
array(
'type' => 'list_start',
'level' => $level - 1
)
);
}
// remove a level from the list?
while (count($stack) > $level) {
echo ".";
// 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.
// continue adding end-list tokens until the stack count
// and the indent level are the same.
$return .= $this->wiki->addToken(
$this->rule,
array (
'type' => 'list_end',
'level' => $tmp
)
);
array_pop($stack);
// reset to the current (previous) list type so that
// the new list item matches the proper list type.
$type = $stack[$tmp - 1];
// Close the previously opened List item
$return .= $this->wiki->addToken(
$this->rule,
array (
'type' => $type . '_end',
'level' => $tmp
)
);
// 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])) {
// first count
$itemcount[$level] = 0;
} else {
// increment count
$itemcount[$level]++;
}
// is this the very first item in the list?
if (! $pastFirst) {
$first = true;
$pastFirst = true;
} else {
$first = false;
}
// create a list-item starting token.
$start = $this->wiki->addToken(
$this->rule,
array(
'type' => $type . '_start',
'level' => $level,
'count' => $itemcount[$level],
'first' => $first
)
);
// create a list-item ending token.
$end = $this->wiki->addToken(
$this->rule,
array(
'type' => $type . '_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.
$level = count($stack);
while ($level > 0) {
array_pop($stack);
$return .= $this->wiki->addToken(
$this->rule,
array (
'type' => 'list_end',
'level' => $level - 1
)
);
// if we are higher than level 1 we need to close fake items
if ($level > 1) {
$return .= $this->wiki->addToken(
$this->rule,
array (
'type' => $stack[$level - 2] . '_end',
'level' => $level - 2
)
);
}
$level = count($stack);
}
// we're done! send back the replacement text.
return "\n" . $return . "\n\n";
}
}
?>

View File

@ -0,0 +1,86 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Mediawiki: Parses for emphazised text.
*
* Text_Wiki rule parser to find source text emphazised
* as defined by text surrounded by repeated single quotes ''...'' and more
* Translated are ''emphasis'' , '''strong''' or '''''both''''' ...
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @author Paul M. Jones <pmjones@php.net>
* @copyright 2005 bertrand Gugger
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Emphasis.php,v 1.4 2006/02/15 12:27:40 toggg Exp $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* Emphazised text rule parser class for Mediawiki. Makes Emphasis, Strong or both
* This class implements a Text_Wiki_Parse to find source text marked for
* emphasis, stronger and very as defined by text surrounded by 2,3 or 5 single-quotes.
* On parsing, the text itself is left in place, but the starting and ending
* instances of the single-quotes are replaced with tokens.
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @copyright 2005 bertrand Gugger
* @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 {
/**
* The regular expression used to parse the source text and find
* matches conforming to this rule. Used by the parse() method.
* We match '' , ''' or ''''' embeded texts
*
* @access public
* @var string
* @see Text_Wiki_Parse::parse()
*/
var $regex = "/(?<!')'('{1,4})(.*?)\\1'(?!')/";
/**
* Generates a replacement for the matched text. Token options are:
* - 'type' => ['start'|'end'] The starting or ending point of the emphasized text.
* Generated tokens are Emphasis (this rule), Strong or Emphasis / Strong
* The text itself is left in the source but may content bested blocks
*
* @access public
* @param array &$matches The array of matches from parse().
* @return string Delimited by start/end tokens to be used as
* placeholder in the source text surrounding the text to be emphasized.
*/
function process(&$matches)
{
$embeded = $matches[2];
switch (strlen($matches[1])) {
case 1:
$start = $this->wiki->addToken($this->rule, array('type' => 'start'));
$end = $this->wiki->addToken($this->rule, array('type' => 'end'));
break;
case 3:
$embeded = "'" . $embeded . "'";
case 2:
$start = $this->wiki->addToken('Strong', array('type' => 'start'));
$end = $this->wiki->addToken('Strong', array('type' => 'end'));
break;
case 4:
$start = $this->wiki->addToken($this->rule, array('type' => 'start'))
. $this->wiki->addToken('Strong', array('type' => 'start'));
$end = $this->wiki->addToken('Strong', array('type' => 'end'))
. $this->wiki->addToken($this->rule, array('type' => 'end'));
break;
}
return $start . $embeded . $end;
}
}
?>

View File

@ -0,0 +1,109 @@
<?php
/**
*
* Parses for heading text.
*
* @category Text
*
* @package Text_Wiki
*
* @author Paul M. Jones <pmjones@php.net>
*
* @author Moritz Venn <moritz.venn@freaque.net>
*
* @license LGPL
*
* @version $Id: Heading.php,v 1.3 2006/02/03 19:47:02 toggg Exp $
*
*/
/**
*
* 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 Moritz Venn <moritz.venn@freaque.net>
*
*/
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()
*
*/
var $regex = '/^(={2,6})(.*?)\1(?:\s|$)/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.
*
*/
function process(&$matches)
{
// keep a running count for header IDs. we use this later
// when constructing TOC entries, etc.
static $id;
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' => trim($matches[2]),
'id' => $prefix . $id ++
)
);
$end = $this->wiki->addToken(
$this->rule,
array(
'type' => 'end',
'level' => strlen($matches[1])
)
);
return $start . trim($matches[2]) . $end . "\n";
}
}
?>

View File

@ -0,0 +1,250 @@
<?php
/**
*
* Parses for bulleted and numbered lists.
*
* @category Text
*
* @package Text_Wiki
*
* @author Justin Patrin <papercrane@reversefold.com>
* @author Paul M. Jones <pmjones@php.net>
*
* @license LGPL
*
* @version $Id: List.php,v 1.1 2006/03/28 04:46:09 ritzmo Exp $
*
*/
/**
*
* 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 Justin Patrin <papercrane@reversefold.com>
* @author Paul M. Jones <pmjones@php.net>
*
*/
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()
*
*/
//TODO: add text continuations (any number of + signs) and expandable areas (- after *s ot #s)
var $regex = '/\n((?:\*|#)+.*?\n(?!(?:\*|#)+))/s';
/**
*
* 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.
*
*/
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(
'/^((\*|#)+)(.*?)$/ms',
$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]);
// get the list item type
if ($val[2] == '*') {
$type = 'bullet';
} elseif ($val[2] == '#') {
$type = 'number';
} 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
)
);
}
// 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.
// 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
)
);
// 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])) {
// first count
$itemcount[$level] = 0;
} else {
// increment count
$itemcount[$level]++;
}
// is this the very first item in the list?
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
)
);
// create a list-item ending token.
$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)
)
);
}
// we're done! send back the replacement text.
return "\n" . $return . "\n\n";
}
}
?>

View File

@ -0,0 +1,73 @@
<?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.2 2006/02/15 10:20:08 toggg Exp $
*
*/
/**
*
* 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 {
/**
*
* The regular expression used to find source text matching this
* rule.
*
* @access public
*
* @var string
*
*/
var $regex = "/<nowiki>(.*)<\/nowiki>/Ums";
/**
*
* 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.
*
*/
function process(&$matches)
{
$options = array('text' => $matches[1]);
return $this->wiki->addToken($this->rule, $options);
}
}
?>

View File

@ -0,0 +1,286 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Mediawiki: Parses for tables.
*
* This class implements a Text_Wiki_Rule to find tables in pipe syntax
* {| ... |- ... | ... |}
* On parsing, the text itself is left in place, but the starting and ending
* tags for table, rows and cells are replaced with tokens. (nested tables enabled)
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @copyright 2005 bertrand Gugger
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Table.php,v 1.7 2005/12/06 15:54:56 ritzmo Exp $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* Table rule parser class for Mediawiki.
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @copyright 2005 bertrand Gugger
* @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()
*/
var $regex = '#^\{\|(.*?)(?:^\|\+(.*?))?(^(?:((?R))|.)*?)^\|}#msi';
/**
* The regular expression used in second stage to find table's rows
* used by process() to call back processRows()
*
* @access public
* @var string
* @see process()
* @see processRows()
*/
var $regexRows = '#(?:^(\||!)-|\G)(.*?)^(.*?)(?=^(?:\|-|!-|\z))#msi';
/**
* The regular expression used in third stage to find rows's cells
* used by processRows() to call back processCells()
*
* @access public
* @var string
* @see process()
* @see processCells()
*/
var $regexCells =
'#((?:^\||^!|\|\||!!|\G))(?:([^|\n]*?) \|(?!\|))?(.+?)(?=^\||^!|\|\||!!|\z)#msi';
/**
* The current table nesting depth, starts by zero
*
* @access private
* @var int
*/
var $_level = 0;
/**
* The count of rows for this level
*
* @access private
* @var array of int
*/
var $_countRows = array();
/**
* The max count of cells for this level
*
* @access private
* @var array of int
*/
var $_maxCells = array();
/**
* The count of cells for each row
*
* @access private
* @var array of int
*/
var $_countCells = array();
/**
* The count of spanned cells from previous rowspans for each column
*
* @access private
* @var array of int
*/
var $_spanCells = array();
/**
* Generates a replacement for the matched text. Returned 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)
* 'caption_start' : the start of associated caption
* 'caption_end' : the end of associated caption
*
* 'level' => the table nesting level (starting zero) ('table_start')
*
* 'rows' => the number of rows in the table ('table_start')
*
* 'cols' => the number of columns in the table or rows
* ('table_start' and 'row_start')
*
* 'span' => column span ('cell_start')
*
* 'row_span' => row span ('cell_start')
*
* 'attr' => header optional attribute flag ('row_start' or 'cell_start')
*
* 'format' => table, row or cell optional styling ('xxx_start')
*
* @param array &$matches The array of matches from parse().
* @return string the original text with tags replaced by delimited tokens
* which point to the the token array containing their type and definition
* @access public
*/
function process(&$matches)
{
if (array_key_exists(4, $matches)) {
$this->_level++;
$expsub = preg_replace_callback(
$this->regex,
array(&$this, 'process'),
$matches[3]
);
$this->_level--;
} else {
$expsub = $matches[3];
}
$this->_countRows[$this->_level] = $this->_maxCells[$this->_level] = 0;
$this->_countCells[$this->_level] = $this->_spanCells[$this->_level] = array();
$sub = preg_replace_callback(
$this->regexRows,
array(&$this, 'processRows'),
$expsub
);
$param = array(
'type' => 'table_start',
'level' => $this->_level,
'rows' => $this->_countRows[$this->_level],
'cols' => $this->_maxCells[$this->_level]
);
if ($format = trim($matches[1])) {
$param['format'] = $format;
}
$ret = $this->wiki->addToken($this->rule, $param );
if ($matches[2]) {
$ret .= $this->wiki->addToken($this->rule, array(
'type' => 'caption_start',
'level' => $this->_level ) ) . $matches[2] .
$this->wiki->addToken($this->rule, array(
'type' => 'caption_end',
'level' => $this->_level ) );
}
$param['type'] = 'table_end';
return $ret . $sub . $this->wiki->addToken($this->rule, $param );
}
/**
* Generates a replacement for the matched rows. Token options are:
* 'type' =>
* 'row_start' : the start of a row
* 'row_end' : the end of a row
*
* 'order' => the row order in the table
*
* 'cols' => the count of cells in the row
*
* 'attr' => header optional attribute flag
*
* 'format' => row optional styling
*
* @param array &$matches The array of matches from process() callback.
* @return string 2 delimited tokens pointing the row params
* and containing the cells-parsed block of text between the tags
* @access public
*/
function processRows(&$matches)
{
$this->_countCells[$this->_level][$this->_countRows[$this->_level]] = 0;
$sub = preg_replace_callback(
$this->regexCells,
array(&$this, 'processCells'),
$matches[3]
);
$param = array(
'type' => 'row_start',
'order' => $this->_countRows[$this->_level],
'cols' => $this->_countCells[$this->_level][$this->_countRows[$this->_level]++]
);
if ($matches[1] == '!') {
$param['attr'] = 'header';
}
if ($format = trim($matches[2])) {
$param['format'] = $format;
}
if ($this->_maxCells[$this->_level] < $param['cols']) {
$this->_maxCells[$this->_level] = $param['cols'];
}
$ret = $this->wiki->addToken($this->rule, $param );
$param['type'] = 'row_end';
return $ret . $sub . $this->wiki->addToken($this->rule, $param );
}
/**
* Generates a replacement for the matched cells. Token options are:
* 'type' =>
* 'cell_start' : the start of a row
* 'cell_end' : the end of a row
*
* 'order' => the cell order in the row
*
* 'cols' => the count of cells in the row
*
* 'span' => column span
*
* 'row_span' => row span
*
* 'attr' => header optional attribute flag
*
* 'format' => cell optional styling
*
* @param array &$matches The array of matches from processRows() callback.
* @return string 2 delimited tokens pointing the cell params
* and containing the block of text between the tags
* @access public
*/
function processCells(&$matches)
{
$order = & $this->_countCells[$this->_level][$this->_countRows[$this->_level]];
while (isset($this->_spanCells[$this->_level][$order])) {
if (--$this->_spanCells[$this->_level][$order] < 2) {
unset($this->_spanCells[$this->_level][$order]);
}
$order++;
}
$param = array(
'type' => 'cell_start',
'attr' => $matches[1] && ($matches[1]{0} == '!') ? 'header': null,
'span' => 1,
'rowspan' => 1,
'order' => $order
);
if ($format = trim($matches[2])) {
if (preg_match('#(.*)colspan=("|\')?(\d+)(?(2)\2)(.*)#i', $format, $pieces)) {
$param['span'] = (int)$pieces[3];
$format = $pieces[1] . $pieces[4];
}
if (preg_match('#(.*)rowspan=("|\')?(\d+)(?(2)\2)(.*)#i', $format, $pieces)) {
$this->_spanCells[$this->_level][$order] =
$param['rowspan'] = (int)$pieces[3];
$format = $pieces[1] . $pieces[4];
}
$param['format'] = $format;
}
$this->_countCells[$this->_level][$this->_countRows[$this->_level]] += $param['span'];
$ret = $this->wiki->addToken($this->rule, $param);
$param['type'] = 'cell_end';
return $ret . $matches[3] . $this->wiki->addToken($this->rule, $param );
}
}
?>

348
vendor/Text/Wiki/Parse/Mediawiki/Url.php vendored Normal file
View File

@ -0,0 +1,348 @@
<?php
/**
*
* Parse for URLS in the source text.
*
* @category Text
*
* @package Text_Wiki
*
* @author Paul M. Jones <pmjones@php.net>
*
* @author Moritz Venn <moritz.venn@freaque.net>
*
* @license LGPL
*
* @version $Id: Url.php,v 1.1 2005/12/06 15:54:56 ritzmo Exp $
*
*/
/**
*
* Parse for URLS in the source text.
*
* Various URL markings are supported: inline (the URL by itself),
* inline (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
* undescribed -- [http://example.com]
* described -- [http://example.com Example Description]
* described -- [http://www.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>
*
* @author Moritz Venn <moritz.venn@freaque.net>
*
*/
class Text_Wiki_Parse_Url extends Text_Wiki_Parse {
/**
*
* 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
*
*/
var $conf = array(
'schemes' => array(
'http://',
'https://',
'ftp://',
'gopher://',
'news://',
'mailto:'
)
);
/**
*
* Constructor.
*
* We override the constructor so we can comment the regex nicely.
*
* @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();
$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;
")*" . // end pattern
"[^ \\t\\n\\/\"\'{$this->wiki->delim}]*" .
"[A-Za-z0-9\\/?=&~_]";
}
/**
*
* Find three different kinds of URLs in the source text.
*
* @access public
*
*/
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
);
// -------------------------------------------------------------
//
// Unnamed-reference ('Ordinary'-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(
$tmp_regex,
//array(&$this, 'processFootnote'),
array(&$this, 'processOrdinary'),
$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
);
//$tmp_regex = '/(^|[^A-Za-z])([a-zA-Z])(.*?)/';
$tmp_regex = '/(^|\s)([a-zA-Z0-9\-]+\.[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]+)+)($|\s)/';
// use the standard callback for inline URLs
$this->wiki->source = preg_replace_callback(
$tmp_regex,
array(&$this, 'processWithoutProtocol'),
$this->wiki->source
);
$tmp_regex = '/(^|\s|'.$this->wiki->delim.')<([a-zA-Z0-9\-\.%_\+\!\*\'\(\)\,]+@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]+)+)>(\s|'.$this->wiki->delim.'|$)/';
// use the standard callback for inline URLs
$this->wiki->source = preg_replace_callback(
$tmp_regex,
array(&$this, 'processInlineEmail'),
$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.
*
*/
function process(&$matches)
{
// set options
$options = array(
'type' => 'inline',
'href' => $matches[2],
'text' => $matches[2]
);
// tokenize
return $matches[1] . $this->wiki->addToken($this->rule, $options) . $matches[5];
}
function processWithoutProtocol(&$matches)
{
// set options
$options = array(
'type' => 'inline',
'href' => 'http://'.$matches[2],
'text' => $matches[2]
);
// tokenize
return $matches[1] . $this->wiki->addToken($this->rule, $options) . $matches[4];
}
function processInlineEmail(&$matches)
{
// set options
$options = array(
'type' => 'inline',
'href' => 'mailto://'.$matches[2],
'text' => $matches[2]
);
// tokenize
return $matches[1] . $this->wiki->addToken($this->rule, $options) . $matches[4];
}
/**
*
* 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.
*
*/
function processFootnote(&$matches)
{
// 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);
}
function processOrdinary(&$matches)
{
// keep a running count for footnotes
$this->footnoteCount++;
// set options
$options = array(
'type' => 'descr',
'href' => $matches[1],
'text' => $matches[1]
);
// 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.
*
*/
function processDescr(&$matches)
{
// set options
$options = array(
'type' => 'descr',
'href' => $matches[1],
'text' => $matches[4]
);
// tokenize
return $this->wiki->addToken($this->rule, $options);
}
}
?>

View File

@ -0,0 +1,302 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Mediawiki: Parses for links to (inter)wiki pages or images.
*
* Text_Wiki rule parser to find links, it groups the 3 rules:
* # Wikilink: links to internal Wiki pages
* # Interwiki: links to external Wiki pages (sister projects, interlangage)
* # Image: Images
* as defined by text surrounded by double brackets [[]]
* Translated are the link itself, the section (anchor) and alternate text
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @author Paul M. Jones <pmjones@php.net>
* @copyright 2005 bertrand Gugger
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Wikilink.php,v 1.7 2006/02/25 13:34:50 toggg Exp $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* Wikilink, Interwiki and Image rules parser class for Mediawiki.
* This class implements a Text_Wiki_Parse to find links marked
* in source by text surrounded by 2 opening/closing brackets as
* [[Wiki page name#Section|Alternate text]]
* On parsing, the link is replaced with a token.
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @copyright 2005 bertrand Gugger
* @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 {
/**
* Configuration for this rule (Wikilink)
*
* @access public
* @var array
*/
var $conf = array(
'spaceUnderscore' => true,
'project' => array('demo', 'd'),
'url' => 'http://example.com/en/page=%s',
'langage' => 'en'
);
/**
* Configuration for the Image rule
*
* @access public
* @var array
*/
var $imageConf = array(
'prefix' => array('Image', 'image')
);
/**
* Configuration for the Interwiki rule
*
* @access public
* @var array
*/
var $interwikiConf = array(
'sites' => array(
'manual' => 'http://www.php.net/manual/en/%s',
'pear' => 'http://pear.php.net/package/%s',
'bugs' => 'http://pear.php.net/package/%s/bugs'
),
'interlangage' => array('en', 'de', 'fr')
);
/**
* 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 Text_Wiki_Parse::parse()
*/
var $regex = '/(?<!\[)\[\[(?!\[)\s*(:?)((?:[^:]+:)+)?([^:]+)(?:#(.*))?\s*(?:\|(((?R))|.*))?]]/msU';
/**
* Constructor.
* We override the constructor to get Image and Interwiki config
*
* @param object &$obj the base conversion handler
* @return The parser object
* @access public
*/
function Text_Wiki_Parse_Wikilink(&$obj)
{
$default = $this->conf;
parent::Text_Wiki_Parse($obj);
// override config options for image if specified
if (in_array('Image', $this->wiki->disable)) {
$this->imageConf['prefix'] = array();
} else {
if (isset($this->wiki->parseConf['Image']) &&
is_array($this->wiki->parseConf['Image'])) {
$this->imageConf = array_merge(
$this->imageConf,
$this->wiki->parseConf['Image']
);
}
}
// override config options for interwiki if specified
if (in_array('Interwiki', $this->wiki->disable)) {
$this->interwikiConf['sites'] = array();
$this->interwikiConf['interlangage'] = array();
} else {
if (isset($this->wiki->parseConf['Interwiki']) &&
is_array($this->wiki->parseConf['Interwiki'])) {
$this->interwikiConf = array_merge(
$this->interwikiConf,
$this->wiki->parseConf['Interwiki']
);
}
if (empty($this->conf['langage'])) {
$this->interwikiConf['interlangage'] = array();
}
}
// convert the list of recognized schemes to a regex OR,
/* $schemes = $this->getConf('schemes', $default['schemes']);
$this->url = str_replace( '#delim#', $this->wiki->delim,
'#(?:' . (is_array($schemes) ? implode('|', $schemes) : $schemes) . ')://'
. $this->getConf('host_regexp', $default['host_regexp'])
. $this->getConf('path_regexp', $default['path_regexp']) .'#'); */
}
/**
* Generates a replacement for the matched text. Token options are:
* - 'page' => the name of the target wiki page
* -'anchor' => the optional section in it
* - 'text' => the optional alternate link text
*
* @access public
* @param array &$matches The array of matches from parse().
* @return string token to be used as replacement
*/
function process(&$matches)
{
// Starting colon ?
$colon = !empty($matches[1]);
$auto = $interlang = $interwiki = $image = $site = '';
// Prefix ?
if (!empty($matches[2])) {
$prefix = explode(':', substr($matches[2], 0, -1));
$count = count($prefix);
$i = -1;
// Autolink
if (isset($this->conf['project']) &&
in_array(trim($prefix[0]), $this->conf['project'])) {
$auto = trim($prefix[0]);
unset($prefix[0]);
$i = 0;
}
while (++$i < $count) {
$prefix[$i] = trim($prefix[$i]);
// interlangage
if (!$interlang &&
in_array($prefix[$i], $this->interwikiConf['interlangage'])) {
$interlang = $prefix[$i];
unset($prefix[$i]);
continue;
}
// image
if (!$image && in_array($prefix[$i], $this->imageConf['prefix'])) {
$image = $prefix[$i];
unset($prefix[$i]);
break;
}
// interwiki
if (isset($this->interwikiConf['sites'][$prefix[$i]])) {
$interwiki = $this->interwikiConf['sites'][$prefix[$i]];
$site = $prefix[$i];
unset($prefix[$i]);
}
break;
}
if ($prefix) {
$matches[3] = implode(':', $prefix) . ':' . $matches[3];
}
}
$text = empty($matches[5]) ? $matches[3] : $matches[5];
$matches[3] = trim($matches[3]);
$matches[4] = empty($matches[4]) ? '' : trim($matches[4]);
if ($this->conf['spaceUnderscore']) {
$matches[3] = preg_replace('/\s+/', '_', $matches[3]);
$matches[4] = preg_replace('/\s+/', '_', $matches[4]);
}
if ($image) {
return $this->image($matches[3] . (empty($matches[4]) ? '' : '#' . $matches[4]),
$text, $interlang, $colon);
}
if (!$interwiki && $interlang && isset($this->conf['url'])) {
if ($interlang == $this->conf['langage']) {
$interlang = '';
} else {
$interwiki = $this->conf['url'];
$site = isset($this->conf['project']) ? $this->conf['project'][0] : '';
}
}
if ($interwiki) {
return $this->interwiki($site, $interwiki,
$matches[3] . (empty($matches[4]) ? '' : '#' . $matches[4]),
$text, $interlang, $colon);
}
if ($interlang) {
$matches[3] = $interlang . ':' . $matches[3];
$text = (empty($matches[5]) ? $interlang . ':' : '') . $text;
}
// set the options
$options = array(
'page' => $matches[3],
'anchor' => (empty($matches[4]) ? '' : $matches[4]),
'text' => $text
);
// create and return the replacement token
return $this->wiki->addToken($this->rule, $options);
}
/**
* Generates an image token. Token options are:
* - 'src' => the name of the image file
* - 'attr' => an array of attributes for the image:
* | - 'alt' => the optional alternate image text
* | - 'align => 'left', 'center' or 'right'
*
* @access public
* @param array &$matches The array of matches from parse().
* @return string token to be used as replacement
*/
function image($name, $text, $interlang, $colon)
{
$attr = array('alt' => '');
// scan text for supplementary attibutes
if (strpos($text, '|') !== false) {
$splits = explode('|', $text);
$sep = '';
foreach ($splits as $split) {
switch (strtolower($split)) {
case 'left': case 'center': case 'right':
$attr['align'] = strtolower($split);
break;
default:
$attr['alt'] .= $sep . $split;
$sep = '|';
}
}
} else {
$attr['alt'] = $text;
}
$options = array(
'src' => ($interlang ? $interlang . ':' : '') . $name,
'attr' => $attr);
// create and return the replacement token
return $this->wiki->addToken('Image', $options);
}
/**
* Generates an interwiki token. Token options are:
* - 'page' => the name of the target wiki page
* - 'site' => the key for external site
* - 'url' => the full target url
* - 'text' => the optional alternate link text
*
* @access public
* @param array &$matches The array of matches from parse().
* @return string token to be used as replacement
*/
function interwiki($site, $interwiki, $page, $text, $interlang, $colon)
{
if ($interlang) {
$interwiki = preg_replace('/\b' . $this->conf['langage'] . '\b/i',
$interlang, $interwiki);
}
// set the options
$options = array(
'page' => $page,
'site' => $site,
'url' => sprintf($interwiki, $page),
'text' => $text
);
// create and return the replacement token
return $this->wiki->addToken('Interwiki', $options);
}
}
?>

218
vendor/Text/Wiki/Render.php vendored Normal file
View File

@ -0,0 +1,218 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Base rendering class for parsed and tokenized text.
*
* PHP versions 4 and 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: Render.php,v 1.10 2006/03/11 07:12:13 justinpatrin Exp $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* Base rendering class for parsed and tokenized text.
*
* @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 Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render {
/**
*
* Configuration options for this render rule.
*
* @access public
*
* @var string
*
*/
var $conf = array();
/**
*
* The name of this rule's format.
*
* @access public
*
* @var string
*
*/
var $format = null;
/**
*
* The name of this rule's token array elements.
*
* @access public
*
* @var string
*
*/
var $rule = null;
/**
*
* A reference to the calling Text_Wiki object.
*
* This is needed so that each rule has access to the same source
* text, token set, URLs, interwiki maps, page names, etc.
*
* @access public
*
* @var object
*/
var $wiki = null;
/**
*
* Constructor for this render format or rule.
*
* @access public
*
* @param object &$obj The calling "parent" Text_Wiki object.
*
*/
function Text_Wiki_Render(&$obj)
{
// keep a reference to the calling Text_Wiki object
$this->wiki =& $obj;
// get the config-key-name for this object,
// strip the Text_Wiki_Render_ part
// 01234567890123456
$tmp = get_class($this);
$tmp = substr($tmp, 17);
// split into pieces at the _ mark.
// first part is format, second part is rule.
$part = explode('_', $tmp);
$this->format = isset($part[0]) ? ucwords(strtolower($part[0])) : null;
$this->rule = isset($part[1]) ? ucwords(strtolower($part[1])) : null;
// is there a format but no rule?
// then this is the "main" render object, with
// pre() and post() methods.
if ($this->format && ! $this->rule &&
isset($this->wiki->formatConf[$this->format]) &&
is_array($this->wiki->formatConf[$this->format])) {
// this is a format render object
$this->conf = array_merge(
$this->conf,
$this->wiki->formatConf[$this->format]
);
}
// is there a format and a rule?
if ($this->format && $this->rule &&
isset($this->wiki->renderConf[$this->format][$this->rule]) &&
is_array($this->wiki->renderConf[$this->format][$this->rule])) {
// this is a rule render object
$this->conf = array_merge(
$this->conf,
$this->wiki->renderConf[$this->format][$this->rule]
);
}
}
/**
*
* Simple method to safely get configuration key values.
*
* @access public
*
* @param string $key The configuration key.
*
* @param mixed $default If the key does not exist, return this value
* instead.
*
* @return mixed The configuration key value (if it exists) or the
* default value (if not).
*
*/
function getConf($key, $default = null)
{
if (isset($this->conf[$key])) {
return $this->conf[$key];
} else {
return $default;
}
}
/**
*
* Simple method to wrap a configuration in an sprintf() format.
*
* @access public
*
* @param string $key The configuration key.
*
* @param string $format The sprintf() format string.
*
* @return mixed The formatted configuration key value (if it exists)
* or null (if it does not).
*
*/
function formatConf($format, $key)
{
if (isset($this->conf[$key])) {
//$this->conf[$key] needs a textEncode....at least for Xhtml output...
return sprintf($format, $this->conf[$key]);
} else {
return null;
}
}
/**
* Default method to render url
*
* @access public
* @param string $urlChunk a part of an url to render
* @return rendered url
*
*/
function urlEncode($urlChunk)
{
return rawurlencode($urlChunk);
}
/**
* Default method to render text (htmlspecialchars)
*
* @access public
* @param string $text the text to render
* @return rendered text
*
*/
function textEncode($text)
{
return htmlspecialchars($text);
}
}
?>

90
vendor/Text/Wiki/Render/Latex.php vendored Normal file
View File

@ -0,0 +1,90 @@
<?php
/**
*
* Formats parsed Text_Wiki for LaTeX rendering.
*
* $Id: Latex.php,v 1.2 2004/09/25 19:05:13 pmjones Exp $
*
* @author Jeremy Cowgar <jeremy@cowgar.com>
*
* @package Text_Wiki
*
* @todo [http://google.com] becomes 1 with a LaTeX footnote in subscript.
* This should be a normal LaTeX footnote associated with the
* previous word?
*
* @todo parse "..." to be ``...''
*
* @todo parse '...' to be `...'
*
* @todo move escape_latex to a static function, move escaping to the
* individual .php files they are associated with
*
* @todo allow the user to add conf items to do things like
* + A custom document header
* + Custom page headings
* + Include packages
* + Set Title, Author, Date
* + Include a title page
* + Not output Document Head/Foot (maybe combinding many pages?)
*
*/
class Text_Wiki_Render_Latex extends Text_Wiki_Render {
function escape_latex ($txt) {
$txt = str_replace("\\", "\\\\", $txt);
$txt = str_replace('#', '\#', $txt);
$txt = str_replace('$', '\$', $txt);
$txt = str_replace('%', '\%', $txt);
$txt = str_replace('^', '\^', $txt);
$txt = str_replace('&', '\&', $txt);
$txt = str_replace('_', '\_', $txt);
$txt = str_replace('{', '\{', $txt);
$txt = str_replace('}', '\}', $txt);
// Typeset things a bit prettier than normas
$txt = str_replace('~', '$\sim$', $txt);
$txt = str_replace('...', '\ldots', $txt);
return $txt;
}
function escape($tok, $ele) {
if (isset($tok[$ele])) {
$tok[$ele] = $this->escape_latex($tok[$ele]);
}
return $tok;
}
function pre()
{
foreach ($this->wiki->tokens as $k => $tok) {
if ($tok[0] == 'Code') {
continue;
}
$tok[1] = $this->escape($tok[1], 'text');
$tok[1] = $this->escape($tok[1], 'page');
$tok[1] = $this->escape($tok[1], 'href');
$this->wiki->tokens[$k] = $tok;
}
$this->wiki->source = $this->escape_latex($this->wiki->source);
return
"\\documentclass{article}\n".
"\\usepackage{ulem}\n".
"\\pagestyle{headings}\n".
"\\begin{document}\n";
}
function post()
{
return "\\end{document}\n";
}
}
?>

View File

@ -0,0 +1,33 @@
<?php
/**
*
* This class renders an anchor target name in LaTeX.
*
* $Id: Anchor.php,v 1.2 2004/09/25 19:05:13 pmjones Exp $
*
* @author Jeremy Cowgar <jeremy@cowgar.com>
*
* @package Text_Wiki
*
*/
class Text_Wiki_Render_Latex_Anchor extends Text_Wiki_Render {
function token($options)
{
extract($options); // $type, $name
if ($type == 'start') {
//return sprintf('<a id="%s">',$name);
return '';
}
if ($type == 'end') {
//return '</a>';
return '';
}
}
}
?>

View File

@ -0,0 +1,36 @@
<?php
class Text_Wiki_Render_Latex_Blockquote extends Text_Wiki_Render {
var $conf = array('css' => null);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
$type = $options['type'];
$level = $options['level'];
// starting
if ($type == 'start') {
return "\\begin{quote}\n";
}
// ending
if ($type == 'end') {
return "\\end{quote}\n\n";
}
}
}
?>

28
vendor/Text/Wiki/Render/Latex/Bold.php vendored Normal file
View File

@ -0,0 +1,28 @@
<?php
class Text_Wiki_Render_Latex_Bold extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
if ($options['type'] == 'start') {
return '\textbf{';
}
if ($options['type'] == 'end') {
return '}';
}
}
}
?>

54
vendor/Text/Wiki/Render/Latex/Box.php vendored Normal file
View File

@ -0,0 +1,54 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Box rule end renderer for Latex
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @copyright 2005 bertrand Gugger
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Box.php,v 1.1 2005/08/15 09:50:55 toggg Exp $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders a box drawn in Latex.
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @copyright 2005 bertrand Gugger
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Latex_Box extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
if ($options['type'] == 'start') {
return '\framebox[\textwidth]{';
}
if ($options['type'] == 'end') {
return "}\n";
}
}
}
?>

24
vendor/Text/Wiki/Render/Latex/Break.php vendored Normal file
View File

@ -0,0 +1,24 @@
<?php
class Text_Wiki_Render_Latex_Break extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
return "\\newline\n";
}
}
?>

View File

@ -0,0 +1,33 @@
<?php
class Text_Wiki_Render_Latex_Center extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
return 'Center: NI';
if ($options['type'] == 'start') {
//return "\n<center>\n";
return '<div style="text-align: center;">';
}
if ($options['type'] == 'end') {
//return "</center>\n";
return '</div>';
}
}
}
?>

26
vendor/Text/Wiki/Render/Latex/Code.php vendored Normal file
View File

@ -0,0 +1,26 @@
<?php
class Text_Wiki_Render_Latex_Code extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
$text = $options['text'];
return "\\begin{verbatim}\n$text\n\\end{verbatim}\n\n";
}
}
?>

View File

@ -0,0 +1,58 @@
<?php
class Text_Wiki_Render_Latex_Colortext extends Text_Wiki_Render {
var $colors = array(
'aqua',
'black',
'blue',
'fuchsia',
'gray',
'green',
'lime',
'maroon',
'navy',
'olive',
'purple',
'red',
'silver',
'teal',
'white',
'yellow'
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
return 'Colortext: NI';
$type = $options['type'];
$color = $options['color'];
if (! in_array($color, $this->colors)) {
$color = '#' . $color;
}
if ($type == 'start') {
return "<span style=\"color: $color;\">";
}
if ($options['type'] == 'end') {
return '</span>';
}
}
}
?>

View File

@ -0,0 +1,53 @@
<?php
class Text_Wiki_Render_Latex_Deflist extends Text_Wiki_Render {
var $conf = array(
'css_dl' => null,
'css_dt' => null,
'css_dd' => null
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
$type = $options['type'];
switch ($type)
{
case 'list_start':
return "\\begin{description}\n";
case 'list_end':
return "\\end{description}\n\n";
case 'term_start':
return '\item[';
case 'term_end':
return '] ';
case 'narr_start':
return '{';
case 'narr_end':
return "}\n";
default:
return '';
}
}
}
?>

View File

@ -0,0 +1,25 @@
<?php
class Text_Wiki_Render_Latex_Delimiter extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
// TODO: Is this where I can do some LaTeX escaping for items
// such as $ { } _ ?
return "Delimiter: ".$options['text'];
}
}
?>

23
vendor/Text/Wiki/Render/Latex/Embed.php vendored Normal file
View File

@ -0,0 +1,23 @@
<?php
class Text_Wiki_Render_Latex_Embed extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
return "Embed: ".$options['text'];
}
}
?>

View File

@ -0,0 +1,29 @@
<?php
class Text_Wiki_Render_Latex_Emphasis extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
if ($options['type'] == 'start') {
return '\textsl{';
}
if ($options['type'] == 'end') {
return '}';
}
}
}
?>

73
vendor/Text/Wiki/Render/Latex/Font.php vendored Normal file
View File

@ -0,0 +1,73 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* BBCode: extra Font rules renderer to size the text
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @copyright 2005 bertrand Gugger
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Font.php,v 1.2 2006/03/11 11:14:23 toggg Exp $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* Font rule render class (used for BBCode)
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @copyright 2005 bertrand Gugger
* @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::Text_Wiki_Render()
*/
class Text_Wiki_Render_Latex_Font extends Text_Wiki_Render {
/**
* A table to translate the sizes
*
* @access public
* @var array
*/
var $sizes = array(
'tiny' => 5,
'scriptsize' => 7,
'footnotesize' => 8,
'small' => 9,
'normalsize' => 11,
'large' => 13,
'Large' => 16,
'LARGE' => 19,
'huge' => 22,
'Huge' => 9999);
/**
* Renders a token into text matching the requested format.
* process the font size option
*
* @access public
* @param array $options The "options" portion of the token (second element).
* @return string The text rendered from the token options.
*/
function token($options)
{
if ($options['type'] == 'start') {
foreach ($this->sizes as $key => $lim) {
if ($options['size'] < $lim) {
break;
}
}
return '\{' . $key . '}{';
}
if ($options['type'] == 'end') {
return '}';
}
}
}
?>

View File

@ -0,0 +1,6 @@
<?php
class Text_Wiki_Render_Latex_Freelink extends Text_Wiki_Render_Latex_Wikilink {
// renders identically to wikilinks, only the parsing is different :-)
}
?>

View File

@ -0,0 +1,23 @@
<?php
class Text_Wiki_Render_Latex_Function extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
return "Function: NI";
}
}
?>

View File

@ -0,0 +1,33 @@
<?php
class Text_Wiki_Render_Latex_Heading extends Text_Wiki_Render {
function token($options)
{
// get nice variable names (type, level)
extract($options);
if ($type == 'start') {
switch ($level)
{
case '1':
return '\part{';
case '2':
return '\section{';
case '3':
return '\subsection{';
case '4':
return '\subsubsection{';
case '5':
return '\paragraph{';
case '6':
return '\subparagraph{';
}
}
if ($type == 'end') {
return "}\n";
}
}
}
?>

23
vendor/Text/Wiki/Render/Latex/Horiz.php vendored Normal file
View File

@ -0,0 +1,23 @@
<?php
class Text_Wiki_Render_Latex_Horiz extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
return "\n\\noindent\\rule{\\textwidth}{1pt}\n";
}
}
?>

25
vendor/Text/Wiki/Render/Latex/Html.php vendored Normal file
View File

@ -0,0 +1,25 @@
<?php
class Text_Wiki_Render_Latex_Html extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
print_r($this);
return '';
}
}
?>

70
vendor/Text/Wiki/Render/Latex/Image.php vendored Normal file
View File

@ -0,0 +1,70 @@
<?php
class Text_Wiki_Render_Latex_Image extends Text_Wiki_Render {
var $conf = array(
'base' => '/'
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
return 'Image: NI';
$src = '"' .
$this->getConf('base', '/') .
$options['src'] . '"';
if (isset($options['attr']['link'])) {
// this image has a link
if (strpos($options['attr']['link'], '://')) {
// it's a URL
$href = $options['attr']['link'];
} else {
$href = $this->wiki->getRenderConf('xhtml', 'wikilink', 'view_url') .
$options['attr']['link'];
}
} else {
// image is not linked
$href = null;
}
// unset these so they don't show up as attributes
unset($options['attr']['link']);
$attr = '';
$alt = false;
foreach ($options['attr'] as $key => $val) {
if (strtolower($key) == 'alt') {
$alt = true;
}
$attr .= " $key=\"$val\"";
}
// always add an "alt" attribute per Stephane Solliec
if (! $alt) {
$attr .= ' alt="' . basename($options['src']) . '"';
}
if ($href) {
return "<a href=\"$href\"><img src=$src$attr/></a>";
} else {
return "<img src=$src$attr/>";
}
}
}
?>

View File

@ -0,0 +1,8 @@
<?php
class Text_Wiki_Render_Latex_Include extends Text_Wiki_Render {
function token()
{
return '';
}
}
?>

View File

@ -0,0 +1,58 @@
<?php
class Text_Wiki_Render_Latex_Interwiki extends Text_Wiki_Render {
var $conf = array(
'sites' => array(
'MeatBall' => 'http://www.usemod.com/cgi-bin/mb.pl?%s',
'Advogato' => 'http://advogato.org/%s',
'Wiki' => 'http://c2.com/cgi/wiki?%s'
)
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
$text = $options['text'];
if (isset($options['url'])) {
// calculated by the parser (e.g. Mediawiki)
$href = $options['url'];
} else {
$site = $options['site'];
// toggg 2006/02/05 page name must be url encoded (e.g. may contain spaces)
$page = $this->urlEncode($options['page']);
if (isset($this->conf['sites'][$site])) {
$href = $this->conf['sites'][$site];
} else {
return $text;
}
// old form where page is at end,
// or new form with %s placeholder for sprintf()?
if (strpos($href, '%s') === false) {
// use the old form
$href = $href . $page;
} else {
// use the new form
$href = sprintf($href, $page);
}
}
return $text . '\footnote{' . $href . '}';
}
}
?>

View File

@ -0,0 +1,28 @@
<?php
class Text_Wiki_Render_Latex_Italic extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
if ($options['type'] == 'start') {
return '\textit{';
}
if ($options['type'] == 'end') {
return '}';
}
}
}
?>

76
vendor/Text/Wiki/Render/Latex/List.php vendored Normal file
View File

@ -0,0 +1,76 @@
<?php
class Text_Wiki_Render_Latex_List extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* This rendering method is syntactically and semantically compliant
* with XHTML 1.1 in that sub-lists are part of the previous list item.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
// make nice variables (type, level, count)
extract($options);
switch ($type)
{
case 'bullet_list_start':
return "\\begin{itemize}\n";
case 'bullet_list_end':
return "\\end{itemize}\n";
case 'number_list_start':
$depth = 'enumi' . str_pad('', $level, 'i');
$enum = '\arabic';
if (isset($format)) {
switch ($format) {
case 'a':
$enum = '\alph';
break;
case 'A':
$enum = '\Alph';
break;
case 'i':
$enum = '\roman';
break;
case 'I':
$enum = '\Roman';
break;
}
}
return '\renewcommand{\labelenumi}{' . $enum . '{' . $depth .
"}}\n\\begin{enumerate}\n";
case 'number_list_end':
return "\\end{enumerate}\n";
case 'bullet_item_start':
case 'number_item_start':
return '\item{';
case 'bullet_item_end':
case 'number_item_end':
return "}\n";
default:
// ignore item endings and all other types.
// item endings are taken care of by the other types
// depending on their place in the list.
return '';
break;
}
}
}
?>

View File

@ -0,0 +1,12 @@
<?php
class Text_Wiki_Render_Latex_Newline extends Text_Wiki_Render {
function token($options)
{
return "\\newline\n";
}
}
?>

48
vendor/Text/Wiki/Render/Latex/Page.php vendored Normal file
View File

@ -0,0 +1,48 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Page rule end renderer for Latex
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @copyright 2005 bertrand Gugger
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Page.php,v 1.1 2005/08/15 15:27:16 toggg Exp $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders page markers in Latex.
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @copyright 2005 bertrand Gugger
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Latex_Page extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
return "\\newpage\n";
}
}
?>

View File

@ -0,0 +1,31 @@
<?php
class Text_Wiki_Render_Latex_Paragraph extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
extract($options); //type
if ($type == 'start') {
return '';
}
if ($type == 'end') {
return "\n\n";
}
}
}
?>

View File

@ -0,0 +1,34 @@
<?php
class Text_Wiki_Render_Latex_Phplookup extends Text_Wiki_Render {
var $conf = array('target' => '_blank');
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
return 'Phplookup: NI';
$text = trim($options['text']);
$target = $this->getConf('target', '');
if ($target) {
$target = " target=\"$target\"";
}
return "<a$target href=\"http://php.net/$text\">$text</a>";
}
}
?>

View File

@ -0,0 +1,49 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Plugin rule end renderer for Latex
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @copyright 2005 bertrand Gugger
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Plugin.php,v 1.1 2005/08/17 09:16:35 toggg Exp $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders wiki plugins in Latex. (empty)
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @copyright 2005 bertrand Gugger
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Latex_Plugin extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
* Plugins produce wiki markup so are processed by parsing, no tokens produced
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
return '';
}
}
?>

View File

@ -0,0 +1,40 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Jeremy Cowgar <jeremy@cowgar.com> |
// +----------------------------------------------------------------------+
//
// $Id: Prefilter.php,v 1.2 2004/09/25 19:05:13 pmjones Exp $
/**
*
* This class implements a Text_Wiki_Render_Latex to "pre-filter" source text so
* that line endings are consistently \n, lines ending in a backslash \
* are concatenated with the next line, and tabs are converted to spaces.
*
* @author Jeremy Cowgar <jeremy@cowgar.com>
*
* @package Text_Wiki
*
*/
class Text_Wiki_Render_Latex_Prefilter extends Text_Wiki_Render {
function token()
{
return '';
}
}
?>

View File

@ -0,0 +1,48 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Preformatted rule end renderer for Latex
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @copyright 2005 bertrand Gugger
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Preformatted.php,v 1.1 2005/08/15 06:15:36 toggg Exp $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders preformated text in Latex.
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @copyright 2005 bertrand Gugger
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Latex_Preformatted extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
return "\\begin{verbatim}\n" . $options['text'] . "\n\\end{verbatim}\n";
}
}
?>

23
vendor/Text/Wiki/Render/Latex/Raw.php vendored Normal file
View File

@ -0,0 +1,23 @@
<?php
class Text_Wiki_Render_Latex_Raw extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
return "Raw: ".$options['text'];
}
}
?>

View File

@ -0,0 +1,38 @@
<?php
class Text_Wiki_Render_Latex_Revise extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
if ($options['type'] == 'del_start') {
return '\sout{';
}
if ($options['type'] == 'del_end') {
return '}';
}
if ($options['type'] == 'ins_start') {
return '\underline{';
}
if ($options['type'] == 'ins_end') {
return '}';
}
}
}
?>

View File

@ -0,0 +1,44 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Smiley rule Latex renderer
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @copyright 2005 bertrand Gugger
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Smiley.php,v 1.2 2005/08/10 11:42:08 toggg Exp $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* Smiley rule Latex render class
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @copyright 2005 bertrand Gugger
* @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::Text_Wiki_Render()
*/
class Text_Wiki_Render_Latex_Smiley extends Text_Wiki_Render {
/**
* Renders a token into text matching the requested format.
* process the Smileys
*
* @access public
* @param array $options The "options" portion of the token (second element).
* @return string The text rendered from the token options.
*/
function token($options)
{
return $options['symbol'];
}
}
?>

View File

@ -0,0 +1,54 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Specialchar rule end renderer for Latex
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @copyright 2005 bertrand Gugger
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Specialchar.php,v 1.1 2005/08/15 11:10:36 toggg Exp $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders special characters in Latex.
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @copyright 2005 bertrand Gugger
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Latex_SpecialChar extends Text_Wiki_Render {
var $types = array('~bs~' => '\\\\',
'~hs~' => '\hspace{1em}',
'~amp~' => '\&',
'~ldq~' => '``',
'~rdq~' => "''",
'~lsq~' => '`',
'~rsq~' => "'",
'~c~' => '\copyright',
'~--~' => '---',
'" -- "' => '---',
'&quot; -- &quot;' => '---',
'~lt~' => '<',
'~gt~' => '>');
function token($options)
{
if (isset($this->types[$options['char']])) {
return $this->types[$options['char']];
} else {
return $options['char'];
}
}
}
?>

View File

@ -0,0 +1,30 @@
<?php
class Text_Wiki_Render_Latex_Strong extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
if ($options['type'] == 'start') {
return '\textbf{';
}
if ($options['type'] == 'end') {
return '}';
}
}
}
?>

View File

@ -0,0 +1,54 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Subscript rule end renderer for Latex
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @copyright 2005 bertrand Gugger
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Subscript.php,v 1.1 2005/08/15 10:09:04 toggg Exp $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders subscript text in Latex.
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @copyright 2005 bertrand Gugger
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Latex_Subscript extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
if ($options['type'] == 'start') {
return '_{';
}
if ($options['type'] == 'end') {
return '}';
}
}
}
?>

View File

@ -0,0 +1,31 @@
<?php
class Text_Wiki_Render_Latex_Superscript extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
return 'Superscript: NI';
if ($options['type'] == 'start') {
return '<sup>';
}
if ($options['type'] == 'end') {
return '</sup>';
}
}
}
?>

99
vendor/Text/Wiki/Render/Latex/Table.php vendored Normal file
View File

@ -0,0 +1,99 @@
<?php
class Text_Wiki_Render_Latex_Table extends Text_Wiki_Render {
var $cell_id = 0;
var $cell_count = 0;
var $is_spanning = false;
var $conf = array(
'css_table' => null,
'css_tr' => null,
'css_th' => null,
'css_td' => null
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
// make nice variable names (type, attr, span)
extract($options);
switch ($type)
{
case 'table_start':
$this->cell_count = $cols;
$tbl_start = '\begin{tabular}{|';
for ($a=0; $a < $this->cell_count; $a++) {
$tbl_start .= 'l|';
}
$tbl_start .= "}\n";
return $tbl_start;
case 'table_end':
return "\\hline\n\\end{tabular}\n";
case 'caption_start':
return "\\caption{";
case 'caption_end':
return "}\n";
case 'row_start':
$this->is_spanning = false;
$this->cell_id = 0;
return "\\hline\n";
case 'row_end':
return "\\\\\n";
case 'cell_start':
if ($span > 1) {
$col_spec = '';
if ($this->cell_id == 0) {
$col_spec = '|';
}
$col_spec .= 'l|';
$this->cell_id += $span;
$this->is_spanning = true;
return '\multicolumn{' . $span . '}{' . $col_spec . '}{';
}
$this->cell_id += 1;
return '';
case 'cell_end':
$out = '';
if ($this->is_spanning) {
$this->is_spanning = false;
$out = '}';
}
if ($this->cell_id != $this->cell_count) {
$out .= ' & ';
}
return $out;
default:
return '';
}
}
}
?>

View File

@ -0,0 +1,9 @@
<?php
class Text_Wiki_Render_Latex_Tighten extends Text_Wiki_Render {
function token()
{
return '';
}
}
?>

View File

@ -0,0 +1,54 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Titlebar rule end renderer for Latex
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @copyright 2005 bertrand Gugger
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Titlebar.php,v 1.1 2005/08/15 11:36:52 toggg Exp $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders a title bar in Latex.
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @copyright 2005 bertrand Gugger
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Latex_Titlebar extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
if ($options['type'] == 'start') {
return '\framebox[\textwidth]{\textbf{';
}
if ($options['type'] == 'end') {
return "}}\n";
}
}
}
?>

30
vendor/Text/Wiki/Render/Latex/Toc.php vendored Normal file
View File

@ -0,0 +1,30 @@
<?php
class Text_Wiki_Render_Latex_Toc extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
if($options['type'] == 'list_start') {
return "\\tableofcontents\n\n";
}
return '';
}
}
?>

30
vendor/Text/Wiki/Render/Latex/Tt.php vendored Normal file
View File

@ -0,0 +1,30 @@
<?php
class Text_Wiki_Render_Latex_tt extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
if ($options['type'] == 'start') {
return '\texttt{';
}
if ($options['type'] == 'end') {
return '}';
}
}
}
?>

View File

@ -0,0 +1,30 @@
<?php
class Text_Wiki_Render_Latex_Underline extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
if ($options['type'] == 'start') {
return '\underline{';
}
if ($options['type'] == 'end') {
return '}';
}
}
}
?>

35
vendor/Text/Wiki/Render/Latex/Url.php vendored Normal file
View File

@ -0,0 +1,35 @@
<?php
class Text_Wiki_Render_Latex_Url extends Text_Wiki_Render {
var $conf = array(
'target' => false,
'images' => true,
'img_ext' => array('jpg', 'jpeg', 'gif', 'png')
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
// create local variables from the options array (text,
// href, type)
extract($options);
return $text . '\footnote{' . $href . '}';
}
}
?>

View File

@ -0,0 +1,60 @@
<?php
class Text_Wiki_Render_Latex_Wikilink extends Text_Wiki_Render {
var $conf = array(
'pages' => array(),
'view_url' => 'http://example.com/index.php?page=%s',
'new_url' => 'http://example.com/new.php?page=%s',
'new_text' => '?'
);
/**
*
* Renders a token into XHTML.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
// make nice variable names (page, anchor, text)
extract($options);
// are we checking page existence?
$list = $this->getConf('pages');
if (is_array($list)) {
// yes, check against the page list
$exists = in_array($page, $list);
} else {
// no, assume it exists
$exists = true;
}
// convert *after* checking against page names so as not to mess
// up what the user typed and what we're checking.
$page = $this->textEncode($page);
$anchor = $this->textEncode($anchor);
$text = $this->textEncode($text);
$href = $this->getConf('view_url');
if (strpos($href, '%s') === false) {
// use the old form (page-at-end)
$href = $href . $page . $anchor;
} else {
// use the new form (sprintf format string)
$href = sprintf($href, $page . $anchor);
}
// get the CSS class and generate output
$css = $this->formatConf(' class="%s"', 'css');
return $text . '\footnote{' . $href . '}';
}
}
?>

16
vendor/Text/Wiki/Render/Plain.php vendored Normal file
View File

@ -0,0 +1,16 @@
<?php
class Text_Wiki_Render_Plain extends Text_Wiki_Render {
function pre()
{
return;
}
function post()
{
return;
}
}
?>

View File

@ -0,0 +1,23 @@
<?php
/**
*
* This class renders an anchor target name in XHTML.
*
* @author Manuel Holtgrewe <purestorm at ggnore dot net>
*
* @author Paul M. Jones <pmjones at ciaweb dot net>
*
* @package Text_Wiki
*
*/
class Text_Wiki_Render_Plain_Anchor extends Text_Wiki_Render {
function token($options)
{
return $options['name'];
}
}
?>

View File

@ -0,0 +1,39 @@
<?php
class Text_Wiki_Render_Plain_Blockquote extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
$type = $options['type'];
$level = $options['level'];
// set up indenting so that the results look nice; we do this
// in two steps to avoid str_pad mathematics. ;-)
$pad = str_pad('', $level + 1, "\t");
$pad = str_replace("\t", ' ', $pad);
// starting
if ($type == 'start') {
return "\n$pad";
}
// ending
if ($type == 'end') {
return "\n$pad";
}
}
}
?>

Some files were not shown because too many files have changed in this diff Show More