View Single Post
Old 02-05-2011, 03:05 PM   #12
Rylon
Hungry Polar Bear
Rylon ought to be getting tired of karma fortunes by now.Rylon ought to be getting tired of karma fortunes by now.Rylon ought to be getting tired of karma fortunes by now.Rylon ought to be getting tired of karma fortunes by now.Rylon ought to be getting tired of karma fortunes by now.Rylon ought to be getting tired of karma fortunes by now.Rylon ought to be getting tired of karma fortunes by now.Rylon ought to be getting tired of karma fortunes by now.Rylon ought to be getting tired of karma fortunes by now.Rylon ought to be getting tired of karma fortunes by now.Rylon ought to be getting tired of karma fortunes by now.
 
Rylon's Avatar
 
Posts: 34
Karma: 355562
Join Date: Feb 2011
Location: San Jose, CA
Device: Kindle Keyboard Wi-Fi + 3G
Here's an alternate solution

Rather than using calibre's smart quotes option, I decided to go old school and use sed. I wrote a sed script that does a good job of creating html smart quotes.

I'm attaching the file, to use it type
Code:
sed -f qscript.txt input file > output file
at a unix command prompt.

Note, as is, this script only works with GNU Sed. To get it to work with other versions of sed, simply remove all the comments aside from the first one.

What you'll end-up with is a file that uses escaped quotations using the numeric character reference. It'll also handle apostrophes and m-dashes. The script has been tested and used only on text files I got from Project Gutenberg and converted to html.

This script has a tendency to be under-inclusive. I suggest that you open up the new file and do a search for double and single quotes. If there aren't a lot, you can manually change them. If there are a lot, I dunno.
Attached Files
File Type: txt qscript.txt (1.1 KB, 429 views)

Last edited by Rylon; 02-05-2011 at 03:46 PM. Reason: Whoops, forgot a step in adding the attachment.
Rylon is offline   Reply With Quote