A Mac smart quote curiosity

I didn’t turn on the smart quotes feature on any of my Macs until earlier this week. I probably should have, but I didn’t need them when writing blog posts or reports,1 and I did virtually all of my social media posting from my phone, which has had smart quotes turned on for years. Since turning Mac smart quotes on, I’ve noticed they behave differently in different apps, even when the apps all come from Apple. I haven’t seen anyone talk about these differences, so I thought I’d do a quick post on what I’ve learned.

As far as I know, the original smart quotes algorithm was created by David Dunham for his miniWRITER desk accessory way back in the early days of classic Mac OS. Here’s Dunham’s description of the algorithm:

As the user types, the characters typed are automatically replaced, according to the context of the insertion point, before being inserted into the text. A quote is turned into its left equivalent if it is at the beginning of the text, or if it follows a space, tab, return, or left punctuation (‘(,’ ‘[,’ ‘{,’ or ‘<’). A quote is also considered an opening quote if it follows an opening quote of the opposite type (as in: “‘sorry’ is all you have to say?” she asked).

Every other quotation mark becomes its right equivalent.

Despite its simplicity, this is a remarkably robust algorithm. The only time I’ve noticed it messing up is when you need an apostrophe at the beginning of a word. If, for example, you’re typing out A Visit from St. Nicholas, what should be

’Twas the night before Christmas…

turns into

‘Twas the night before Christmas…

Fortunately, apostrophes like this are uncommon in modern writing. ’Tisn’t very likely you’ll see this unless you do a lot of dialect writing.

Here’s how Apple’s smart quotes work in a few different apps:

Pages
Here, smart quotes do exactly what you’d expect. As soon as you type either ' or ", you’ll see the appropriate curly version appear on the screen.

TextEdit
Things are almost the same in TextEdit, but not quite. As you type, you’ll see the straight versions appear momentarily, then be replaced by the curly version a fraction of a second later. The overall effect is the same as in Pages, but the slight delay is noticeable. By the way, smart quotes in Stickies (remember Stickies? it’s still here) works the same way as TextEdit.

Safari
Now we get into something interesting. In a web page’s text field, typing ' or " will put the straight quote on the screen and it won’t become curly until you type something else. If it’s supposed to be an opening quotation mark, the curly version won’t appear until you’ve typed the next character. If it’s supposed to be a closing quotation mark or an apostrophe, the curly version won’t appear until you’ve typed some kind of “ending” character—typically a space, a return, or some kind of punctuation. This is usually not a problem, even though it looks a little weird. But if you end on a closing quote—or you don’t put a space or punctuation character after a contraction—the final quotation mark or apostrophe will never curl. Here’s a demonstration:

If you’re sending a message via Safari (or a web app made from Safari) this lack of curl could make your message look goofy, with a bunch of typographically correct apostrophes and quotation marks finished off with a straight one.

Why do different apps from Apple handle smart quotes in slightly different ways? Maybe because the apps were written at different times by different teams and they didn’t share code because the excessively secretive Apple keeps its teams separate? Or maybe there’s a good reason for them to work differently, but I don’t know what that would be.


  1. Going back to when I used Linux, which didn’t have a system-wide smart quotes setting, I’ve had filters that convert straight quotes and apostrophes to curly ones prior to publishing.