Unclear behaviour of double quotes

We found out a weird behaviour in the commonmark reference implementation which doesn’t seem to have a counter-part in the spec (discussed in Fix smart punctuation by GuillaumeGomez · Pull Request #565 · raphlinus/pulldown-cmark · GitHub).

So when we have the following:

" hello"

It generates an open and closing unicode quotes. However, its equivalent in single quotes doesn’t (and all other emphasis rules too):

' hello'

Did I miss it in the spec or is it only specially handled in the reference implementation?

Thanks in advance!

“Smart Quotes” behavior is not part of the CommonMark spec. It’s just an optional added feature of the reference implementation.

Even if it’s an added feature, some clarifications would be welcome. :slight_smile:

We try to match quotes using the same algorithm as for emphasis.
So when the quote is followed by a space, it won’t be interpreted
as an opener for a matched pair.

When you have an unmatched quote like this, we treat it as
a left double quote if it’s a double utoe, and a right single
quote if it’s a single uote. That explains the asymmetry.
Why do it this way? Well, unmatched left double quotes are
used in some styles of punctuation, in fictional dialogue
continued by the same character. Unmatched left single
quotes, though, are likely apostrophes (and hence right).

Guillaume Gomez via CommonMark Discussion
noreply@talk.commonmark.org writes: