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