[pmwiki-users] Markup/php question

Patrick R. Michaud pmichaud at pobox.com
Mon Jan 31 08:23:44 CST 2005


On Mon, Jan 31, 2005 at 10:27:43AM +0100, Tom Cato Amundsen wrote:
> Hello. I'm writing some new markup to be used on my wiki. I know python
> very well, but I'm having a little trouble with php:
> 
> function xlink_func($url, $text) { 
>     return substr($url, 0, 3);
> }
> markup('xlink', 'inline', '/\\(:xlink ([^\s]*)(\s(.*?))?:\\)/',
>  xlink_func('$1','$2'));
> 
> The substr function does nothing, it just returns the whole $url.
> If I write a string, "abcde" instead of $url in xlink_func, then
> substr does what I expect.
> 
> What am I doing wrong here?

I'm guessing that you want xlink_func() to be called when someone uses
the (:xlink ...:) markup.  As written above, it's being called when
the markup is being defined.  You probably want:

  Markup('xlink', 'inline', 
    '/\\(:xlink ([^\s]*)(\s(.*?))?:\\)/e',
    "xlink_func('$1','$2')");

Note the "/e" at the end of the search pattern, and the replacement
pattern is placed inside of quotes, since it's something to be executed
when the pattern is matched (as opposed to being executed immediately).

Pm



More information about the pmwiki-users mailing list