Extending The Curly Quotes Module is fun! With a little understanding of how RegEx works, you can do all sorts of fun things. For instance, I added the following into my ‘Curly Quotes’ template:
<MTAddRegex>s|&([^#])|&$1|g</MTAddRegex>
Which does what you may ask? Well, it does the same thing as the Hivelogic URL Cleaner. It finds all instances of an & in the site, and converts it to the equivalent symbolic notation (&), except when it is followed by a # (indicating it’s already a symbolic notation of something). As an added bonus, this version will clean up your &’s all over the place, so your page will validate. Well, except for that pesky RDF thing.
There is a downside, in that I’m now force to used numeric symbolic equivalents instead of the handy shortcuts (like < instead of <), but I’m sure I’ll figure out some workaround for that too. Perhaps if I simply replace all those with their numerical equivalents before replacing the ampersand? I’ll sleep on this one.
Why can’t you use the ‘shortcuts’ ? Is the problem that you have different versions scattered around your files?
Why can’t you use the ‘shortcuts’ ? Is the problem that you have different versions scattered around your files?
Oh – because I replace all &’s, except those followed by #’s. So the shortcuts, which don’t have the #’s, will be converted, so they won’t work anymore. Although I was thinking I could probably do something where I also escape any series of characters ending in a ;. That should work also. But is slightly more complex, so I didn’t do that. I’m still thinking on this one.
Oh – because I replace all &’s, except those followed by #’s. So the shortcuts, which don’t have the #’s, will be converted, so they won’t work anymore. Although I was thinking I could probably do something where I also escape any series of characters ending in a ;. That should work also. But is slightly more complex, so I didn’t do that. I’m still thinking on this one.
How about this?
s/&[^#](?![a-z]*;)/&$1|gi
How about this?
s/&[^#](?![a-z]*;)/&$1|gi
Whoops, that last post got eaten. See this.
Whoops, that last post got eaten. See this.