[pmwiki-users] New Recipe: IntuitiveSpacing

Patrick R. Michaud pmichaud at pobox.com
Thu Mar 15 14:40:28 CDT 2007


On Thu, Mar 15, 2007 at 07:32:21PM +0000, Hans wrote:
> Thursday, March 15, 2007, 7:26:56 PM, Patrick wrote:
> 
> > Actually, you want to change only _leading_ spaces, so I think this should have
> > a caret, as in:
> 
> >   Markup('spacing', '>^ws', "/^(\\s{1,7})/e",
> >           "str_replace(' ',' ', '$1');");
> 
> > I think this is also the issue with Site.PageActions -- adding
> > the caret should fix that as well.
> 
> I want to change both leading spaces as spaces in between words etc.,
> to preserve white spaces literally in text as well.

Ouch.  You're likely to run into many problems with this, then,
because any spaces that occur in the middle of HTML tags will also 
be converted.  For example, suppose someone creates a markup function
that somehow produces:

    <div id='mymarkup'   class='xyz'>...</div>

They'll be very surprised when the triple spaces inside the element attributes 
are converted to "&nbsp;&nbsp;&nbsp;" .  And I think it's unreasonable to 
require that recipe writers avoid multiple spaces in HTML tags the recipe
produces, since they're perfectly legal otherwise.

So, at the very least the function needs to make sure that any spaces it is
converting aren't in the middle of an HTML tag.

Pm



More information about the pmwiki-users mailing list