[Pmwiki-users] Smart Quotes
Patrick R. Michaud
pmichaud at pobox.com
Tue May 27 16:59:41 CDT 2003
On Wed, May 28, 2003 at 09:17:14AM +1200, John Rankin wrote:
> [...]
> So I wrote a short php script that automatically turns single and double quotes into left and right quotes.
Is this a local customization (e.g., via $InlineReplacements) or is
it actually a script that modifies the stored text somehow?
> This raised 3 questions:
> - are there any bad side-effects of doing global quote substitution, eg are there places where it will incorrectly pick up quotes around HTML attribute values
My first reaction is that there probably are going to be some problems
with the HTML, although off-hand I can't think of where. Certainly there
will be problems with quotes in the [[table ...]] and ||-table markups.
WikiStyles are probably okay (so far) because quotes aren't part of
WikiStyles (yet).
> - what about cases like '90s where the quote should be a right single to indicate omitted characters; I solved this using ` (back tick) as an escape character, so an author writes `'90s
I think that for smart quotes to be truly smart one should make sure
they're paired and in the right location--i.e., I'd do a replacement
like along the lines of (I'm writing off the top of my head here so don't
hold me to this):
$InlineReplacements["/\\B'(\\w|\\w.*?[\\w,.!?])'\\B/"] = "'‘$1&rsquo'";
$InlineReplacements['/\\B"(\\w|\\w.*?[\\w,.!?])"\\B/'] = "'“$1&rdquo'";
This ought to handle things like converting
"Don't do that!"
"'Hello,' he said."
into smart quotes while recognizing that things like
I lived in the '80s and '90s
Don't make the mistake of believing you shouldn't do something
The players' shirts were all torn.
shouldn't be translated. I'm sure there are some pathological cases I've
missed--I'll have to look at some of my regex recipes to see how others
deal with the conversions to typographic quotes.
> - are there times when an author will want to over-ride smart quotes and leave them straight, and if so, what should the mark-up be
Well, [='=] and [="=] ought to work. :-) And if you work to make sure
that quotes are only converted at appropriate word boundaries then it
ought to handle most of the cases where it would otherwise be a problem.
I'd be interested to see the recipe you end up with for this.
Pm
More information about the pmwiki-users
mailing list