[Pmwiki-users] PmWiki 2 custom markup, draft 1
Patrick R. Michaud
pmichaud
Mon Sep 6 19:37:31 CDT 2004
On Tue, Sep 07, 2004 at 10:11:59AM +1200, John Rankin wrote:
> On Tuesday, 7 September 2004 3:29 AM, Patrick R. Michaud <pmichaud at pobox.com> wrote:
> >On Mon, Sep 06, 2004 at 01:02:32PM +1200, John Rankin wrote:
> >Using a pattern match to process the entire text may not be the
> >most efficient mechanism in the world, so PmWiki 2 offers an
> >alternative to using preg_replace for markup translations.
> >[...]
> ? So instead of writing
> else
> Markup('breakpage','directives','/\\[:breakpage:\\]/','');
> you could have written
> else
> Markup('breakpage','directives','[:breakpage:]','');
No, actually this last one wouldn't work. When using the non-pattern
match version of Markup, the *entire text* being processed at that point
gets replaced by the return value of the executed string--not just the
portion that matched the third parameter. Thus the second Markup()
call above would cause any line containing [:breakpage:] to become an
empty string. (While this may seem inconsistent, the behavior is
set this way to support the split operation.)
To use the non-pattern-match form to convert [:breakpage:] to an
empty string, you'd need to do something like
Markup('breakpage','directives','[:breakpage:]',
"return str_replace('[:breakpage:]','',\$x);");
Pm
More information about the pmwiki-users
mailing list