[pmwiki-users] PageList vs WikiForm for multi-line variables

Peter Bowers pbowers at pobox.com
Mon Oct 5 09:10:18 CDT 2015

On Mon, Oct 5, 2015 at 10:44 AM, Peter Bowers <pbowers at pobox.com> wrote:

> You could extend this specifically for a variable named "Abstract" as
> follows:
> $PageTextVarPatterns['abstract'] = '/^(:*\\s*(Abstract)\\s*:[
> \\t]?)(.*?)(\\n(?::*\\s*(?:\\w[-\\w]*)\\s*:))/s';

OK, I got a chance to actually try it out and my fears re typos & thinkos
were validated but my fears re having 'var:' definition match as well ended
up not being a problem.

On my system I add this (slightly modified from above) to my config.php and
*voila* {$:Abstract} magically becomes a multi-line PTV:

$PageTextVarPatterns['abstract'] = '/(?:^|\\n)(:*\\s*(Abstract)\\s*:[
\\t]?)(.*?)(\\n(?::*[ \\t]*(?:\\w[-\\w]*)[ \\t]*:)|$)/s';

No need to modify the ':var' element of that array, at least in my
abbreviated testing. (Apparently the later definition over-writes the value
obtained in the earlier definition since there's no break in the loop in

I have a vague recollection that WikiForms separates PTVs with a
double-newline, so you may want to replace the second \\n with a double
\\n\\n to avoid picking up an extra newline. That would look like this:

$PageTextVarPatterns['abstract'] = '/(?:^|\\n)(:*\\s*(Abstract)\\s*:[
\\t]?)(.*?)(\\n\\n(?::*[ \\t]*(?:\\w[-\\w]*)[ \\t]*:)|$)/s';

But if you ever ended up with a PTV immediately following the Abstract
without the intervening newline then this definition would happily swallow
the entire subsequent PTV definition.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.pmichaud.com/pipermail/pmwiki-users/attachments/20151005/b68de4cc/attachment.html>

More information about the pmwiki-users mailing list