View Single Post
Old 02-14-2008, 12:43 PM   #243
nrapallo
GuteBook/Mobi2IMP Creator
nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.
 
nrapallo's Avatar
 
Posts: 2,958
Karma: 2530691
Join Date: Dec 2007
Location: Toronto, Canada
Device: REB1200 EBW1150 Device: T1 NSTG iLiad_v2 NC Device: Asus_TF Next1 WPDN
kovidgoyal:

I noticed the same thing and have compensated for poorly constructed anchors (as used in SpaceEncyclopedia.mobi and a lot of feedbooks.com .prc's) in version 3 of my 'mobi2imp.pl' perl script.

The following code snippet (from mobi2html), now allows the hyperlinks to work properly (changes in bold):

Code:
print STDERR "Adding name attributes\n";
foreach my $pos (sort keys %fileposmap) {
#    print STDERR "NAMEPOS: $pos\n";
    my $a = substr ($text, $pos+$offset, 2);
    if ($a eq "<a" or $a eq "<A") {
	substr ($text, $pos+$offset, 2, "<a name=\"" . $pos . "\"");
	$offset += (8 + length ($pos));
	next;
    }
    if ($a eq "<h" or $a eq "<H") {
	# Put an empty acnhor before any '<'
	substr ($text, $pos+$offset, 2, "<a name=\"" . $pos . "\"></a><h");
	$offset += (15 + length ($pos));
	next;
    }
#For .IMP start - Kludge mainly for feedbooks.com .prc files (ignore warning)
#
    if (substr ($a, 0, 1) eq "<") {
	# Put an empty acnhor before header
	substr ($text, $pos+$offset, 2, "<a name=\"" . $pos . "\"></a>$a");
	$offset += (15 + length ($pos));
             print STDERR "FIXED: $pos - Not an anchor: $a\n";
	next;
    }
    print STDERR "WARNING: $pos - Not an anchor: $a\n";
}
More information can be found in the Fictionwise eBookwise forum thread 'Using perl scripts to produce .IMP ebooks and more... ' at https://www.mobileread.com/forums/sho...48&postcount=3

-Nick

Last edited by nrapallo; 02-14-2008 at 01:45 PM. Reason: fixing layout
nrapallo is offline   Reply With Quote