Smart quotes in the editor

Hi there,

Hope I’m writing in the right category here.

When you type a quote or apostrophe in the Ghost editor, you get a straight one: " and '. Those are a typewriter leftover. Almost every publication uses curly quotes in print and on the web, and most writing tools (Google Docs, Word, Pages, iA Writer) convert them as you type. In Ghost you have to fix them by hand or paste from somewhere else, and on a site with any typographic care the straight marks stand out.

A few related requests exist, though I’m not allowed to link to them: How can I use smart quotes in the Ghost editor?, Curly quote marks and Support curly quotes.

I’ve built this as a Koenig plugin and opened a PR (#30941). Here’s what it does:

  • Quotes and apostrophes curl as you type: “Hello,” she said. “It’s ‘fine’.”
  • Leading apostrophes, which most software gets wrong, point the right way: rock ’n’ roll, the ’90s, ’til.
  • Feet and inches become primes rather than quotes: 5′10″, a 12″ pizza.
  • Pasted text is converted too, but existing posts are never rewritten when they load.
  • Left alone: inline code, HTML and Markdown cards, card inputs, and Ghost’s {first_name, “there”} replacement strings.
  • Each conversion is a normal undo step, so Cmd+Z gives you back the straight quote if you really wanted one.

The rules follow Smart Quotes for Smart People.

ghost-smart-quotes-typing

A couple of questions for the team:

  1. Should it be on by default, or a setting? I’d argue on by default, since curly quotes are correct for nearly all prose, and the undo escape hatch covers the exceptions.
  2. The post title field isn’t a Lexical editor, so it isn’t covered yet. Worth doing as a follow-up?

PR: ✨ Added smart quotes to the editor by dvdwinden · Pull Request #30941 · TryGhost/Ghost · GitHub

7 Likes

Nice job!

I’m not from the team, but I would like to share my idea anyway. I think, it should be “on” for new Ghost sites, but “off” for ongoing sites, to not cause a breaking change, for the people who are happy with “non-smart” quotes. But this setting should be in Ghost admin, to easily switch, not in the Ghost config file.

Hm, good shout. I’m not immediately worried it’d be a breaking change, though.

Really nice work, especially the leading apostrophes. ’90s and rock ’n’ roll are exactly where most editors get it wrong.

On the default question, I’d lean toward on for new sites with a toggle in admin, like @muratcorlu said. The undo step covers the occasional miss, so the toggle is mostly for people pasting code-heavy content outside code cards.

One thing that might be worth thinking about: sites not writing in English. German uses „…“ and French uses « … », so curling to English quotes would be wrong for them. Could the style follow the site’s publication language setting, or at least be skipped for non-English locales at first?

We’ve been working through the same straight-vs-curly question for text on Novastart’s infinite canvas, so it’s great to see someone tackle it this carefully.

That’s a great idea. Dutch technically also should use „…”, but it’s a bit antiquated, and done very rarely.

I’d be happy to make it locale-specific. Let’s see what thoughts the Ghost team adds to the PR.

I made some changes based on your input, @Novastart and @muratcorlu. Thank you!

1 Like

Since it converts as you type, older posts will keep their straight quotes, so most sites would be mixed for a while after turning it on. Not a big deal, but probably worth a line in the release notes so nobody thinks it’s broken.

I was puzzled when I came across this topic, as my Ghost site has always used smart quotes in the editor. After doing a little digging, I realized it wasn’t Ghost or the browser doing that – it was my Mac, with the “Use smart quotes” setting turned on in Settings. (In fact, I’ve had to learn how to force straight quotes when needed.)

Would Windows and Linux have a similar setting?

2 Likes

Not really, as far as I know. On Windows it’s the apps doing it (Word, Google Docs), there’s no system-wide switch like the one on the Mac. On Linux you can type them with a Compose key, but nothing converts them for you automatically. So for anyone writing on Windows, the editor doing it itself would actually make a difference.

I’m afraid that doesn’t do the trick. I’ve had this setting switched on, but it seems to overridden by websites (this forum included).

(Though, the forum does seem to turn them into smart quotes after posting, but not when typing. Anyway!)

That’s Discourse’s typographer setting, it swaps the quotes when the post gets rendered and the editor never touches them. Doing it at render time in Ghost would also fix the mixed old/new posts thing, though since Ghost stores the rendered HTML, old posts would only change once they’re re-saved.

1 Like