[pmwiki-users] ParseArgs problem with value containing spaces

Patrick R. Michaud pmichaud at pobox.com
Wed Sep 6 13:38:29 CDT 2006

On Wed, Sep 06, 2006 at 11:10:21AM -0700, Tony Colley wrote:
>    I'm trying to add a style= key/value argument to a directive, and having a
>    problem with ParseArgs not working as I expect.
>    I tried my sample syntax at Cookbook/ParseArgs#demo and it seemed to parse
>    it just fine. However, it doesn't work in my code. I just updated my
>    PmWiki from SVN (rev 1582) and it still doesn't work.
>    Specifically, I have a directive that I define as
>       Markup( 'hrule', 'directives', '/\\(:hr (.*?):\\)/e',
>    "Keep(Hrule('$1'))" );

You want to use PSS('$1') instead of '$1'.  Otherwise the backslashes
in front of quotes (added by the /e option) will change the argument
parsing (because the items no longer begin with quotes).  Thus

    Markup( 'hrule', 'directives', '/\\(:hr (.*?):\\)/e',
      "Keep(Hrule(PSS('$1')))" );

It's a PHP misfeature, I don't have any better way to handle it than
putting PSS(...) around things whenever /e is used.

>    When I enter
>       (:hr style="height: 1px; width: 1px;":)
>    I see this debug output:
>       style=\"height: 1px; width: 1px;\"

Yes, the backslashes added by /e are the likely culprit.


P.S.:  PSS() stands for "PmWiki Strip Slashes".  I abbreviated it
because it's used fairly frequently and the longer name would
really clutter up the replacement strings.

More information about the pmwiki-users mailing list