At Medium, we want to give writers the best typography possible. Among many other things, in our editor — now, editors! — we change dumb quotes to smart quotes. Unfortunately, earlier this year, we discovered that words with smart quotes were flagged as incorrect in Chrome for Windows:
I found out it was originally filed as a bug in Chromium in December 2012. Some friendly people also linked to the matching bug upstream in the wordlist repository, and provided enough context and encouragement.
This is how I approached fixing that bug.
Installing and compiling Chromium
Since the issue only manifested itself on Windows or Linux, I grabbed a virtual machine with Windows 7 and Visual Studio 2013 Professional.
I verified that my Chromium runs by running out\Debug\chrome.exe in the command line. (You know you’re on Windows when you use backslashes instead of / in your paths.)
Also, as a one time operation, I built the convert_dict tool by going to the same directory I built Chromium, and entering ninja -C out\Debug convert_dict
First intermediate goal
Instead of immediately attacking the biggest problem, I decided to start with two smaller tasks. This way I’d know incrementally what works and what doesn’t.
The first goal was trying to add a nonexistent word to dictionary to see if it’s picked up properly. My choice was “typotypography,” which doesn’t exist:
I closed Chromium.
I went to src\third_party\hunspell_dictionaries, and opened en_US.dic in a text editor (Sublime Text for Windows).
I added typotypography in the right place:
I went to command line, to src\third_party_hunspell_dictionaries directory. I then ran the previously compiled convert_dict tool to compile the dictionary.
Reading en_US.aff ...
Reading en_US.dic ...
Reading en_US.dic_delta ...
Writing en_US.bdic ...
Lastly, I copied the generated dictionary to the right place:
E:\src>copy third_party\hunspell_dictionaries\en_US.bdic out\Debug\Dictionaries\en-US-4–0.bdic
Then I ran Chromium:
And verified that the change worked:
Second intermediate goal
Knowing that my changes are recognized, I then decided to add : (colon) as a valid alternative to the apostrophe. The reason I went with the colon was that it was within ASCII range, and I was afraid of Unicode encoding issues.
I went to en_US.aff file, and changed the header from:
ICONV : '
I followed all the dictionary compilation steps from above, and verified by relaunching Chromium and typing didn:t — it was no longer underlined in red.
I then changed:
ICONV ’ '
The change to UTF-8 would require converting the dictionary file to UTF-8 as well… except American English dictionary file was all ASCII, so it didn’t matter.
I followed the dictionary compilation rules as above, relaunched Chromium, and verified it worked:
Then, in order to get my change into Chromium faster, I also patched Chromium directly.
I went into src\third_party\hunspell_dictionaries, and started a branch by invoking:
git checkout -b mwichary-typographical-quotes
Then, I followed usual git incantations:
git add en_US.affgit commit -m "Smart/typographical quotes for en-US."git cl upload
I changed the description and referred to the bug above. This is my patch (again, this was filed by someone else but that’s because of unusual circumstances).
Voilà! It took a few weeks for the change to make it from canary to beta to Chrome stable but, as of a few months ago, the bug is fixed, and smart quotes will not create any spellcheck issues — whether you’re using Medium or not.
It was easier than I thought, and it’s incredibly satisfying to have contributed a fix that every user of Chromium and Chrome will benefit from.