View Single Post
Old 02-22-2012, 10:48 PM   #10
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,664
Karma: 205039118
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
OK. I'm assuming you already have Python installed and working.

First get the latest smartypants.py script from here (bottom of the page). Either copy and paste the text from the browser or right-click and "save link as." Just make sure you end up with a file named "smartypants.py". (Alternatively, you can install smartypants.py as a library module in your Python installation if you know how to do that.) I tend to use the smartypants.py script included in the calibre source.

Download and unzip the smarty-wrapper.py script from the zip-file I've attached to this post (the forum won't let me attach a .py file).

Now... put the (x)html file you want to "smarten" in a folder along with the smartypants.py file and the smarty-wrapper.py file (you can forget about the smartypants.py script if you've already installed it as a module).

From a command prompt... cd to the folder where all three files are located and issue the following command:
Code:
python smarty-wrapper.py infile.html outfile.html
Of course make sure to change infile.html to whatever the name of the file you're trying to modify really is. And change outfile.html to whatever you want your resulting new file to be called.

You can read the extensive documentation that's included in the smartypants.py script in order to modify its behavior. Just know that the default action is to smarten quotes (double and single), change -- to an mdash, and to change three consecutive periods ... into an ellipsis …
Attached Files
File Type: zip smarty-wrapper.zip (525 Bytes, 361 views)

Last edited by DiapDealer; 02-22-2012 at 10:53 PM.
DiapDealer is online now   Reply With Quote