Friday, May 29, 2009
Two Bits in EPub format
Chris Kelty’s book, Two Bits: The Cultural Significance of Free Software is available as a free download in PDF and HTML formats. Neither version is suitable for reading on a handheld or ebook reader, so I’ve made an EPub version. EPub is an XHTML-based self-contained single file document format. Download here. This is how I made it from the HTML version:
Step 1: Fix spaces
I intend to read the book on a Sony Reader PRS-505. The HTML version uses n- and m-spaces that aren’t part of the Dutch Roman font that the Sony Reader uses, so they show up as ugly ‘?’ characters. This script replaces them with regular spaces:
#!/usr/bin/env python import sys spaces = u'\u1680\u180e\u2002\u2003\u2004\u2005\u2006\u2008\u2009\u200a\u205f\u3000' nbsp = u'\u2007\u202f\u2060' nospace = u'\u200b\u200c\u200d\ufeff' for f in sys.argv[1:]: print "Updating %s..." % f data = unicode(open(f, 'rb').read(), 'utf-8') for s in spaces: data = data.replace(s, ' ') for s in nbsp: data = data.replace(s, '\u00a0') for s in nospace: data = data.replace(s, '') open(f, 'wb').write(data.encode('utf-8'))
Step 2: Remove print page numbers
The HTML files have page numbers as per the print edition. You may not want them. I didn’t:
perl -pi -e 's/<a name="[^"]*"><span class="page">\[PAGE [^\]]*\]<\/span><\/a>//' *.html perl -pi -e 's/<span class="page" align="right">\[PAGE [^\]]*\]<\/span>//' *.html perl -pi -e 's/<span class="page">\[PAGE [^\]]*\]<\/span>//' *.html
Step 3: Make EPub edition
The included Index.html file uses a frameset that displays a sidebar on the left. This is not suitable for handhelds, so I threw it away. I then made a list of all the HTML files as per the order in the sidebar, and used eCub to convert into EPub format. However, this file turned out to be unreadable on the Sony Reader, so I used Calibre to fix it and add the cover image.
Here’s the resulting EPub version of Two Bits.
ckelty — May 29, 2009 3:35:27 AM — # ↩
jace, thanks for doing this. I will add it to the website as a download option! and thanks for explaining how you did it too… I hope it’s as interesting on an ebook reader as it is in HTML ;)
Kiran Jonnalagadda — May 29, 2009 3:45:37 PM — # ↩
Thanks, Chris.
Opera on S60 can be used to read the HTML version offline (though it won’t keep track of where you were). For other devices, the EPub version works better. Stanza on the iPhone and the Sony Reader PRS-505 and later can read EPub. It can also be read online:
bookworm.oreilly.com/view/Two+Bits%3A+The+Cultural+Significance+of+Free+Software/27273/
The EPub version retains all the hyperlinks. On the Sony Reader, the footnotes and within-book links all work. EPub files are also pre-paginated (but reflowable across pages) so it’s lighter on the device’s processor than a raw HTML file would be.
Pingback by Two Bits » Blog Archive » Two Bits, now in eBook form… — May 29, 2009 3:42:46 AM — # ↩
[…] Kiran “Jace” Jonnalagadda (a veteran silk-list member) created an epub version for the Sony e-Book reader (thanks jace)! SHARETHIS.addEntry({ title: “Two Bits, now in eBook form…”, url: “twobits.net/2009/05/28/two-bits- […]
Radhika — May 30, 2009 1:54:13 PM — # ↩
Hello Kiran, We at Naukriforwomen have been reading your articles and commentaries on the vast issues facing India and wish to congratulate you on this wonderful work and for the impact it makes. We wish there were more writers such as you to take India forward and put Indian women in the forefront where they rightfully should be.
You and our website have a lot of things in common, one of them being a shared vision of creating a better world for the modern Indian woman. To put things in perspective, Naukriforwomen.com is the first and only jobsite that is solely dedicated to the Indian Woman. In a short span of time Naukriforwomen.com has created a place for itself in the minds of Indian women with thousands of Registered Job Seekers and over 1000 Registered Employers posting women-oriented jobs. Our goal is to reach out to every Indian woman who wants to earn a living.
We would like to take this opportunity to invite you to visit us at www.naukriforwomen.com and get to know us better. We are passionate about the cause of the Indian woman and would like to be associated with you in this noble initiative. We implore you to you cover our website and write about us in your write-ups and appearances. Together, we believe that we can achieve a lot for the neglected Indian woman.
Best Regards,
Naukriforwomen.com Team.
Kerim Friedman — Jun 28, 2009 12:23:24 PM — # ↩
This is MUCH easier to read on my iPhone (with Stanza) than the version I had made previously. Which is great, because now it is summer and I plan to finally finish reading it. Thanks!