Skip to content

Commit

Permalink
Fixed Headers, Added Preformatted rule (used Brian's syntax for this …
Browse files Browse the repository at this point in the history
…one) and fixed resulting Bug #8448

git-svn-id: https://svn.php.net/repository/pear/packages/Text_Wiki/trunk@218241 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
Moritz Venn committed Aug 15, 2006
1 parent f123996 commit c068c26
Show file tree
Hide file tree
Showing 13 changed files with 372 additions and 461 deletions.
2 changes: 1 addition & 1 deletion Text/Wiki/Mediawiki.php
Expand Up @@ -35,12 +35,12 @@ class Text_Wiki_Mediawiki extends Text_Wiki {
var $rules = array(
'Prefilter',
'Delimiter',
'Preformatted',
'Code',
// 'Plugin',
// 'Function',
// 'Html',
'Raw',
// 'Preformatted',
// 'Include',
// 'Embed',
// 'Page',
Expand Down
67 changes: 28 additions & 39 deletions Text/Wiki/Parse/Mediawiki/Break.php
@@ -1,70 +1,59 @@
<?php

// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
*
* Parses for explicit line breaks.
*
* @category Text
*
* @package Text_Wiki
*
* @author Brian J. Sipos <bjs5075@rit.edu>
*
* @license LGPL
*
*/
* Mediawiki: Parses for explicit line breaks.
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Brian J. Sipos <bjs5075@rit.edu>
* @author Moritz Venn <ritzmo@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id$
* @link http://pear.php.net/package/Text_Wiki
*/

/**
*
* Parses for explicit line breaks.
*
* This class implements a Text_Wiki_Parse to mark explicit line breaks in the
* source text.
*
* @category Text
*
* @package Text_Wiki
*
* @author Brian J. Sipos <bjs5075@rit.edu>
*
*/

* Parses for explicit line breaks.
*
* This class implements a Text_Wiki_Parse to mark explicit line breaks in the
* source text.
*
* @category Text
* @package Text_Wiki
* @author Brian J. Sipos <bjs5075@rit.edu>
* @author Moritz Venn <ritzmo@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
* @see Text_Wiki_Parse::Text_Wiki_Parse()
*/
class Text_Wiki_Parse_Break extends Text_Wiki_Parse {


/**
*
* The regular expression used to parse the source text and find
* matches conforming to this rule. Used by the parse() method.
*
* @access public
*
* @var string
*
* @see parse()
*
*/

var $regex = '/<br\ *\/?>/';


/**
*
* 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);
}
}

?>
?>
74 changes: 31 additions & 43 deletions Text/Wiki/Parse/Mediawiki/Code.php
@@ -1,72 +1,60 @@
<?php

// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
*
* 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$
*
*/
* Mediawiki: Parses for text marked as a code example block.
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @author Moritz Venn <ritzmo@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id$
* @link http://pear.php.net/package/Text_Wiki
*/

/**
*
* Parses for text marked as a code example block.
*
* This class implements a Text_Wiki_Parse to find sections marked as code
* examples. Blocks are marked as the string <code> on a line by itself,
* followed by the inline code example, and terminated with the string
* </code> on a line by itself. The code example is run through the
* native PHP highlight_string() function to colorize it, then surrounded
* with <pre>...</pre> tags when rendered as XHTML.
*
* @category Text
*
* @package Text_Wiki
*
* @author Paul M. Jones <pmjones@php.net>
*
*/

* 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>
* @author Moritz Venn <ritzmo@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
* @see Text_Wiki_Parse::Text_Wiki_Parse()
*/
class Text_Wiki_Parse_Code extends Text_Wiki_Parse {


/**
*
* The regular expression used to find source text matching this
* rule.
*
* @access public
*
* @var string
*
*/

/* var $regex = '/^(\<code( .+)?\>)\n(.+)\n(\<\/code\>)(\s|$)/Umsi';*/
var $regex = ';^<code(\s[^>]*)?>\n?((?:(?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?
Expand Down
16 changes: 0 additions & 16 deletions Text/Wiki/Parse/Mediawiki/Deflist.php
@@ -1,7 +1,6 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
*
* Mediawiki: Parse for definition lists.
*
* @category Text
Expand All @@ -15,7 +14,6 @@
*/

/**
*
* Parses for definition lists.
*
* This class implements a Text_Wiki_Parse to find source text marked as a
Expand All @@ -33,29 +31,20 @@
* @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
Expand All @@ -64,20 +53,15 @@ class Text_Wiki_Parse_Deflist extends Text_Wiki_Parse {
* '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)
{
Expand Down
77 changes: 31 additions & 46 deletions Text/Wiki/Parse/Mediawiki/Heading.php
@@ -1,79 +1,64 @@
<?php

// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
*
* 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$
*
*/
* Mediawiki: Parses for heading text.
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @author Moritz Venn <ritzmo@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id$
* @link http://pear.php.net/package/Text_Wiki
*/

/**
*
* 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>
*
*/

* 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 Justin Patrin <papercrane@reversefold.com>
* @author Paul M. Jones <pmjones@php.net>
* @author Moritz Venn <ritzmo@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
* @see Text_Wiki_Parse::Text_Wiki_Parse()
*/
class Text_Wiki_Parse_Heading extends Text_Wiki_Parse {


/**
*
* The regular expression used to parse the source text and find
* matches conforming to this rule. Used by the parse() method.
*
* @access public
*
* @var string
*
* @see parse()
*
*/

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
Expand Down

0 comments on commit c068c26

Please sign in to comment.