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

Thierry pmwiki at lma.metelu.net
Mon Oct 5 10:32:18 CDT 2015


thanks a lot for your answer! Your previous answer was not working, but
after some random modifications (in particular playing with the /ms at the
end) the following kind of worked:

$PageTextVarPatterns['abstract'] =

But your last suggestion seems to work as well, so i guess i will stick to
that one!

Now, another problem appears, i write something depending on whether the
"Abstract" field is empty or not, so i have some condition such as

(:if ! equal "" "{=$:Abstract}":)

It seems that the condition can not be multiline, so all of this is boken.
I tried to just count the length with "{(strlen "{=$:Abstract}")}", but it
also fails. Any idea ?


On Mon, Oct 05, 2015 at 04:10:18PM +0200, Peter Bowers wrote:
> 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
> PageTextVar()...)
> 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.
> -Peter

More information about the pmwiki-users mailing list