Skip to content

Instantly share code, notes, and snippets.

@karbassi
karbassi / curlies.js
Created August 12, 2013 23:49
Really small native javascript function to convert text with straight quotes to curly/smart quotes.
function curlies(element) {
function smarten(text) {
return text
/* opening singles */
.replace(/(^|[-\u2014\s(\["])'/g, "$1\u2018")
/* closing singles & apostrophes */
.replace(/'/g, "\u2019")
/* opening doubles */