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).

5 thoughts on “A ConTeXt style file for formatting RSS feeds for Kindle

  1. Very interesting (as usual)!
    Did you consider setting it flushleft? Kindle’s screen is so narrow it might be a better idea (I agree, though, that Kindle’s own line-breaking algorithm sucks terribly).

    • Personally, I find that with protrusion enabled, TeX’s line breaks are reasonable.

      Currently I set tolerance to “verytolerant, strech”. Ideally, this should be changed to “tolerant”, but since I use this in a cron job, I don’t want to do any manual tweaking at all.

      Generally, I don’t like flushleft text, so did not even consider it. I’ll try it for a few days (with tolerance=strict) and see how it goes.

    • I don’t think that tex has been ported to Fire. But if you’d like to produce pdf sized to the screen size of Fire and then just copy them over, I’d be happy to add a setting for Kindle Fire to the eink module.

  2. Very interesting and useful. Presently I use Calibre for my kindle dx. But the formatting is not good. But I was wondering, how would I go about following this blog using this script. There is only a follow option that emails a new post to the subscriber. This means that I will have to save the post and then process it using the ruby script. What am I missing?

Leave a comment