Smart Quotes

quotes typography markdown parsing

The Goldmark Markdown parser should automatically convert your writing to use smart quotes or curly quotes, rather than dumb/straight quotes. However, there may occasionally be a bug. Let’s test out some edge cases!

Table of contents

Examples

These may display “undesirable” behavior. But as a 5′11″ man located near 39° 57′ 9.2988″ N and 75° 9′ 54.7992″ W (primes! I manually entered them), I consider many things about my situation undesirable. I should be 6'20", like Washington.

“‘You miss 100% of the shots you don’t take.’ –Wayne Gretzky” – Michael Scott

Closing quotation marks within italics

*"Do the best you can until you know better. Then when you know better, do better."*

“Do the best you can until you know better. Then when you know better, do better.”

Closing quotation marks within boldfacing

**"At first, things were not clear."**

“At first, things were not clear.”

Closing quotation marks within boldfacing and italics

***"The law cannot protect anyone unless it binds everyone; and it cannot bind anyone unless it protects everyone."***

“The law cannot protect anyone unless it binds everyone; and it cannot bind anyone unless it protects everyone.”

Plural possessives

John's dog is named Sam. The Smiths' dog is named Rover.

John’s dog is named Sam. The Smiths’ dog is named Rover.

This is not difficult (see "[Introduction to Hugo Templating](https://gohugo.io/templates/introduction/)").

This is not difficult (see “Introduction to Hugo Templating”).

Apple's early Cairo font gave us ["moof" and the "dogcow."](https://www.macworld.com/article/2926184/we-miss-you-clarus-the-dogcow.html)

Apple’s early Cairo font gave us “moof” and the “dogcow.”

Single closing quotation marks with slang/informalities

"I'm not doin' that," Bill said with emphasis.

“I’m not doin’ that,” Bill said with emphasis.

Closing single quotation marks in quotations-within-quotations

Janet said, "When everything is 'breaking news,' nothing is 'breaking news.'"

Janet said, “When everything is ‘breaking news,’ nothing is ‘breaking news.’”

Opening single quotation marks for abbreviations

We're talking about the internet --- 'net for short.

We’re talking about the internet — ’net for short.

Note: This may be impossible to resolve, since it could cause subsequent issues with the opening quotation marks for nested quotes: He muttered, "And then she said, 'Hello,' in a shy voice."

He muttered, “And then she said, ‘Hello,’ in a shy voice.”

Quotation marks next to footnotes

People ask, "Why can't you just change the format?"[^formatChgNote]

People ask, “Why can’t you just change the format?”1

Conclusion

As of Hugo v0.81.0, smart quotes are unreliable when using Goldmark.

You may get better results from Blackfriday, but since that is no longer the default Markdown rendering engine, that may cause different problems.

Goldmark seems to be receiving more maintenance, and Goldmark has the potential to be more consistent/predictable in its implementation by following the CommonMark specification.

P.S. No one is working on fixing this

UPDATE 2021-09-13: The Goldmark parser bug was closed as “stale” because the author is not a native English speaker and lacks the confidence to sort it out themselves, and nobody else stepped up to fix it. The Hugo bug report was closed because the bug is in an upstream project, not Hugo itself. Therefore, nobody seems to be working on fixing this bug at the moment.

This is troubling because the alternative Markdown parser Blackfriday was deprecated in Hugo v0.87.0, Goldmark is really the only option going forward.

If you happen to have the relevant skills, dear reader, I encourage you to take a swing at fixing this bug.

UPDATE 2022-01-16: Good news, the Goldmark maintainer removed stale bot from the relevant Goldmark bug, and added tags for “good first issue” and “help wanted”, so we can stop wrestling with stale bot there. Bad news, some stale bot equivalent closed and locked the relevant Hugo bug, which might make it harder to locate people with the skills and interest in fixing the issue. I have filed a new Hugo bug report, and hopefully we can keep this one open despite unfriendly bots.

The bug was finally fixed!

UPDATE 2022-03-18: As of Hugo 0.94.2 I can no longer reproduce any problems with smart quotes. Goldmark was fixed in version 1.4.7, and Hugo updated to Goldmark 1.4.7 in Hugo 0.93.0. Hooray!


  1. This is a regular footnote. ↩︎