[pmwiki-devel] Creating a page text variable in a recipe
Hans
design5 at softflow.co.uk
Mon Sep 28 04:33:26 CDT 2009
Monday, September 28, 2009, 9:45:46 AM, Petko wrote:
> Couldn't you just use :
> :title:Song Sung Blue
> :subtitle:Neil Diamond
> :album:Hot August Night
> instead of the ones in {braces} ? Change your markup parser to recognize this.
> This way, they will work as regular PageTextVariables from other pages and
> from pagelists.
I agree.
Alternatively add a custom pattern to $PageTextVarPatterns,
so PmWiki sees the {text:more text} as a PTV.
Something like this:
$PageTextVarPatterns['{var:...}'] = '/^(\\{)(\\w+):\\s*(.*?)(\\})/m';
There is a danger that it will catch something else, but I could not
see it doing a very quick test. I think Petko's idea to use an
established PTV pattern is wiser for this reason.
In both cases you might want to change the
title:Some Song Title P
PTV, as PmWiki has a title markup, not a PTV as yet, but it may get confused.
I also suggest to change the starting ||: and ending :|| delimiters
to something else, as ||: is taken as table markup.
(:song:) (:songend:) perhaps.
We still have problems if more than one such song markup is used per
page. Standard PTVs have to be unique in the page text content in
order to work reliably.
A while back I started working on a recipe which defined data PTVs
of various formats, which offered a hierarchical data structure.
This would be useful to access PTvs of same name but located in different
branches of the data tree. Maybe it is worthwhile to discuss this in a
separate thread.
Hans
More information about the pmwiki-devel
mailing list