A ConTeXt style file for formatting RSS feeds for Kindle

As I said in the last post, I bought an Amazon Kindle Touch sometime back, and I find it very useful for reading on the bus/train while commuting to work.I use it read novels and books, a few newspapers and magazines that I subscribe to, and RSS feeds of different blogs that I follow. Until now, I had been using ifttt to send RSS feeds to Instapaper; Instapaper then emails a daily digest as an ebook to kindle account at midnight; in the morning, I switch on my Kindle for a minute; the Kindle syncs new content over Wifi; and off I go.

However, Kindle typesets ebooks very poorly,  so I decided to write a ConTeXt style file to typeset RSS feed (check it out on github).  To use this style:

\usemodule[rssfeed]

\starttext
\setvariables
    [rssfeed]
    [title={Title of the feed},
     description={Description of the feed},
     link={A link to the feed},
    ]

\starttitle[title={First feed entry}]
....
\stopttitle

\starttitle[title={Second feed entry}]
...
\stoptitle

\stoptext

It uses the eink module to set the page layout and fonts, and use a light and clean style for formatting feed entries. Since the proof is in the pudding, look at following PDFs to see the style for different types of blogs.

I use a simple ruby script to parse RSS feeds and uses Pandoc to convert the contents of each entry to ConTeXt. The script is without bells and whistles, and there is no site specific formatting of feeds. All feeds are handles the same way, and as a result, there are a few glitches: For example, IEEE uses some non-standard tags to denote math) which Pandoc doesn’t handle and the images generated by WordPress blogs that use $latex=...$ to typeset math are not handled correctly by ConTeXt, etc.

The script also uses Mutt to email the generated PDF to my Kindle account. This way, I can simply add a cron job that runs the script at appropriate frequency (daily for usual blogs, weekly for low traffic blogs, and once a month for table of contents of different journals).

Advertisements

A style file for eink readers

Recently I bought an Amazon Kindle touch. It is more convenient than the IREX DR1000 for reading morning news and blogs (thanks to instapaper’s automated delivery of “Read Later” articles, and ifttt for sending RSS feeds to Instapaper).

I have also started reading novels on the Kindle as opposed to the DR1000. Being small, the Kindle is easier to carry; and its hardware just works better than the DR1000: instant startup, huge battery life, and wifi; all areas where DR1000 was lacking. Still DR1000 is the best device when it comes to reading and annotating academic papers, which is surprising given that DR1000 came out 3.5 years ago; perhaps the “eink devices for reading and annotating academic papers” is too niche a niche market to have a successful product. DR1000 was $800 and IREX is now bankrupt.

Anyways, since I am reading novels on Kindle, I have updated my old ConTeXt style file for DR1000 to also handle Kindle and am releasing that as a ConTeXt module. Actually, as two ConTeXt modules: t-eink-devices that stores the dimensions and desired font sizes for eink devices (currently, it has data only for DR1000 and Kindle as those are the only devices that I have) and t-eink that sets an easy to read style that includes:

  • Paper size that matches the screen dimensions
  • Tiny margins, no headers and footers
  • Bookmarks for titles and chapters (both DR1000 and Kindle can use PDF bookmarks as table of contents)
  • A reasonable default style for chapter and title headings
  • A \startinterlude\stopinterlude environment for title pages, dedication, etc.

I have only tested this with simple novels (mostly texts and pictures). That is why the module does not set any style for sections, subsections, etc, as I did not need them so far.

This is mostly for personal use, but I am announcing this module in case someone wants to give it a shot. To use the module, simply add

\usemodule[irex] 
 [ 
 % alternative=kinde, % or DR1000 
 % mainfont={Tex Gyre Schola}, 
 % sansfont={Tex Gyre Heros}, 
 % monofont={Latin Modern Mono}, 
 % mathfont={Xits}, 
 % size=, % By default, kindle uses 10pt and DR1000 uses 12pt font.
 % Use this setting if you want to set a font size.
 ]

This module passes the font loading to the simplefonts module. So, use any name for mainfont etc. that simplefonts will understand. If you don’t set any option, then the default values, indicated above, are used. So, to test out the module, you can just use (for kindle):

\usemodule[eink]

or (for DR1000)

\usemodule[eink][alternative=DR1000]

Below are the samples from Le Petit Prince. The text and images were taken from this website and converted to ConTeXt using Pandoc. The text is also available from Project Gutenburg, Australia.

If you have a Kindle or a DR1000, you can compare the quality of these PDFs (hyphenation, line-breaking, widows and orphans) from what you get from the eBook version. If I am to spend 5-10 hours reading a novel, I don’t mind spending 15 minutes extra (to create a PDF version of the book) to make that reading experience pleasant.

The output is not perfect, especially in terms for float placement in the Kindle version (Page 5 has an underfull page because the figure was too big to fit in the page, the right float image on page 10 would have been better as a here figure, the right float figures on page 13-14 are much lower compared to where they are referred, etc.). But, I find these more tolerable than a chapter title appearing at the bottom of the page and occasionally loosing pagination when I highlight text (both of which happen with epub documents).