[pmwiki-users] Keep() function documented

Joachim Durchholz jo at durchholz.org
Tue Jul 5 16:34:01 CDT 2005


Patrick R. Michaud wrote:

> On Tue, Jul 05, 2005 at 10:30:59PM +0200, Joachim Durchholz wrote:
> 
>>Patrick R. Michaud wrote:
>>
>>>Well, at the moment Keep tokens aren't legally nestable, although 
>>>we can fix that at some point if we need to.
>>
>>Um... there's nothing that would prevent a markup from Keep()ing text 
>>stretches that contain other Keep tokens, or would there be?
> 
> There's nothing to "prevent" someone from doing it, but such
> nested keeps are generally not restored properly.  That's what
> I meant by "not legally nestable" -- someone can write a script
> that does it, but they may not be entirely happy with the results.

Ah, I see.

Note that such nesting can easily happen if a markup calls PRR().

> A quick fix for this might be to have Keep() automatically restore
> any nested tokens before building the new one.

Hmm... I've been thinking about a different approach: introduce a 
$RedoMarkupRule that, if set, will cause MarkupToHTML to repeat the 
current rule. The 'restore' rule could then set that variable so it will 
be automatically repeated until no keep tokens are left.

Such a variable would also help with parsing nested constructs of all 
kinds: let the rule recognise just the innermost construct, process it, 
and replace it with a keep token, then repeat, until all nesting levels 
have been processed. (If the nesting construct may span several lines, 
this would have to happen before line splitting. ... BTW why does PmWiki 
split the text into lines? Efficiency reasons, or other considerations?)

Regards,
Jo



More information about the pmwiki-users mailing list