Officium Divinum on an ebook reader

BooksIf you want an easy way to put the Divine Office or Liturgy of the Hours on an ebook reader see Universalis. You can read it online. They even have standalone software for Windows and Mac. You can try it for free for a month before you buy a registration code.

The program takes all the hassle of figuring out what to read for the day – it’s all sorted out by computer. The program spits out an ebook to take you through the week with the hours plus the Office of Readings.

All normal people happy with Novus Ordo liturgical things and proprietary operating systems can stop reading there.

The rest of the post describes the sort of complications that make it worth posting about.

For starters, Universalis doesn’t run properly under Linux. Wine doesn’t quite handle the graphical user interface, though it does generate an ebook. Also it uses the modern Liturgy of the Hours, which is great. It spreads out the psalms over a 4 week cycle – which is why you need a computer to keep track of which week it is! My soft spot for the traditional Latin Mass and the Douay Rheims Bible casts a rosy glow over the older Divine Office which gets all the psalms in just one week. Also my Free Open Source Software side baulks at the thought of paying for software – Universalis uses contemporary translations which require royalty payments.

Enter Divinum Officium. A free, open source program written in Perl which generates html versions of the hours according to whichever version of the pre Vatican II office you choose. From Pre-Tridentine Monastic to 1960, in Latin, English and/or Magyar.

The next step was getting the web pages onto my ebook reader. Next piece of the puzzle is Calibre – an open source ebook manager program which converts books between different formats.

My ebook reader only reads epub. It also reads pdfs, but is not so easy to navigate. Epub is basically a zipped up webpage. Html is supposed to be one of the easiest formats to make into an epub ebook.

Unfortunately Calibre had a hard time with Divinum Officium’s output. The webpages are formatted with tables and Kobo doesn’t handle tables very well. It won’t break them over a page so only the first page of each chapter is visible. It needed some tidying up.

UPDATE: Divinum Officium has been updated and now can produce html that Calibre can digest into good epubs that look great on my Kobo Reader – even with two columns!

With “Learning Perl” in one hand and a piece of paper in the other I managed to make up a script to strip the table tags. At the risk of losing all credibility as a programmer here’s my first perl program. I call it cleanup.pl. NOTA BENE: This code is now quite unnecessary with the new updated Divinum Officium, but I leave it here so the article makes sense.


#!/usr/bin/perl
## Here goes nothing!
## Made obsolete by the June 2011 update to Divinum Officium

$aday = "8-31";

opendir(ADAY,"$aday/") || die "can't open $aday";

while ($name = readdir(ADAY)){
print "$name\n";
$newname = $name;
if ($name eq '.'){
print "found a dot";
} elsif ($name eq '..') {
print "found two!;"
} else {

open(IN,"$aday/$name") || die "can't open $aday/$name";
open(OUT,">out/$name") || die "can't open out/$name for writing";
while ($line = ){
$line =~ s/<\/?(TR|TD|TABLE)[^>]*>//;
$line =~ s/<TD[^>]*>//;
$line =~ s/<BODY[^>]*>/<body>/;
print OUT $line;
}
close(IN);
close(OUT);
}
}

closedir(ADAY);

open(IN,"Master-$aday.html") || die "can't open Master-$aday.html";
open(OUT,">Hours-$aday.html") || die "can't open Hours-$aday.html to write";
while ($line = ){
$line =~ s/<\/?(TR|TD|TABLE)[^>]*>//;
$line =~ s/<\/?(TR|TD|TABLE)[^>]*>//;
$line =~ s/<\/?(TR|TD|TABLE)[^>]*>//;
$line =~ s/$aday/out/;
$line =~ s/Master-out/Hours-$aday/;
print OUT $line;
}
print "That's Hours-$aday.html done!\n";
close(IN);
close(OUT);

Divinum Officium can generate lots of days at a time. Then for each day I edit cleanup.pl and change the $aday. The output is still rather rough with lots of deprecated FONT tags so I use Tidy from the World Wide Web consortium with this config file:


// Tidy configuration for converting to xml
output-xhtml: yes
add-xml-decl: no
doctype: strict
indent: auto
wrap: 76
clean: yes
bare: yes

Then call up Calibre to add the file Hours-8-31.html as a book. Then convert the book to epub. Then send the book to the Kobo.

UPDATE: Now I just cd into the Hofficium/officiumprog/ directory and type “perl LHofficium.pl” then note the tips for “Nook and Kindle” that appear in the lower part of the window. I generate the files and then open up Calibre to add the “books” and convert to epub and send to the Kobo as per usual. No scripting required.

Or buy Windows and an Universalis registration code – but where’s the fun in that?

Laszlo Kiss, the creator of divinumofficium.com, died unexpectedly but peacefully at his home on July 11, 2011. He was a few days short of his 73rd birthday.

Requiescat in pace.