[pmwiki-users] Re: A (:comment:) markup enhancement

Patrick R. Michaud pmichaud at pobox.com
Tue Mar 15 17:29:25 CST 2005


On Wed, Mar 16, 2005 at 12:11:45AM +0100, Dominique Faure wrote:
> Hi,
> 
> When developing code in [choose a programming language here], I'm used to
> enable/disable prog parts with comments marks.
> With PmWiki, I've got the (:comment ...:) directive, but its current
> definition isn't supporting embedding of other directives into comments:
> 
> (:comment foo bar ...:) => (nothing) regular use works as expected
> (:comment (:nl:) :)     => <space>:) aka. closing mark of (:nl:) is closing
> the comment directive
> 
> So, the current markup definition:
> 
> Markup('comment','directives','/\\(:comment .*?:\\)/','');
> 
> could be changed into:
> 
> Markup('comment','<directives','/\\(:comment\\s?.*:\\)/','');
> 
> or even into:
> 
> Markup('comment','<directives','/\\(:comment\\s?.*:\\)/s','');
> 
> to handle multiline comments embedding disabled directives, with the
> performance cost impact of having greedy regexp.

Actually, the real cost of this last one is that any (:comment:) directive 
would then expand to include *any* later directive that occurred, even outside
the supposed "comment".  For example:

    (:comment this is a comment:)
    here is some
    text
    (:spacewikiwords:)
    more text
    more text

would actually consider everything up to (:spacewikiwords:) as being 
part of the comment, because the .* is greedy (across newlines).  And 
even with the single-line version, the result of:

    (:comment hello world:)  (:searchbox:)

is that (:searchbox:) ends up being part of the comment, since .*
will match "hello world:)  (:searchbox".

If you need multiline comments (that can include other directives),
try using (:if false:):

    (:if false:)
    here is some
    text
    (:searchbox:)
    with other directives
    (:if:)

Pm



More information about the pmwiki-users mailing list