[pmwiki-users] CustomMarkup without <p>

Patrick R. Michaud pmichaud at pobox.com
Tue May 31 11:52:27 CDT 2005


On Tue, May 31, 2005 at 06:00:23PM +0200, Christian Schlatter wrote:
> Patrick R. Michaud wrote:
> >Actually, it'll be easier if you could tell us what your (:gallery:)
> >Markup looks like, then I can tell you how to fix it.  :-)
> 
> OK, the Markup code looks like this:
> 
> Markup("gallery", "directive", "/\(:gallery:\)/e", Keep(cs_gallery())");
> 
> The function cs_gallery() uses the embed class of menalto gallery and 
> returns the gallery body content. When I write (:gallery:) into a 
> wikipage, the produced HTML looks something like:

The problem is that PmWiki doesn't have any easy way to know that
the Keep() result contains block markup.  The easy way to fix this
is probably to do:

   Markup("gallery", "directive",
     "/^\\(:gallery:\\)/e",
     "'<:block>'.Keep(cs_gallery())");

where the '<:block>' tells PmWiki that the item that follows isn't
paragraph text.  Note that this restricts (:gallery:) to appearing
at the beginning of a markup line.

Another way to do this (without restriction to beginning of line) 
may be to move the <div> generated by cs_gallery outside of 
the Keep(), as in:

   Markup("gallery", "directive",
     "/\\(:gallery:\\)/e",
     "'<div id=\"gallery\">'.Keep(cs_gallery()).'</div>'");

PmWiki will then see the <div> and know to not treat it as a
paragraph.  (I've thought about trying to make the block
markup smart enough to "look inside" of Keep() text for block
markupsi to prevent paragraph formatting, but that's a *lot* 
more difficult than what I have now.

One last note -- keep in mind that the use of id="gallery" in 
the <div> tag will mean that only one (:gallery:) can be 
used in a page and still produce valid XHTML.

Pm



More information about the pmwiki-users mailing list