View Full Version : Hypertext and EPUB?


Spolle
06-23-2013, 05:17 PM
I consider writing some interactive stories. EPUB looks like a good platform.

However, the normal page turning is a problem. This means that if the users clumsy fingers misses the hyperlink text, he will instead go forward (or backward) one page. I could, of course, duplicate each page. This will cause the book to be twice as big, but would mean that "going forward" one page won't make any difference. However, this would be a bother to do manually, and I don't know any way to script it.

Is there any 'legal' way to expand the clickable area of a hyperlink beyond that of a simple text area? I know that I could do nasty hacks like put a <table> inside a <a>, but this not the kind of coding e-book readers will expect.

Is it possible to disable page turning by toying with content.opf or toc.ncx? So that the book thinks there is no next page, or that the next page is the same page?

Is it possible to avoid page breaks in certain areas of the text? (this is to avoid that the user misses a hyperlink option because it is on the next page.)

If anyone has any experience in using hypertext inside EPUB books, I would love to hear about it.

Thanks for reading this far!

mrmikel
06-23-2013, 09:04 PM
If by hypertext you mean links in the book, they are used all the time. You just have to point back to where it came from, since some older readers do not have a back button.

Avoiding page breaks can be a bit of a problem since the user can zoom to a large text size. You might succeed but leave big gaps of empty space since you have forced the whole paragraph onto the next page.

Sigil, the epub editor has buttons to provide both links and anchors. But you have to do them yourself. You could make the link text larger or color it differently or include the following and leading space, but the colors will not show up on a number of e-ink readers. Image maps don't work either.

Many many links can slow things down on e-ink readers as opposed to tablet computers.

If you must lay things out exactly, then a pdf might be the way to go. How much pdf internal links would be honored by a reader I don't know.

JSWolf
06-23-2013, 09:22 PM
Make sure the links in the ePub are large enough to be easily touched.

One book I've recently fixed up to make the links big enough, I change the superscripted numbers to [1] [2], etc. also removing the superscript so they were the same size as the main text. No problem touching them to move to the footnote.

Jellby
06-24-2013, 03:32 AM
However, the normal page turning is a problem. This means that if the users clumsy fingers misses the hyperlink text, he will instead go forward (or backward) one page.

That's only a problem if the ebook reader turns pages by touching. I guess most of them nowadays do, but it's not something inherent to the ebook format. Besides, some readers (mine, for instance) let you select links without using the touchscreen, which is a possible workaround.

I could, of course, duplicate each page.

No, you couldn't, because you don't know where each page starts and ends, that depends on the font family and size, screen size, orientation, margins, linespacing... all of those could change from reader to reader.

Unless you are creating one of those concoctions called "fixed-format" ePub. A PDF would be much better in this case.

Is there any 'legal' way to expand the clickable area of a hyperlink beyond that of a simple text area? I know that I could do nasty hacks like put a <table> inside a <a>, but this not the kind of coding e-book readers will expect.

You can add more text to the link, like instead of "see chapter <a href...>3</a>" you could write "<a href...>see chapter 3</a>". But if you are thinking of extending the active link area above and below the text, without affecting the normal text layout... I think that would be tricky, and I wouldn't expect it to work correctly in many readers.

Is it possible to avoid page breaks in certain areas of the text? (this is to avoid that the user misses a hyperlink option because it is on the next page.)

In theory, you can use "page-break: avoid" inside a block's CSS. In practice, this is often not properly supported.

JSWolf
06-24-2013, 02:04 PM
This one very good reason why Sony did it right. They decided on a swipe for page turns and not just a tap. This means that trying to tap on a link won't cause a page turn by mistake.

Spolle
06-24-2013, 07:08 PM
Thanks guys, for this goldmine of info! :-)

HarryT
06-26-2013, 04:53 AM
The "<spine>" section of the OPF file defines the "browsing sequence" of pages in the book. I believe (although I haven't tried it) that you could stop the user from paging forward from one "topic" to the next by NOT having those files listed in the "spine". Hyperlinks would still work, but not paging.

Doitsu
06-26-2013, 06:07 AM
The "<spine>" section of the OPF file defines the "browsing sequence" of pages in the book. I believe (although I haven't tried it) that you could stop the user from paging forward from one "topic" to the next by NOT having those files listed in the "spine". Hyperlinks would still work, but not paging.

AFAIK, that won't work in ADE and epubcheck will display a warning for each hyper-linked .html file without a spine entry.
Theoretically, a linear="no" spine entry attribute should prevent pages from being displayed when paging through a book, but, AFAIK, only iBooks and some other epub 3 reading systems actually observe this attribute.

HarryT
06-26-2013, 06:13 AM
That's a pity. As I say, I haven't actually tried it - it was merely a thought.

I believe it does work for Mobi, if that's of any interest for the OP.

Jellby
06-26-2013, 08:16 AM
I believe (although I haven't tried it) that you could stop the user from paging forward from one "topic" to the next by NOT having those files listed in the "spine".

That would make the ePub invalid. The spec says that all HTML files must be listed in the spine.

Theoretically, a linear="no" spine entry attribute should prevent pages from being displayed when paging through a book, but, AFAIK, only iBooks and some other epub 3 reading systems actually observe this attribute.

And Calibre, if I remember correctly. That's a pity, because it would be a very useful attribute for endnotes, especially when they are at the end of each chapter.

JSWolf
06-27-2013, 10:50 PM
What I do is put the footnotes/endnotes at the end of the spine so when I read forward, I won't be having to skip past them.

Jellby
06-28-2013, 07:43 AM
What I do is put the footnotes/endnotes at the end of the spine so when I read forward, I won't be having to skip past them.

Of course, that's what I do as well, but even in that case it would be nice if readers obeyed the linear="no" attribute, especially if the notes are not included in the global page count.