How to Easily Replace “Smart Quotes” in HTML

Posted / 24 September, 2014

Author / Enginess

If you manage web content using a standard CMS, chances are you jump back and forth between the visual and HTML editors now and again. Some do it more than others. We do it a lot. Which is why we have a problem with using smart quotes (e.g. “smart” and not "smart") on the web.

If you manage web content using a standard CMS, chances are you jump back and forth between the visual and HTML editors now and again. Some do it more than others. I do it a lot.

Which is why I have a problem with using smart (or “curly”) quotes on the web.

Any proofreader will tell you that you should use smart quotes and smart apostrophes in your writing, but they don’t know that they wreak havoc when they pop up in HTML. There’s no elegant way to switch between using the two in a browser. It’s really one or the other, and then manually fixing them as you go.

But, you can make your own shortcut (on a Mac) to remove smart quotes and preserve your HTML by following the instructions below:

  1. Open the application called Automator (find it in the applications folder or Launchpad)
  2. Select ‘Service’ from the options for the new type of document to create
  3. Make the options read: “Service receives selected text in any application  and check off “Output replaces selected text”.
  4. Add the ‘Run Shell Script’ element as the first item
  5. Choose Shell: /bin/bash and pass input: to stdin
  6. In the text area, paste: sed -e 's/“/"/g; s/”/"/g; s/…/.../g; ' -e "s/’/'/g"  Your final product should look like this:

Now, just save it and give it a name like “Remove Smart Quotes”. You can even add some scissors (✃) for fun.

Done.

Now, when you select any text in any application and right click (or control click), you’ll have the option to remove smart quotes, like this:

remove smart quotes

So you can easily turn this broken HTML:

Moveable Online URL

Into this clean HTML:

Moveable Online URL clean Plan your project right - a step-by-step guide to ensure a successful digital project launch. Read now.

Topics

See all ≫ ≪ Hide all

Subscribe to Enginess Digital Insights


Share the insights /