Improve smartypants support

Taken from http://gist.github.com/drdrang/705071

Basically, if a ' or a " is preceded by the beginning of line, dash,
slash, parentheses, brackets, quotes, or whitespace, it's an opening
one. Otherwise it's a closing one.
Merge pull request #178 from tasuk/improve-smartypants

Improve smartypants support