[pmwiki-users] Custom markup over multiple lines

DaveG pmwiki at solidgone.com
Sun Jan 1 10:19:15 CST 2006


Thanks very much. I made a minor correction to the ordering of the << 
and >>, and also the //s should be /s since we're using single quotes:
    Markup('^Country:', 'fulltext',
      '/^Country\s+(UK|US|JP|AU|NZ|CA):(.*?)&gt;&gt;&lt;&lt;/ism',
      '<div class="country $1">$2</div>');

Out of interest, would it be more in the pmwiki-way to define  the markup:
    (:country UK:)
    (:countryend:)

OR
    >>country UK<<
    >><<

Or some other way?

  ~ ~ Dave

Patrick R. Michaud wrote:
> 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