[pmwiki-users] PageList vs WikiForm for multi-line variables
Peter Bowers
pbowers at pobox.com
Mon Oct 5 03:44:02 CDT 2015
On Sat, Oct 3, 2015 at 9:06 PM, Thierry <pmwiki at lma.metelu.net> wrote:
> My question is: how to let PageList understand that the content of the
> "Abstract" field is all the lines that appear between ":Abstract:" and the
> definition of the next variable in the page ?
>
Currently $PageTextVarPatterns is defined in pmwiki.php as:
===(snip)===
$PageTextVarPatterns = array(
'var:' => '/^(:*\\s*(\\w[-\\w]*)\\s*:[ \\t]?)(.*)($)/m',
'(:var:...:)' => '/(\\(: *(\\w[-\\w]*) *:(?!\\))\\s?)(.*?)(:\\))/s'
);
===(snip)===
You could extend this specifically for a variable named "Abstract" as
follows:
$PageTextVarPatterns['abstract'] = '/^(:*\\s*(Abstract)\\s*:[
\\t]?)(.*?)(\\n(?::*\\s*(?:\\w[-\\w]*)\\s*:))/s';
Potential problems with the proposed solution:
* I typed this into an email editor and so I very well (almost certainly)
might have messed up the regex (mis-matched parens, typos, thinkos, etc.)
* Now both the 'var:' and the 'abstract' definition will match 'Abstract:'
variable defs - not sure what implications that will have - you may need to
complicate the 'var:' definition to match any variable but Abstract
probably by means of
** a negative lookahead (?!Abstract) after the first \\s*
*** $PageTextVarPatterns['var:'] = '/^(:*\\s*(?!Abstract)(\\w[-\\w]*)\\s*:[
\\t]?)(.*)($)/m';
** or a negative lookbehind (?<!Abstract) before the second \\s*
*** $PageTextVarPatterns['var:'] =
'/^(:*\\s*(\\w[-\\w]*)(?<!Abstract)\\s*:[ \\t]?)(.*)($)/m';
* Same caveat re typos, thinkos, etc on the regexes above.
-Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.pmichaud.com/pipermail/pmwiki-users/attachments/20151005/75115de3/attachment.html>
More information about the pmwiki-users
mailing list