Source for file Wikilink.php
Documentation is available at Wikilink.php
* Parse for links to wiki pages.
* Wiki page names are typically in StudlyCapsStyle made of
* 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.
* $Id: Wikilink.php,v 1.2 2004/09/25 19:05:13 pmjones Exp $
* @author Paul M. Jones <pmjones@ciaweb.net>
* We override the Text_Wiki_Parse constructor so we can
* explicitly comment each part of the $regex property.
* @param object &$obj The calling "parent" Text_Wiki object.
// allows numbers as "lowercase letters" in the regex
"(!?" . // START WikiPage pattern (1)
"[A-Za-z0-9]*" . // 0+ alpha or digit
"[a-z0-9]+" . // 1+ lower or digit
"[A-Za-z0-9]*" . // 0+ or more alpha or digit
")" . // END WikiPage pattern (/1)
"((\#" . // START Anchor pattern (2)(3)
"(" . // start sub pattern (4)
"[-A-Za-z0-9_:.]*" . // 0+ dash, alpha, digit, underscore, colon, dot
"[-A-Za-z0-9_]" . // 1 dash, alpha, digit, or underscore
")?)?)"; // end subpatterns (/4)(/3)(/2)
* First parses for described links, then for standalone links.
$tmp_regex = '/\[' . $this->regex . ' (.+?)\]/';
array (&$this, 'processDescr'),
$tmp_regex = '/(^|[^A-Za-z0-9\-_])' . $this->regex . '/';
array (&$this, 'process'),
* Generate a replacement for described links.
* @param array &$matches The array of matches from parse().
* @return A delimited token to be used as a placeholder in
* the source text, plus any text priot to the match.
// create and return the replacement token and preceding text
return $this->wiki->addToken ($this->rule, $options); // . $matches[7];
* Generate a replacement for standalone links.
* @param array &$matches The array of matches from parse().
* @return A delimited token to be used as a placeholder in
* the source text, plus any text prior to the match.
// 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 ];
'text' => $matches[2 ] . $matches[3 ],
// create and return the replacement token and preceding text
return $matches[1 ] . $this->wiki->addToken ($this->rule, $options);
Documentation generated on Mon, 11 Mar 2019 14:22:35 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|