[Pmwiki-users] Smart Quotes

John Rankin john.rankin at affinity.co.nz
Tue May 27 17:14:41 CDT 2003


On Wednesday, 28 May 2003 9:59 AM, Patrick R. Michaud <pmichaud at pobox.com> =
wrote:
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. =20

Is this a local customization (e.g., via $InlineReplacements) or is
it actually a script that modifies the stored text somehow?

It's an $InlineReplacements -- I treat it as a rendering requirement, so =
it can be turned on and off.

> 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).
--
I found a problem with || [[http://... http://...gif]] || -- the align =
attributes are getting smart quoted (I need to investigate this further to =
work out exactly what's happening)

> - 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/"] =3D "'&lsquo;$1&=
rsquo'";
  $InlineReplacements['/\\B"(\\w|\\w.*?[\\w,.!?])"\\B/'] =3D "'&ldquo;$1&=
rdquo'";

This ought to handle things like converting

   "Don't do that!"=20
   "'Hello,' he said." =20

into smart quotes while recognizing that things like=20

   I lived in the '80s and '90s=20
   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.
--
Well, I'd expect '80s and '90s and don't all to become &rsquo;

The killer is this 'n' that, which should be &rsquo;n&rsquo; -- hence the =
back tick

> - 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, [=3D'=3D] and [=3D"=3D] ought to work.  :-) =20
--
Duh!

I'd be interested to see the recipe you end up with for this. =20
--
Will do...
JR









More information about the pmwiki-users mailing list