View Single Post
Old 12-13-2011, 09:46 AM   #4
Boris4Perl
Junior Member
Boris4Perl began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Nov 2011
Device: none
internal links as toc?

Hello,

I'm searching this forums and the internet since quite a while now. My knowledge seems to increase... but I just keep on failing on the device with my tests

I think this thread here is appropriate for my question.

I am writing Perl-Code that generates mobi-files from scratch... well actually I'm using mobiperl's libraries for the most of the part. Until now I could solve most problems, everything is working fine... images and html are handled well. But I keep one failing including a table of content (TOC).

This Thread tells me, that there is a simple and a complex solution... since I'm doing it from scratch I would want to give the simple solution a try...
As far as I understand, the simple way of creating a TOC is to implement it with links and anchors. But if I try doing so, it's not working.

Ok, instead of talking more, I first show an example of how I think it should work. This is an example of HTML-data which is displaying fine on Kindle, apart that the TOC is working:

Code:
<body>
<a id="TOC"></a>
<h1>Table of Content</h1>
<p><a href="#start">Foreword</a></p>
<p><a href="#chap1">Chapter One</a></p>
<p><a href="#chap2">Chapter Two</a></p>
<mbp:pagebreak />
<a id="start"></a>
<h1>Foreword</h1>
<p>Some Text and a <a href="http://www.perl.org">hyperlink</a>.</p>
<mbp:pagebreak />
<a id="chap1"></a>
<h1>Chapter One</h1>
<p>Some Text...</p>
<mbp:pagebreak />
<a id="chap2"></a>
<h1>Chapter Two</h1>
<p>The end!</p>
</body>
(Here is the code rendered through browser as png -> Pic

The only difference to the post above is, that I don't use any path in the link, I just say "#ref" instead of "path#ref". But as far as I know I am storing all the content just in one block into the mobi file, and this data has nothing that I could call a "filename"... or does it?

If you test this example HTML code in a bowser it works very well. If I test it on the Linux-eBook-Reader "fbreader" it works well enough. But if I try it on Amazon-Kindle it doesn't work. When I move the cursor over the TOC-entries, nothing happens at all (if you do the same with a hyperlink the cursor changes to a hand-symbol).

So here comes my final question: Is my approach completely going into the wrong direction or is there just a small bug to fix which I I'm just blind for?

Thank you very much for any help.
Boris4Perl is offline   Reply With Quote