[pmwiki-users] Custom markup over multiple lines

Patrick R. Michaud pmichaud at pobox.com
Sun Jan 1 00:08:16 CST 2006


On Sat, Dec 31, 2005 at 09:58:27PM -0500, DaveG wrote:
> I'm trying to define a custom markup that spans text over multiple 
> lines. Here's what I have:
> Markup('^Country:', 'directives', '/^Country 
> (UK|US|JP|AU|NZ|CA):(.*?)>><</im', '<div class="country $1">$2</div>');
> 
> There are two problems I'd like help with.
> 1] How to get the regex to span multiple lines?
> 2] The >><< terminator doesn't work. I tried "\>\>\<\<" to no avail. 
> What's the right way?

Any markup that is intended to span multiple lines can't be in
the directives section, because by that point PmWiki has
already broken the text up into separate lines.  It needs to go
in the "fulltext" section, or at least somewhere before the
"split" markup rule.

The regular expression '.' doesn't match a newline unless the /s
option is given.

Lastly, the characters '<' and '>' are already converted to
'&lt;' and '&gt;' by the time the markup rules are in effect,
so to match >><< in the markup one must use &lt;&lt;&gt;&gt;.

So, perhaps something like:

  Markup('^Country:', 'fulltext', 
    '/^Country\\s+(UK|US|JP|AU|NZ|CA):(.*?)&lt;&lt;&gt;&gt;/ism', 
    '<div class="country $1">$2</div>');

Pm




More information about the pmwiki-users mailing list