I just found a file that exhibited this problem heavily today, and the root cause wasn't unbalanced quotes in the source file. It was actually spaces between the quoted text and the quotes. That really confuses the smartypants function.
A 'bad' example:
" This is bad... "
A 'good' example:
"This is good..."
There isn't really an easy way to fix this automatically with regex - I tried - you just need to go through the text and find places where there is an offending space. You can use a regex to make it simpler though:
"\s+(?=\w)
(?<=\W)\s+"
(?<=\w)\s+"
Just search through the text with those patterns, and replace with " when it's a real match.
|