[pmwiki-users] Re: Conditional Markup enhancement

Patrick R. Michaud pmichaud at pobox.com
Tue Mar 1 09:03:25 CST 2005


On Tue, Mar 01, 2005 at 09:39:57AM +0100, chr at home.se wrote:
> On Mon, 28 Feb 2005, Patrick R. Michaud wrote:
> 
> > ParseArgs also understands single and double quotes, thus one 
> > can have arguments like key="value with spaces".
> 
> Sounds very useful, and the only problem is that it will lose argument
> order (not that I use it very often, but it might be good to have in some
> cases).

The items are in argument order within "classes"--i.e., the
name-value pairs appear in $args in the order in which they
were encountered, and all of the +, -, and unnamed arguments
are in the order in which they were encountered.

Plus, for *most* features the argument order isn't important.
I'm not intending ParseArgs to be an all-purpose-parse-the-arguments-in-
any-way-you-need function -- it's just designed to handle the
most common cases and make that simple.  If the data structure
returned is too complex, then I haven't achieved my purpose.
Functions that need more complex parsing can still do it
themselves (and will be more effective at it).

Still, since the hard part of parsing strings like these
is handling quotes, and since ParseArgs already knows how
to do that, perhaps for processing things in an appropriate
sequence it's sufficient to simply return something like
your last option, but without the nested key/value pairs:

   $args['#'] = array(
      '', '123',
      'list', 'none',
      '+', 'list',
      '-', 'any',
      '', 'apple pie',
      'title', 'my page',
      '+', 'plus',
      '+', 'something');

(This is in addition to setting $args[''], $args['+'], $args['list'], etc.)

Pm



More information about the pmwiki-users mailing list