[pmwiki-devel] Bugfix for extendvars.php

Stirling Westrup sti at pooq.com
Wed Nov 8 08:55:24 CST 2006


I found that I could fix the parsing problem in extendvars.php by replacing
the recognizer regex with more complex one that allows for unbalanced
parentheses inside of double quotes. I'm not really sure its a final solution
but it works for now. Come December (and the end of NaNoWriMo) I may just see
if I can't come up with a similar recipe of my own that addresses some of the
limitations in the current extendvars.php recipe.

(This is not a criticism of D. Faure. The current recipe is written very much
as I might have done, had I not had the experience of working with this
version. Unfortunately there are some unexpected interactions with other
PmWiki markup which may require a very different approach to solve.)


In any case, I found that the solution was to change the line in SetPageVars
that says:

 if(preg_match('/^(\\([^)]+\\)|\\[[^]]+\\])\s*(.*)/', $v, $m)) {

to:

 if(preg_match('/^(\\((?:\\s+|"[^"]*"|[^)\\s]+)+\\)|\\[(?:\\s+|"[^"]*"|[^)\\s]+)\
+\\])\s*(.*)/', $v, $m)) {


PS: I'm wondering if PM has any suggestions on best practices for overriding
and/or chaining markup definitions. When augmenting something like the
'{$var}' markup, one very often wants to

  a) define a new, more general, markup pattern for the existing rule
  b) pre-process the matched text.
  c) pass some string through to the old rule for handling.
  d) post-process the results.

I can think of several ways to do this, but none, to my mind, are particularly
elegant.



More information about the pmwiki-devel mailing list