02-12-2008, 01:54 PM | #241 |
Wizard
Posts: 1,154
Karma: 3252017
Join Date: Jan 2008
Location: Germany
Device: Pocketbook Touch Lux (623)
|
|
02-14-2008, 11:24 AM | #242 |
creator of calibre
Posts: 44,036
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
@tompe
version 0.29 of mobi2html still has a bunch of <mbpagebreak> elements in the output and doesn't create <a name> elements, when converting the attached mobi file (Created using mobigen -c1 -s0) |
Advert | |
|
02-14-2008, 12:43 PM | #243 |
GuteBook/Mobi2IMP Creator
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"; } -Nick Last edited by nrapallo; 02-14-2008 at 01:45 PM. Reason: fixing layout |
02-14-2008, 01:17 PM | #244 |
creator of calibre
Posts: 44,036
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
@nrapallo
Thanks. |
02-14-2008, 01:32 PM | #245 |
Resident Curmudgeon
Posts: 74,713
Karma: 130140792
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
nrapallo can you please attach a fixed version of mobi2html for us? Thanks!
|
Advert | |
|
02-14-2008, 01:42 PM | #246 |
GuteBook/Mobi2IMP Creator
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
|
JSWolf:
If you mean the code where this fix is in, namely, 'mobi2imp.pl', then it can be found at https://www.mobileread.com/forums/sho...48&postcount=3 (1st attachment in post#3). I maintain this perl script. If you mean, change 'mobi2html' to include this fix, then I would prefer to have tompe apply my suggested fix, as he is the maintainer of that script. Either way, it would be helpful, to have this 'fix' incorporated. -Nick |
02-14-2008, 02:30 PM | #247 | |
Grand Sorcerer
Posts: 7,452
Karma: 7185064
Join Date: Oct 2007
Location: Linköpng, Sweden
Device: Kindle Voyage, Nexus 5, Kindle PW
|
Quote:
There is a 0.0.30 available and if I can get mobi2imp to compile under Windows there will be Windows binaries for this version available later today. |
|
02-14-2008, 02:32 PM | #248 |
Grand Sorcerer
Posts: 7,452
Karma: 7185064
Join Date: Oct 2007
Location: Linköpng, Sweden
Device: Kindle Voyage, Nexus 5, Kindle PW
|
Please let me know if you see some more strange constructions for an anchor.
|
02-14-2008, 03:38 PM | #249 |
GuteBook/Mobi2IMP Creator
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
|
Now that you mention it, the cases where I got the 'Not an anchor' message, that truly did not have any anchors, were:
1. <m - as you mentioned for <mp: pagebreak> (Why would you link to BEFORE a pagebreak? Great sample!). 2. <b - for '<b>' just before an anchor 3. <d - for '<div' like in many feedbooks.com .prc files that I converted They all ended up being valid links to insert a '<a name' tag; just that the ACTUAL 'filepos' was poorly positioned. My thinking was that I would go ahead and insert it as long as it was not in the middle of something. The start of a tag "<" was indeed a good choice to overlook your warning. If this turned out wrong, then the original .prc had it wrong too! Your code is right, just the anchors are poorly positioned! Just my thoughts. Also, thanks for including the 'mobi2imp' in version 0.0.29. That script is version 2; whereas, the fix mentioned above is in version 3 previously posted. However, version 3 also adds the ability to 'fix' corrupt images within the .prc as this is often the case when using the ebook Publisher software. You may want to just comment out this Windows-specific 'fix' line for your distribution, namely: Code:
system "nconvert.exe", "-quiet", "-q", "85", "-resize", "100%", "100%", "$explodedir/$filename"; -Nick |
02-14-2008, 04:15 PM | #250 | |
Grand Sorcerer
Posts: 7,452
Karma: 7185064
Join Date: Oct 2007
Location: Linköpng, Sweden
Device: Kindle Voyage, Nexus 5, Kindle PW
|
Quote:
I could not find nconvert.exe in my version... The huffdic issue is much more work. And as i understood it it did not work entirely correct. I have not decided yet if I need a written description of the algorithm or if the Python code is enough to avoid contamination issues... |
|
02-14-2008, 04:34 PM | #251 |
GuteBook/Mobi2IMP Creator
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
|
It is a freely distributable program that was installed on my PC a few years ago. I did upload that program to my thread in the Fictionwise forum 'Using perl scripts to...'
I think of this line of code as a 'frill' and should be commented out for your distribution, thereby removing the need to include it. Is there any way to re-write out any .jpg/.png/.gif images using perl libs so that I can do away with this external program? -Nick |
02-14-2008, 04:52 PM | #252 | |
Grand Sorcerer
Posts: 7,452
Karma: 7185064
Join Date: Oct 2007
Location: Linköpng, Sweden
Device: Kindle Voyage, Nexus 5, Kindle PW
|
Quote:
Yes, maybe the library I use (GD) will work? Look at how I handle images. |
|
02-14-2008, 05:25 PM | #253 |
Wizard
Posts: 1,154
Karma: 3252017
Join Date: Jan 2008
Location: Germany
Device: Pocketbook Touch Lux (623)
|
Getting mobi2imp from version 0.0.31 to compile under Windows is not really a problem (see attached Makefile(.txt) and .zip), but when I try to run the resulting .exe on a .prc, I get an OLE warning, probably because I don't have eBook Publisher installed.
|
02-14-2008, 05:36 PM | #254 | |
GuteBook/Mobi2IMP Creator
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
|
Quote:
I had looked at the GD.pm but didn't see anything promising. Usually, after the conversion, if I just re-write (and recompress) the images out using nconvert.exe or even the popular irfanview.exe, then the 'corrupt' images issue goes away. -Nick p.s. you can see from my script that I commented out Code:
#use strict; Code:
use strict; Last edited by nrapallo; 02-14-2008 at 10:35 PM. Reason: Ignore p.s. to this post. Problem solved! |
|
02-14-2008, 05:40 PM | #255 |
Grand Sorcerer
Posts: 7,452
Karma: 7185064
Join Date: Oct 2007
Location: Linköpng, Sweden
Device: Kindle Voyage, Nexus 5, Kindle PW
|
Yes, it was easy. Just tested it and put the Windows binaries on the web page.
|
Tags |
mobi2mobi, mobils |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Mobi2Mobi Mobi2Mobi v0.13 - GUI for Mobiperl tools | Jad | Kindle Formats | 476 | 03-15-2015 05:51 PM |
Tools for Editing Kindle .mobi Files? | GJN | Kindle Formats | 33 | 12-26-2013 02:05 PM |
Handy Perl Script to convert HTML0 files to smartquotes | maggotb0y | Sony Reader | 0 | 04-12-2007 11:49 AM |
PRS-500 Perl tools to generate Reader content | TadW | Sony Reader Dev Corner | 0 | 01-08-2007 05:55 AM |
gmail copy (gmcp) - Perl script to copy files to/from Gmail | Colin Dunstan | Lounge | 0 | 09-04-2004 01:24 PM |