Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > Kobo Reader

Notices

Reply
 
Thread Tools Search this Thread
Old 08-30-2010, 07:19 PM   #1
bob451
Member
bob451 began at the beginning.
 
Posts: 10
Karma: 28
Join Date: Aug 2010
Device: kobo
Converting a manual in HTML into an epub for the Kobo

Given that an epub is basically just HTML with a Table of Contents (chapters) for navigation, it is interesting to look at how well the Kobo handles HTML elements such as tables, lists, images and code blocks (monospaced text). As an exercise, I converted a programming manual from HTML to epub.

The manual was the Lua 5.1 Reference Manual (www.lua.org, authors R. Ierusalimschy, L. H. de Figueiredo & W. Celes). It has one large table (the index) and some smaller tables, a contents page (a list) and some smaller lists, few images or diagrams, but lots of code samples and specifications (mainly HTML <pre> blocks).

calibre (0.7.12, default settings) converted the HTML into an epub with 44 html files, comprising contents, index and the body of the manual. The 41 files for the body matched the main sections in the contents. Viewing the epub on a Kobo was quite illuminating. The main problems were:
  • The index could not be displayed by the Kobo, which rebooted every time it tried to load the page (basically one big, wide HTML table).
  • The Table of Contents built by calibre bore little relationship to the 41 files for the body of the manual.
  • Code blocks (<pre>) displayed in a monospaced font but were truncated at the right margin.
  • The monospaced font is fairly lightweight (thin), so that any non-black text (e.g. green) was somewhat difficult to view as converted to greyscale by the Kobo.
The main problem was the code blocks, which are supposed to display in a monospaced font with leading whitespace retained so as allow indented lines; if the block is too wide for the margins it should be scrollable horizontally. Two examples:

Code:

void lua_getfield (lua_State *L, int index, const char *k);     [-0, +1, e]

     co = coroutine.create(function (a,b)
       print("co-body", a, b)
       local r = foo(a+1)
       print("co-body", r)
       local r, s = coroutine.yield(a+b, a-b)
       print("co-body", r, s)
       return b, "end"
     end)
As displayed by the Kobo (medium font), they came out like this, truncated on the right:

Code:

void lua_getfield (lua_Sta[-0, +1, e]

     co = coroutine.create(functio
       print("co-body", a, b)
       local r = foo(a+1)
       print("co-body", r)
       local r, s = coroutine.yiel
       print("co-body", r, s)
       return b, "end"
     end)
The "[-0, +1, e]" text is a non-code block in the current font (serif or non-serif) aligned to the right margin; it just overwrites any text already there. There was no way of scrolling a code block on the Kobo, which makes such blocks quite unreadable.

I eventually settled on a format for code blocks where all lines are aligned left, re-indented, and with any wrap-around further indented. It's quite readable on the Kobo.

Code:

void lua_getfield 
   (lua_State *L, int     [-0, +1, e]
   index, const char *k);

co = coroutine.create(function
   (a,b)
  print("co-body", a, b)
  local r = foo(a+1)
  print("co-body", r)
  local r, s = coroutine.yield(
     a+b, a-b)
  print("co-body", r, s)
  return b, "end"
end)
The main steps in getting to the final epub were:
  • Dropping the index page.
  • Redoing the Table of Contents to correspond to the main section headings.
  • Redoing all the code blocks to align blocks left, re-indented, and with any wrap-around further indented.
  • Changing all text in code blocks to black.
And the result is an epub which is both readable and usable. Obviously, none of the internal links can be utilised for navigation on the Kobo. However, a Table of Contents of ca 40 entries gives reasonable navigation by chapter.
bob451 is offline   Reply With Quote
Old 08-30-2010, 10:13 PM   #2
moffattm
Addict
moffattm ought to be getting tired of karma fortunes by now.moffattm ought to be getting tired of karma fortunes by now.moffattm ought to be getting tired of karma fortunes by now.moffattm ought to be getting tired of karma fortunes by now.moffattm ought to be getting tired of karma fortunes by now.moffattm ought to be getting tired of karma fortunes by now.moffattm ought to be getting tired of karma fortunes by now.moffattm ought to be getting tired of karma fortunes by now.moffattm ought to be getting tired of karma fortunes by now.moffattm ought to be getting tired of karma fortunes by now.moffattm ought to be getting tired of karma fortunes by now.
 
moffattm's Avatar
 
Posts: 333
Karma: 1440670
Join Date: Jul 2010
Location: Auckland, New Zealand
Device: Kobo Original, Kobo Glo
Thanks, Bob, some useful info there.
moffattm is offline   Reply With Quote
Advert
Old 08-31-2010, 03:28 AM   #3
zoran
himself
zoran can tame squirrels without the assistance of a chair or a whip.zoran can tame squirrels without the assistance of a chair or a whip.zoran can tame squirrels without the assistance of a chair or a whip.zoran can tame squirrels without the assistance of a chair or a whip.zoran can tame squirrels without the assistance of a chair or a whip.zoran can tame squirrels without the assistance of a chair or a whip.zoran can tame squirrels without the assistance of a chair or a whip.zoran can tame squirrels without the assistance of a chair or a whip.zoran can tame squirrels without the assistance of a chair or a whip.zoran can tame squirrels without the assistance of a chair or a whip.zoran can tame squirrels without the assistance of a chair or a whip.
 
Posts: 576
Karma: 11226
Join Date: May 2010
Device: Kobo
Calibre forum has a sticky with tips and tricks. There is a lot of
people looking for the clue and almost all find it sooner or later.
It takes time and nerves, or course. For the second issue, I will
go after Sigil. There is a chance to remove parts, make new toc.
I don't give you the solution, just point to the place where to go.
zoran is offline   Reply With Quote
Old 08-31-2010, 04:47 PM   #4
bob451
Member
bob451 began at the beginning.
 
Posts: 10
Karma: 28
Join Date: Aug 2010
Device: kobo
The same technique for handling an indented line that wraps-around, and for applying a right-aligned block to such a line, is applicable to epub files of poetry and verse.

The Gutenberg version of The Waste Land (pg1321) is a case in point. There are short lines, indented lines and long lines, and the layout matters. On the Kobo (medium font), quite a few lines wrap-around to the left-margin regardless of the indent and the layout. It quite ruins the effect. In addition, the decadal line numbers are not aligned to the right-margin as they should be.
bob451 is offline   Reply With Quote
Old 09-02-2010, 03:11 AM   #5
pleochroic
Member
pleochroic began at the beginning.
 
Posts: 21
Karma: 22
Join Date: Jun 2009
Device: kobo, OLPC XO
thanks for the info. i had issues with calibre conversions and didn't feel like diving too deeply into them.

i am now using jutoh instead, which works brilliantly for my purposes, and has already proven itself worth the U$22 price tag (there is a free trial).
pleochroic is offline   Reply With Quote
Advert
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
MemoryError converting PHP manual (html->mobi) jalperin Calibre 1 09-21-2010 11:40 AM
Calibre Indent Issue When Removing Blank Lines (Converting From HTML to MOBI or EPUB) David Derrico Calibre 5 08-04-2010 12:13 AM
Converting Merged HTML file to Epub/PDF Not Working MV64 Calibre 1 06-07-2010 07:48 PM
bookmark issues converting HTML to EPUB isabellkirsten Calibre 0 04-09-2010 11:47 PM
Any way to force page breaks when converting HTML to EPUB Bierkonig Calibre 23 10-31-2009 01:51 PM


All times are GMT -4. The time now is 10:12 AM.


MobileRead.com is a privately owned, operated and funded community.