[pmwiki-users] Custom Markup: $2 does not work correctly (regexp problem?)

Patrick R. Michaud pmichaud at pobox.com
Fri Aug 25 08:21:13 CDT 2006

On Thu, Aug 24, 2006 at 08:54:29PM +0200, Dawid Gajownik wrote:
> Hi!
> 	I wanted to unify look of articles in my wiki so I started creating 
> custom markup similar to this one → 
> http://gentoo-wiki.com/Gentoo_Linux_Wiki:Text_Formatting_Templates 
> Simple things with one parameter works correctly. There are problems 
> with more complicated ones, though. For instance I've created this markup:
> Markup("boxfile", "block", '/\\(:boxfile (.*?) | (.*?):\\)/s', "<div 
> class=\"boxfile\"><p><strong>File:</strong> $1</p><pre>$2</pre></div>");

The '|' has meaning in a regexp (it's an alternation), so I think
what you likely intended is:

Markup("boxfile", "block", 
  '/\\(:boxfile (.*?) \\| (.*?):\\)/s', 
  "<div class=\"boxfile\"><p><strong>File:</strong> $1</p><pre>$2</pre></div>");

> (I'm not sure about this "block" option). 

The "block" parameter simply tells PmWiki when to process this
markup.  In this case, it's being processed at the same time
as other "block markups"  (paragraphs, lists, tables, etc.), which
occurs after processing of directives, inline markups, and links.

Also note that it won't be able to handle multiple lines in the
markup (the /s option on the pattern), because 'block' occurs 
after PmWiki has split the input text into separate lines 
and is in line-by-line processing mode.


More information about the pmwiki-users mailing list