[pmwiki-users] Wikipaths (was: PData support for pagelisting images)

V.Krishn webmaster at insteps.net
Thu Sep 7 18:27:45 CDT 2006


On Friday 08 September 2006 03:57, Patrick R. Michaud wrote:
> On Fri, Sep 08, 2006 at 12:16:05AM +0200, Dominique Faure wrote:
> > On 9/7/06, Patrick R. Michaud <pmichaud at pobox.com> wrote:
> > >> Also, how about using a more tradtional function form
> > >>
> > >> (is it too hard from a regexp standpoint?):
> > >> >   {(function args)Group.PageName#section$[:?]var}
> > >>
> > >>     {function(args)Group.PageName#section$[:?]var}
> > >
> > >It's not too hard, but I like the {(function)...}
> > >syntax since "{(" is a clear marker that a function is
> > >being applied.  It's also somewhat consistent with (:directive:)
> > >syntax, where the args are inside the parens instead of out.
> > >It also leaves the door slightly open for a way to apply
> > >functions to non-variables, like:
> > >
> > >    {(toupper) This text is converted to all caps}
> >
> > [You replied too fast for me :-)]
> >
> > I would love to get the regexps required to refactor PVE according to
> > these specs...
>
> FWIW, the generalized form I'm thinking of would allow multiple
> cascaded functions, so that
>
>    {(toupper)(date "%b %Y") 20020106 }
>
> would become
>
>    JANUARY 2006
>
> So, the regexp to find and replace this becomes something like:
>
>     preg_replace('/\\{(\\(\\w[^)]+\\)*)([^}]*)\\}/e',
>                  "ApplyFunctions(PSS('$1'), PSS('$2'))", $x, $match)

not quite sure, should it be
 preg_replace('/\\{(\\(\\w[^)]+\\))*([^}]*)\\}/e',
//-----------------check n no of func------------
                 "ApplyFunctions(PSS('$1'), PSS('$2'))", $x, $match)

V.Krishn
>
> where we then parse out the first argument by parens
> parens to get the functions and arguments being applied:
>
>     function ApplyFunctions($fnlist, $text) {
>       preg_match_all('/\\((\\w+)([^)]*)\\)/', $fnlist, $functions)
>       // $functions has the list of functions names and their arguments...
>
> Pm
>
> _______________________________________________
> pmwiki-users mailing list
> pmwiki-users at pmichaud.com
> http://www.pmichaud.com/mailman/listinfo/pmwiki-users




More information about the pmwiki-users mailing list