[pmwiki-devel] having a single callback function for markups in php 5.5x compat issues
Petko Yotov
5ko at 5ko.fr
Sat Apr 2 14:12:40 CDT 2016
On 2016-04-02 10:41, V.Krishn wrote:
> (:test param1 param2 param3:)
> CODE:
> Markup('test','directives','/\\(:test\\s(.*?):\\)/',"CallbackTest");
...
> Wondering if were possible to produce:
> Array
> (
> [0] => (:test param1 param2 param3:)
> [1] => test param1 param2 param3
> [name] => test
> )
> One benefit is I can write a single CallBack<fn> for all markups in
> given
> recipe.
Place the directive name in () parentheses:
'/\\(:(test)\\s(.*?):\\)/'
This way you'll have the name as $m[1], and the arguments in $m[2]
(which you can parse with ParseArgs). Then, you can have more than one
directive name:
'/\\(:(name1|name2|name999)\\s(.*?):\\)/'
Petko
P.S. The "\\s" assumes that the directives always have a space after the
name: "(:name:)" will not be recognized. You may want to use a different
pattern, something like:
'/\\(:(name1|name2|name999)(\\s.*?)?:\\)/'
the (\\s.*?)? part makes sure that if there are arguments, they will be
preceded by a space; but there may not be arguments, then it will also
work.
More information about the pmwiki-devel
mailing list