[pmwiki-users] Input recipe V0.2 released

Joachim Durchholz jo at durchholz.org
Tue Jun 28 14:06:54 CDT 2005


Christian Schlatter wrote:
> I extracted the following from an earlier email:
> 
>> The problem is that PmWiki doesn't have any easy way to know that
>> the Keep() result contains block markup.  The easy way to fix this
>> is probably to do:
>>
>>    Markup("gallery", "directive",
>>      "/^\\(:gallery:\\)/e",
>>      "'<:block>'.Keep(cs_gallery())");

Thanks - that did it!

I had to go through some extra gyrations to make it work: (:input ...:) 
is a block markup if it is (:input start...:) or (:input end:), and an 
inline markup otherwise. In case anybody is interested, here's how I did it:

I had two Markup calls. They were essentially the same:
Markup(
   'input',
   '>input-start-of-line',
   '/\\(:input(.*?):\\)/ei',
   'InputMakeHtml(PSS(\'$1\'), 0)'
);
Markup(
   'input-start-of-line',
   '>directives',
   '/^\\(:input(.*?):\\)/ei',
   'InputMakeHtml(PSS(\'$1\'), 1)'
);

The differences were:
1) 'input-start-of-line' will be tried before 'input' (i.e. it has 
priority if both match).
2) Both rules look for the same markup syntax, but 
'input-at-start-of-line' is additionally restricted to recognise it only 
if (surprise!) it's at the start of line.
3) InputMakeHtml got an additional parameter, $at_start_of_line. 'input' 
sets it to zero (false), 'input-start-of-line' to (surprise again!) one 
(true).
4) If InputMakeHtml sees that it's parsing (:input start...:) or (:input 
end:) *and* the $at_start_of_line flag is true, it will prepend the 
<:block> markup, otherwise it will do just the normal thing.
5) Contrary to usual practice, InputHtml wraps the appropriate sections 
of its output string in Keep() calls. (Having Keep() in the Markup call 
would make it impossible to have <:block> processed by further PmWiki 
machinery.)

Regards,
Jo



More information about the pmwiki-users mailing list