View Single Post
Old 08-23-2014, 09:58 PM   #4
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,680
Karma: 205039118
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
But if they're already single smart quotes, neither calibre's smartening routines nor my editor plugin will help the OP convert single smart quotes to double smart quotes. Neither will regex quite frankly--not a one-size fits all Replace All solution, anyway. It would be multiple passes and stepping through stuff one-by-one to make sure everything went right. An algorithm of some kind would be better suited for that kind of wholesale conversion (and even that would probably never be 100%).

If I was forced to do this using regex only, I'd try to change all apostrophes to some weird string with something like (\pL)’(\pL) replaced with \1~apos~\2 (I'd still need to look for plural possessive apostrophes, and words like ’tis and such). Then once I was satisfied that I'd protected all apostrophes by mangling them into a unique string, it should be relatively simple to replace the opening and closing single smart-quotes with their double smart-quote counterparts. With that done, I could go back and unmangle my apostrophes: replacing ~apos~ with ’ (or an entity).

Mostly though, I probably wouldn't bother.
DiapDealer is offline   Reply With Quote