Shiny New E-Book Gizmo: The Amazon Kindle


View Full Version : lit2mobi written in Perl working


tompe
11-28-2007, 03:14 PM
I am working on a set of programs to convert to Mobipocket format. I have only worked on it a couple of days so the state of the code is alpha. I am a bit unsure if the mobi file is generated entirely correct but it seems to works on my Gen3.

If somebody would like to start using these program you need some familiarity with Perl and you need to know how to install modules from CPAN. I have tested on Linux and it should work on Mac and it might work with some small changes on Windows. Notice that the Perl programs writes the Mobifile so you do not have to run mobigen using wine or other similar programs. You have to have clit installed for lit2mobi to work.

If you do not want to install the program but would like to see the result you can send me a lit file and I will send you back the result so you could help by giving feedback on the result.

The programs are here:

http://www.ida.liu.se/~tompe/mobiperl/mobiperl-0.02.tar

You run it like:

lit2mobi The_Railway_Children.lit

lit2mobi --coverimage cover.jpg file.lit


Documentation available with

perldoc html2mobi

since for now lit2html calls html2mobi.

I place the TOC in the beginning of the file also. I also search for a suitable cover image and use it automatically. I do not add a reference to the cover image and that seems to lead to that the book opens on the TOC page and if you go back one page you get the full cover image. If you have a reference you get two cover images instead.

Feedback (bug report, feature suggestions and so on) is very welcome

kovidgoyal
11-28-2007, 03:19 PM
You should use the spine element of the OPF file if present to fix the order in which the HTML files are appended.

tompe
11-28-2007, 03:28 PM
You should use the spine element of the OPF file if present to fix the order in which the HTML files are appended.

I do that. But I duplicate the TOC and place a copy of it first since I have not gotten the guide stuff to work yet. It was an experiment but also it might be that on the Gen3 you want to have it that way. And yes since I only tested a couple of lit files and the TOC was always at the end I assumed that was the standard...

Nate the great
11-28-2007, 03:47 PM
I do that. But I duplicate the TOC and place a copy of it first since I have not gotten the guide stuff to work yet. It was an experiment but also it might be that on the Gen3 you want to have it that way. And yes since I only tested a couple of lit files and the TOC was always at the end I assumed that was the standard...

Let me guess. Those LIT files were from Baen Books, right? They are the only ones I know that use that goofy placement.

kovidgoyal
11-28-2007, 03:49 PM
The way the TOC is specified varies widely from lit file to lit file. Take a look at opf.py in libprs500 for the logic I use to figure out the TOC.

You might also find this page useful
http://www.idpf.org/oebps/oebps1.2/download/oeb12-xhtml.htm

tompe
11-28-2007, 04:06 PM
Let me guess. Those LIT files were from Baen Books, right? They are the only ones I know that use that goofy placement.

Well I think it is the right placement for devices were the TOC-button works fast. The Mobipoacket demo book also had the TOC at the end. But I will look at more test cases.

lovebeta
01-19-2008, 11:55 AM
Thanks pal, it works great! I am wondering if you could add a batch process mode? It would be even better if it could recursively go through all sub-directory.

Thanks again.

tompe
01-19-2008, 12:06 PM
Thanks pal, it works great! I am wondering if you could add a batch process mode? It would be even better if it could recursively go through all sub-directory.


Well, maybe. I put it on my list of possible things to do. It is easy to write a script to do this so I am not sure that these kind of things should be built in.