[pmwiki-users] PVT' question

Hans design5 at softflow.co.uk
Mon Feb 25 16:23:21 CST 2008


Monday, February 25, 2008, 8:06:02 PM, Knut Alboldt wrote:

> But doesn't a line like
> name: value
> define a PTV ? so what will
> label: {$:PTVName} (:PTVName: value:)
> do then ? Will "label" automatically become a PTV, too ?

yes, as Peter already said.

label: {$:PTVName} (:PTVName: value:)
{$:label}

will show as:

label: value
value

ptv 'label' inherits the value of ptv PTVName

> Would it be possible to create a new markup like:
> (:TEST (my-)name value:)
> which can be translated to the contruct above:
> name: {$:my-name} (:my-name: value:)

Perhaps, but would it not be simpler to define a new
PageTextVariable pattern and markup to match?
After all the concept for PTVs is to have certain string patterns
automatically recognised as a PTV pattern, so a 'value' part of the
string can be shown by using a 'name' part.

How about using a triad: label:name:value

Here is a possible definition for a
label |name: value pattern, and a matching markup, which will
display the label only. The label has to start with a letter or
digit ,or : for a definition list label, but then can contain anything
apart from the pipe, which separates it from the following ptv name.
After the : follows the value.

$PageTextVarPatterns['label|var:'] =
        '/^(.*?\\|(\\w[-\\w]*):[ \\t]?)(.*)($)/m';

Markup('label:var:', '<split',
        '/^((:*\\s*[\\w].*?)\\|(\\w[-\\w]*):[ \\t]?)(.*)($)/m', '$2 :$4');

Example:

25 February |20080225: US to set 'binding' climate goals

displays as

25 February: US to set 'binding' climate goals

and PTV {$:20080225} displays as

US to set 'binding' climate goals


:25 February |20080225: US to set 'binding' climate goals

displays as

25 February
      US to set 'binding' climate goals



  ~Hans




More information about the pmwiki-users mailing list