Skip to content

Instantly share code, notes, and snippets.

@maiis
Created October 2, 2013 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maiis/6794822 to your computer and use it in GitHub Desktop.
Save maiis/6794822 to your computer and use it in GitHub Desktop.
"Don't be dumb" “You’re smart!” http://smartquotesforsmartpeople.com/
function smartQuotes(text) {
text = text.replace(/(^|[-\u2014\s(\["])'/g, "$1\u2018"); // opening singles
text = text.replace(/'/g, "\u2019"); // closing singles & apostrophes
text = text.replace(/(^|[-\u2014/\[(\u2018\s])"/g, "$1\u201c"); // opening doubles
text = text.replace(/"/g, "\u201d"); // closing doubles
text = text.replace(/--/g, "\u2014"); // em-dashes
return text;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment