2 rcs_id('$Id: InlineParser.php,v 1.56 2004-06-19 10:21:32 rurban Exp $');
3 /* Copyright (C) 2002 Geoffrey T. Dairiki <dairiki@dairiki.org>
4 * Copyright (C) 2004 Reini Urban
6 * This file is part of PhpWiki.
8 * PhpWiki is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * PhpWiki is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with PhpWiki; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * This is the code which deals with the inline part of the (new-style)
27 * @author Geoffrey T. Dairiki
33 * This is the character used in wiki markup to escape characters with
36 define('ESCAPE_CHAR', '~');
38 require_once(dirname(__FILE__).'/HtmlElement.php');
39 require_once('lib/CachedMarkup.php');
40 require_once(dirname(__FILE__).'/stdlib.php');
43 function WikiEscape($text) {
44 return str_replace('#', ESCAPE_CHAR . '#', $text);
47 function UnWikiEscape($text) {
48 return preg_replace('/' . ESCAPE_CHAR . '(.)/', '\1', $text);
52 * Return type from RegexpSet::match and RegexpSet::nextMatch.
56 class RegexpSet_match {
58 * The text leading up the the next match.
66 * The text following the matched text.
70 * Index of the regular expression which matched.
76 * A set of regular expressions.
78 * This class is probably only useful for InlineTransformer.
84 * @param array $regexps A list of regular expressions. The
85 * regular expressions should not include any sub-pattern groups
86 * "(...)". (Anonymous groups, like "(?:...)", as well as
87 * look-ahead and look-behind assertions are okay.)
89 function RegexpSet ($regexps) {
91 $this->_regexps = array_unique($regexps);
92 if (!defined('_INLINE_OPTIMIZATION')) define('_INLINE_OPTIMIZATION',0);
96 * Search text for the next matching regexp from the Regexp Set.
98 * @param string $text The text to search.
100 * @return RegexpSet_match A RegexpSet_match object, or false if no match.
102 function match ($text) {
103 return $this->_match($text, $this->_regexps, '*?');
107 * Search for next matching regexp.
109 * Here, 'next' has two meanings:
111 * Match the next regexp(s) in the set, at the same position as the last match.
113 * If that fails, match the whole RegexpSet, starting after the position of the
116 * @param string $text Text to search.
118 * @param RegexpSet_match $prevMatch A RegexpSet_match object.
119 * $prevMatch should be a match object obtained by a previous
120 * match upon the same value of $text.
122 * @return RegexpSet_match A RegexpSet_match object, or false if no match.
124 function nextMatch ($text, $prevMatch) {
125 // Try to find match at same position.
126 $pos = strlen($prevMatch->prematch);
127 $regexps = array_slice($this->_regexps, $prevMatch->regexp_ind + 1);
129 $repeat = sprintf('{%d}', $pos);
130 if ( ($match = $this->_match($text, $regexps, $repeat)) ) {
131 $match->regexp_ind += $prevMatch->regexp_ind + 1;
137 // Failed. Look for match after current position.
138 $repeat = sprintf('{%d,}?', $pos + 1);
139 return $this->_match($text, $this->_regexps, $repeat);
142 // Syntax: http://www.pcre.org/pcre.txt
143 // x - EXTENDED, ignore whitespace
147 function _match ($text, $regexps, $repeat) {
148 // If one of the regexps is an empty string, php will crash here:
149 // sf.net: Fatal error: Allowed memory size of 8388608 bytes exhausted
150 // (tried to allocate 634 bytes)
151 if (_INLINE_OPTIMIZATION) { // disabled, wrong
152 // So we try to minize memory usage, by looping explicitly,
153 // and storing only those regexp which actually match.
154 // There may be more than one, so we have to find the longest,
155 // and match inside until the shortest is empty.
156 $matched = array(); $matched_ind = array();
157 for ($i=0; $i<count($regexps); $i++) {
158 if (!trim($regexps[$i])) {
159 trigger_error("empty regexp $i",E_USER_WARNING);
162 $pat= "/ ( . $repeat ) ( " . $regexps[$i] . " ) /x";
163 if (preg_match($pat, $text, $_m)) {
164 $m = $_m; // FIXME: prematch, postmatch is wrong
165 $matched[] = $regexps[$i];
170 // To overcome ANCHORED:
171 // We could sort by longest match and iterate over these.
172 if (empty($matched)) return false;
174 $match = new RegexpSet_match;
176 // Optimization: if the matches are only "$" and another, then omit "$"
177 if (! _INLINE_OPTIMIZATION or count($matched) > 2) {
178 // We could do much better, if we would know the matching markup for the
179 // longest regexp match:
180 $hugepat= "/ ( . $repeat ) ( (" . join(')|(', $regexps) . ") ) /Asx";
181 // Proposed premature optimization 1:
182 //$hugepat= "/ ( . $repeat ) ( (" . join(')|(', array_values($matched)) . ") ) /Asx";
184 '/ ( . *? ) ( ($)|(~(?: [[:alnum:]]+ | .))|(&#\d{2,5};)|(\#? \[ .*? [^]\s] .*? \])|((?<![[:alnum:]]) (?:http|https|mailto|ftp|news|nntp|ssh|gopher) : [^\s<>"']+ (?<![ ,.?; \] \) ]))|((?<! [[:alnum:]])(?:AbbeNormal|AcadWiki|Acronym|Advogato|AIWiki|ALife|AndStuff|Annotation|AnnotationWiki|AwarenessWiki|BcWireless|BenefitsWiki|BridgesWiki|bsdWiki|C2find|Cache|Category|CLiki|CmWiki|CreationMatters|DejaNews|DeWikiPedia|Dict|Dictionary|DiveIntoOsx|DocBook|DolphinWiki|DseWiki|EfnetCeeWiki|EfnetCppWiki|EfnetPythonWiki|EfnetXmlWiki|EljWiki|EmacsWiki|FinalEmpire|Foldoc|FoxWiki|FreeBSDman|FreeNetworks|FreshMeat|Google|GoogleGroups|GreenCheese|HammondWiki|Haribeau|IAWiki|MRQE|IMDB|ISBN|JargonFile|JiniWiki|JspWiki|KmWiki|KnowHow|LanifexWiki|LegoWiki|LinuxWiki|LugKR|MathSongsWiki|MbTest|MeatBall|MetaWiki|MetaWikiPedia|MoinMoin|MuWeb|NetVillage|OpenWiki|OrgPatterns|PangalacticOrg|PersonalTelco|php-function|php-lookup|PhpWiki|PhpWikiCvs|PhpWikiDemo|Pikie|PolitizenWiki|PPR|PurlNet|PythonInfo|PythonWiki|PyWiki|RFC|SeaPig|SeattleWireless|SenseisLibrary|Shakti|SourceForge|Squeak|StrikiWiki|SVGWiki|Tavi|Thesaurus|Thinki|TmNet|TMwiki|TWiki|TwistedWiki|Unreal|UseMod|VisualWorks|WebDevWikiNL|WebSeitzWiki|Why|Wiki|WikiPedia|WikiWorld|YpsiEyeball|ZWiki|Upload): \S+ (?<![ ,.?;! \] \) " \' ]))|( (?<![[:alnum:]])(?:[[:upper:]][[:lower:]]+){2,}(?![[:alnum:]]))|((?: (?<! %) %%% (?! %) | <(?:br|BR)> ))|(''|__)|((?:(?<= \s|^|[-"'\/:]) (?: _ (?! _)|\* (?! \*)|= (?! =))|(?<= =) (?: _ (?! _)|\* (?! \*)) (?! =)|(?<= _) (?: \* (?! \*)|= (?! =)) (?! _)|(?<= \*) (?: _ (?! _)|= (?! =)) (?! \*)|(?<= { ) (?: _ (?! _)|\* (?! \*)|= (?! =)) (?! } )|(?<= < ) (?: _ (?! _)|\* (?! \*)|= (?! =)) (?! > )|(?<= \( ) (?: _ (?! _)|\* (?! \*)|= (?! =)) (?! \) ))(?= \S))|(<(?: b|big|i|small|tt|em|strong|cite|code|dfn|kbd|samp|var|sup|sub )>)|(<(?: abbr|acronym )(?: \stitle=[^>]*)?>)|(<\?plugin(?:-form)?\s[^\n]+?\?>) ) /Asx'
186 if (! preg_match($hugepat, $text, $m)) {
189 // Proposed premature optimization 1:
190 //$match->regexp_ind = $matched_ind[count($m) - 4];
191 $match->regexp_ind = count($m) - 4;
193 $match->regexp_ind = $regexp_ind;
196 $match->postmatch = substr($text, strlen($m[0]));
197 $match->prematch = $m[1];
198 $match->match = $m[2];
203 var_dump($regexps); var_dump($matched); var_dump($matched_inc);
204 PrintXML(HTML::dl(HTML::dt("input"),
205 HTML::dd(HTML::pre($text)),
207 HTML::dd(HTML::pre($match->regexp_ind, ":", $regexps[$match->regexp_ind])),
208 HTML::dt("prematch"),
209 HTML::dd(HTML::pre($match->prematch)),
211 HTML::dd(HTML::pre($match->match)),
212 HTML::dt("postmatch"),
213 HTML::dd(HTML::pre($match->postmatch))
224 * A simple markup rule (i.e. terminal token).
226 * These are defined by a regexp.
228 * When a match is found for the regexp, the matching text is replaced.
229 * The replacement content is obtained by calling the SimpleMarkup::markup method.
237 * @return string Regexp which matches this token.
239 function getMatchRegexp () {
240 return $this->_match_regexp;
243 /** Markup matching text.
245 * @param string $match The text which matched the regexp
246 * (obtained from getMatchRegexp).
248 * @return mixed The expansion of the matched text.
250 function markup ($match /*, $body */) {
251 trigger_error("pure virtual", E_USER_ERROR);
256 * A balanced markup rule.
258 * These are defined by a start regexp, and an end regexp.
264 /** Get the starting regexp for this rule.
266 * @return string The starting regexp.
268 function getStartRegexp () {
269 return $this->_start_regexp;
272 /** Get the ending regexp for this rule.
274 * @param string $match The text which matched the starting regexp.
276 * @return string The ending regexp.
278 function getEndRegexp ($match) {
279 return $this->_end_regexp;
282 /** Get expansion for matching input.
284 * @param string $match The text which matched the starting regexp.
286 * @param mixed $body Transformed text found between the starting
287 * and ending regexps.
289 * @return mixed The expansion of the matched text.
291 function markup ($match, $body) {
292 trigger_error("pure virtual", E_USER_ERROR);
296 class Markup_escape extends SimpleMarkup
298 function getMatchRegexp () {
299 return ESCAPE_CHAR . '(?: [[:alnum:]]+ | .)';
302 function markup ($match) {
303 assert(strlen($match) >= 2);
304 return substr($match, 1);
309 * [image.jpg size=50% border=5], [image.jpg size=50x30]
310 * Support for the following attributes: see stdlib.php:LinkImage()
311 * size=<precent>%, size=<width>x<height>
312 * border=n, align=\w+, hspace=n, vspace=n
314 function isImageLink($link) {
315 if (!$link) return false;
316 return preg_match("/\\.(" . INLINE_IMAGES . ")$/i", $link)
317 or preg_match("/\\.(" . INLINE_IMAGES . ")\s+(size|border|align|hspace|vspace)=/i", $link);
320 function LinkBracketLink($bracketlink) {
322 // $bracketlink will start and end with brackets; in between will
323 // be either a page name, a URL or both separated by a pipe.
325 // strip brackets and leading space
326 preg_match('/(\#?) \[\s* (?: (.*?) \s* (?<!' . ESCAPE_CHAR . ')(\|) )? \s* (.+?) \s*\]/x',
327 $bracketlink, $matches);
328 if (count($matches) < 4) {
329 trigger_error(_("Invalid [] syntax ignored").": ".$bracketlink, E_USER_NOTICE);
330 return new Cached_Link;
332 list (, $hash, $label, $bar, $rawlink) = $matches;
334 $label = UnWikiEscape($label);
336 * Check if the user has typed a explicit URL. This solves the
337 * problem where the URLs have a ~ character, which would be stripped away.
338 * "[http:/server/~name/]" will work as expected
339 * "http:/server/~name/" will NOT work as expected, will remove the ~
341 if (strstr($rawlink, "http://") or strstr($rawlink, "https://"))
344 $link = UnWikiEscape($rawlink);
347 // if label looks like a url to an image, we want an image link.
348 if (isImageLink($label)) {
350 $intermap = getInterwikiMap();
351 if (preg_match("/^" . $intermap->getRegexp() . ":/", $label)) {
352 $imgurl = $intermap->link($label);
353 $imgurl = $imgurl->getAttr('href');
354 } elseif (! preg_match("#^(" . ALLOWED_PROTOCOLS . "):#", $imgurl)) {
355 // local theme linkname like 'images/next.gif'.
357 $imgurl = $WikiTheme->getImageURL($imgurl);
359 $label = LinkImage($imgurl, $link);
363 // It's an anchor, not a link...
364 $id = MangleXmlIdentifier($link);
365 return HTML::a(array('name' => $id, 'id' => $id),
366 $bar ? $label : $link);
369 if (preg_match("#^(" . ALLOWED_PROTOCOLS . "):#", $link)) {
370 // if it's an image, embed it; otherwise, it's a regular link
371 if (isImageLink($link))
372 return LinkImage($link, $label);
374 return new Cached_ExternalLink($link, $label);
376 elseif (preg_match("/^phpwiki:/", $link))
377 return new Cached_PhpwikiURL($link, $label);
379 * Inline images in Interwiki urls's:
380 * [File:my_image.gif] inlines the image,
381 * File:my_image.gif shows a plain inter-wiki link,
382 * [what a pic|File:my_image.gif] shows a named inter-wiki link to the gif
383 * [File:my_image.gif|what a pic] shows a inlimed image linked to the page "what a pic"
385 elseif (strstr($link,':') and
386 ($intermap = getInterwikiMap()) and
387 preg_match("/^" . $intermap->getRegexp() . ":/", $link)) {
388 if (empty($label) && isImageLink($link)) {
389 // if without label => inlined image [File:xx.gif]
390 $imgurl = $intermap->link($link);
391 return LinkImage($imgurl->getAttr('href'), $label);
393 return new Cached_InterwikiLink($link, $label);
395 // Split anchor off end of pagename.
396 if (preg_match('/\A(.*)(?<!'.ESCAPE_CHAR.')#(.*?)\Z/', $rawlink, $m)) {
397 list(,$rawlink,$anchor) = $m;
398 $pagename = UnWikiEscape($rawlink);
399 $anchor = UnWikiEscape($anchor);
407 return new Cached_WikiLink($pagename, $label, $anchor);
411 class Markup_bracketlink extends SimpleMarkup
413 var $_match_regexp = "\\#? \\[ .*? [^]\\s] .*? \\]";
415 function markup ($match) {
416 $link = LinkBracketLink($match);
417 assert($link->isInlineElement());
422 class Markup_url extends SimpleMarkup
424 function getMatchRegexp () {
425 return "(?<![[:alnum:]]) (?:" . ALLOWED_PROTOCOLS . ") : [^\s<>\"']+ (?<![ ,.?; \] \) ])";
428 function markup ($match) {
429 return new Cached_ExternalLink(UnWikiEscape($match));
434 class Markup_interwiki extends SimpleMarkup
436 function getMatchRegexp () {
438 $map = getInterwikiMap();
439 return "(?<! [[:alnum:]])" . $map->getRegexp(). ": \S+ (?<![ ,.?;! \] \) \" \' ])";
442 function markup ($match) {
443 //$map = getInterwikiMap();
444 return new Cached_InterwikiLink(UnWikiEscape($match));
448 class Markup_wikiword extends SimpleMarkup
450 function getMatchRegexp () {
451 global $WikiNameRegexp;
452 if (!trim($WikiNameRegexp)) return " " . WIKI_NAME_REGEXP;
453 return " $WikiNameRegexp";
456 function markup ($match) {
457 if (!$match) return false;
458 if ($this->_isWikiUserPage($match))
459 return new Cached_UserLink($match); //$this->_UserLink($match);
461 return new Cached_WikiLink($match);
464 // FIXME: there's probably a more useful place to put these two functions
465 function _isWikiUserPage ($page) {
467 $dbi = $request->getDbh();
468 $page_handle = $dbi->getPage($page);
469 if ($page_handle and $page_handle->get('pref'))
475 function _UserLink($PageName) {
476 $link = HTML::a(array('href' => $PageName));
477 $link->pushContent(PossiblyGlueIconToText('wikiuser', $PageName));
478 $link->setAttr('class', 'wikiuser');
483 class Markup_linebreak extends SimpleMarkup
485 //var $_match_regexp = "(?: (?<! %) %%% (?! %) | <(?:br|BR)> | <(?:br|BR) \/> )";
486 var $_match_regexp = "(?: (?<! %) %%% (?! %) | <(?:br|BR)> )";
488 function markup ($match) {
493 class Markup_old_emphasis extends BalancedMarkup
495 var $_start_regexp = "''|__";
497 function getEndRegexp ($match) {
501 function markup ($match, $body) {
502 $tag = $match == "''" ? 'em' : 'strong';
503 return new HtmlElement($tag, $body);
507 class Markup_nestled_emphasis extends BalancedMarkup
509 function getStartRegexp() {
510 static $start_regexp = false;
512 if (!$start_regexp) {
513 // The three possible delimiters
514 // (none of which can be followed by itself.)
519 $any = "(?: ${i}|${b}|${tt})"; // any of the three.
521 // Any of [_*=] is okay if preceded by space or one of [-"'/:]
522 $start[] = "(?<= \\s|^|[-\"'\\/:]) ${any}";
524 // _ or * is okay after = as long as not immediately followed by =
525 $start[] = "(?<= =) (?: ${i}|${b}) (?! =)";
527 $start[] = "(?<= _) (?: ${b}|${tt}) (?! _)";
528 $start[] = "(?<= \\*) (?: ${i}|${tt}) (?! \\*)";
531 // any delimiter okay after an opening brace ( [{<(] )
532 // as long as it's not immediately followed by the matching closing
534 $start[] = "(?<= { ) ${any} (?! } )";
535 $start[] = "(?<= < ) ${any} (?! > )";
536 $start[] = "(?<= \\( ) ${any} (?! \\) )";
538 $start = "(?:" . join('|', $start) . ")";
540 // Any of the above must be immediately followed by non-whitespace.
541 $start_regexp = $start . "(?= \S)";
544 return $start_regexp;
547 function getEndRegexp ($match) {
548 $chr = preg_quote($match);
549 return "(?<= \S | ^ ) (?<! $chr) $chr (?! $chr) (?= \s | [-)}>\"'\\/:.,;!? _*=] | $)";
552 function markup ($match, $body) {
554 case '*': return new HtmlElement('b', $body);
555 case '=': return new HtmlElement('tt', $body);
556 case '_': return new HtmlElement('i', $body);
561 class Markup_html_emphasis extends BalancedMarkup
564 "<(?: b|big|i|small|tt|em|strong|cite|code|dfn|kbd|samp|var|sup|sub )>";
566 function getEndRegexp ($match) {
567 return "<\\/" . substr($match, 1);
570 function markup ($match, $body) {
571 $tag = substr($match, 1, -1);
572 return new HtmlElement($tag, $body);
576 class Markup_html_abbr extends BalancedMarkup
578 //rurban: abbr|acronym need an optional title tag.
580 var $_start_regexp = "<(?: abbr|acronym )(?: \stitle=[^>]*)?>";
582 function getEndRegexp ($match) {
583 if (substr($match,1,4) == 'abbr')
587 return "<\\/" . $tag . '>';
590 function markup ($match, $body) {
591 if (substr($match,1,4) == 'abbr')
595 $rest = substr($match,1+strlen($tag),-1);
597 list($key,$val) = explode("=",$rest);
598 $args = array($key => $val);
599 } else $args = array();
600 return new HtmlElement($tag, $args, $body);
604 // Special version for single-line plugins formatting,
605 // like: '<small>< ?plugin PopularNearby ? ></small>'
606 class Markup_plugin extends SimpleMarkup
608 var $_match_regexp = '<\?plugin(?:-form)?\s[^\n]+?\?>';
610 function markup ($match) {
611 //$xml = new Cached_PluginInvocation($match);
612 //$xml->setTightness(true,true);
613 return new Cached_PluginInvocation($match);
618 // TODO: "..." => "…" browser specific display (not cached?)
619 // TODO: "--" => "&emdash;" browser specific display (not cached?)
621 // FIXME: escape '&' somehow.
622 class Markup_isonumchars extends SimpleMarkup {
623 // var $_match_regexp = '<\?plugin(?:-form)?\s[^\n]+?\? >';
624 // no hexnums yet, like ¤ <=> ¤
625 var $_match_regexp = '\&\#\d{2,5};';
627 function markup ($match) {
632 // FIXME: escape '&' somehow.
633 class Markup_isohexchars extends SimpleMarkup {
634 var $_match_regexp = '\&\#x[0-9a-fA-F]{2,4};';
636 function markup ($match) {
641 // FIXME: Do away with magic phpwiki forms. (Maybe phpwiki: links too?)
642 // FIXME: Do away with plugin-links. They seem not to be used.
646 class InlineTransformer
648 var $_regexps = array();
649 var $_markup = array();
651 function InlineTransformer ($markup_types = false) {
653 $markup_types = array('escape', /*'isonumchars', 'isohexchars',*/
654 'bracketlink', 'url',
655 'interwiki', 'wikiword', 'linebreak',
656 'old_emphasis', 'nestled_emphasis',
657 'html_emphasis', 'html_abbr', 'plugin');
658 foreach ($markup_types as $mtype) {
659 $class = "Markup_$mtype";
660 $this->_addMarkup(new $class);
664 function _addMarkup ($markup) {
665 if (isa($markup, 'SimpleMarkup'))
666 $regexp = $markup->getMatchRegexp();
668 $regexp = $markup->getStartRegexp();
670 assert(!isset($this->_markup[$regexp]));
671 $this->_regexps[] = $regexp;
672 $this->_markup[] = $markup;
675 function parse (&$text, $end_regexps = array('$')) {
676 $regexps = $this->_regexps;
678 // $end_re takes precedence: "favor reduce over shift"
679 array_unshift($regexps, $end_regexps[0]);
680 //array_push($regexps, $end_regexps[0]);
681 $regexps = new RegexpSet($regexps);
684 $output = new XmlContent;
686 $match = $regexps->match($input);
689 if ($match->regexp_ind == 0) {
690 // No start pattern found before end pattern.
692 if (isset($markup) and is_object($markup) and isa($markup,'Markup_plugin')) {
693 $current =& $output->_content[count($output->_content)-1];
694 $current->setTightness(true,true);
696 $output->pushContent($match->prematch);
697 $text = $match->postmatch;
701 $markup = $this->_markup[$match->regexp_ind - 1];
702 $body = $this->_parse_markup_body($markup, $match->match, $match->postmatch, $end_regexps);
704 // Couldn't match balanced expression.
705 // Ignore and look for next matching start regexp.
706 $match = $regexps->nextMatch($input, $match);
710 // Matched markup. Eat input, push output.
711 // FIXME: combine adjacent strings.
712 $current = $markup->markup($match->match, $body);
713 $input = $match->postmatch;
714 if (isset($markup) and is_object($markup) and isa($markup,'Markup_plugin')) {
715 $current->setTightness(true,true);
717 $output->pushContent($match->prematch, $current);
719 $match = $regexps->match($input);
722 // No pattern matched, not even the end pattern.
727 function _parse_markup_body ($markup, $match, &$text, $end_regexps) {
728 if (isa($markup, 'SimpleMarkup'))
729 return true; // Done. SimpleMarkup is simple.
731 if (!is_object($markup)) return false; // Some error: Should assert
732 array_unshift($end_regexps, $markup->getEndRegexp($match));
734 // Optimization: if no end pattern in text, we know the
735 // parse will fail. This is an important optimization,
736 // e.g. when text is "*lots *of *start *delims *with
737 // *no *matching *end *delims".
738 $ends_pat = "/(?:" . join(").*(?:", $end_regexps) . ")/xs";
739 if (!preg_match($ends_pat, $text))
741 return $this->parse($text, $end_regexps);
745 class LinkTransformer extends InlineTransformer
747 function LinkTransformer () {
748 $this->InlineTransformer(array('escape', 'bracketlink', 'url',
749 'interwiki', 'wikiword'));
753 function TransformInline($text, $markup = 2.0, $basepage=false) {
757 $trfm = new InlineTransformer;
761 $text = ConvertOldMarkup($text, 'inline');
765 return new CacheableMarkup($trfm->parse($text), $basepage);
767 return $trfm->parse($text);
770 function TransformLinks($text, $markup = 2.0, $basepage = false) {
774 $trfm = new LinkTransformer;
778 $text = ConvertOldMarkup($text, 'links');
782 return new CacheableMarkup($trfm->parse($text), $basepage);
784 return $trfm->parse($text);
787 // (c-file-style: "gnu")
792 // c-hanging-comment-ender-p: nil
793 // indent-tabs-mode: nil