[pmwiki-users] New Recipe: IntuitiveSpacing
Patrick R. Michaud
pmichaud at pobox.com
Thu Mar 15 15:06:57 CDT 2007
On Thu, Mar 15, 2007 at 07:51:17PM +0000, Hans wrote:
> Thursday, March 15, 2007, 7:40:28 PM, Patrick wrote:
>
> > 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 " " . 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.
>
> would it perhaps work if the space conversion gets done after style in
> the markup translation? This would allow the spaces in wiki styles as
> in Site.PageActions.
It would probably help, yes.
> How do I filter out the html tags though? I need to create a function
> for this, and when(where) shall the spacing markup run then in the markup
> translation table?
You might try something like the following for the pattern:
"/(\\s{2,7})(?![^<]*>)/e"
This says to match 2 to 7 spaces, but not if it's followed by a '>' that doesn't
have a '<' in front of it. So then we'd have:
this is a test # matched, no '>' comes after the spaces
this is <span>a test</span> # matched, we find a '<' before coming to a '>'
<span id='xyz'>foo</span> # not matched, a '>' is found after the spaces
so, we're probably inside an HTML tag
Pm
More information about the pmwiki-users
mailing list