Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > Kindle Formats

Notices

Reply
 
Thread Tools Search this Thread
Old 02-12-2008, 01:54 PM   #241
Gudy
Wizard
Gudy ought to be getting tired of karma fortunes by now.Gudy ought to be getting tired of karma fortunes by now.Gudy ought to be getting tired of karma fortunes by now.Gudy ought to be getting tired of karma fortunes by now.Gudy ought to be getting tired of karma fortunes by now.Gudy ought to be getting tired of karma fortunes by now.Gudy ought to be getting tired of karma fortunes by now.Gudy ought to be getting tired of karma fortunes by now.Gudy ought to be getting tired of karma fortunes by now.Gudy ought to be getting tired of karma fortunes by now.Gudy ought to be getting tired of karma fortunes by now.
 
Gudy's Avatar
 
Posts: 1,154
Karma: 3252017
Join Date: Jan 2008
Location: Germany
Device: Pocketbook Touch Lux (623)
Quote:
Originally Posted by DMcCunney View Post
Might want to check that exists, first. On my machine, the boot drive is normally D:, and Perl is in D:\Perl\Bin. (I dual booted Win2K and XP, and C: is the 2K drive.)
Right, so it should probably be %HOMEDRIVE%\Perl\bin then, or %SystemDrive%\Perl\bin?
Gudy is offline   Reply With Quote
Old 02-14-2008, 11:24 AM   #242
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
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)
Attached Files
File Type: mobi SpaceEncyclopedia.mobi (357.9 KB, 359 views)
kovidgoyal is offline   Reply With Quote
Advert
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
Old 02-14-2008, 01:17 PM   #244
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,036
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
@nrapallo
Thanks.
kovidgoyal is offline   Reply With Quote
Old 02-14-2008, 01:32 PM   #245
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
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!
JSWolf is offline   Reply With Quote
Advert
Old 02-14-2008, 01:42 PM   #246
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
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
nrapallo is offline   Reply With Quote
Old 02-14-2008, 02:30 PM   #247
tompe
Grand Sorcerer
tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.
 
Posts: 7,452
Karma: 7185064
Join Date: Oct 2007
Location: Linköpng, Sweden
Device: Kindle Voyage, Nexus 5, Kindle PW
Quote:
Originally Posted by kovidgoyal View Post
@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)
For the attached file 0.0.29 did not give a result file with mbpagebreak in it. I have fixed the other problem. I wonder why the attached file hade two <mbpagebreak/> in a row. I did a fix that works for "<m" or "<M". I do not want to just put an anchor before "<" since I would like to detect the different ways this can be done since some of them might require special handling.

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.
tompe is offline   Reply With Quote
Old 02-14-2008, 02:32 PM   #248
tompe
Grand Sorcerer
tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.
 
Posts: 7,452
Karma: 7185064
Join Date: Oct 2007
Location: Linköpng, Sweden
Device: Kindle Voyage, Nexus 5, Kindle PW
Quote:
Originally Posted by nrapallo View Post
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.
Please let me know if you see some more strange constructions for an anchor.
tompe is offline   Reply With Quote
Old 02-14-2008, 03:38 PM   #249
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
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";
I wanted to update 'mobi2imp' to include your latest revisions to mobi2html for the 'huffdic' issue, but I couldn't find that fix in version 0.0.29; is it there?

-Nick
nrapallo is offline   Reply With Quote
Old 02-14-2008, 04:15 PM   #250
tompe
Grand Sorcerer
tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.
 
Posts: 7,452
Karma: 7185064
Join Date: Oct 2007
Location: Linköpng, Sweden
Device: Kindle Voyage, Nexus 5, Kindle PW
Quote:
Originally Posted by nrapallo View Post
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";
I wanted to update 'mobi2imp' to include your latest revisions to mobi2html for the 'huffdic' issue, but I couldn't find that fix in version 0.0.29; is it there?
I changed my code to also insert an anchor before "<". I did not test it but hopefully it works...

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...
tompe is offline   Reply With Quote
Old 02-14-2008, 04:34 PM   #251
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
Quote:
Originally Posted by tompe View Post

I could not find nconvert.exe in my version...
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
nrapallo is offline   Reply With Quote
Old 02-14-2008, 04:52 PM   #252
tompe
Grand Sorcerer
tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.
 
Posts: 7,452
Karma: 7185064
Join Date: Oct 2007
Location: Linköpng, Sweden
Device: Kindle Voyage, Nexus 5, Kindle PW
Quote:
Originally Posted by nrapallo View Post
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?
I meant that I did not find this line in the Perl code.

Yes, maybe the library I use (GD) will work? Look at how I handle images.
tompe is offline   Reply With Quote
Old 02-14-2008, 05:25 PM   #253
Gudy
Wizard
Gudy ought to be getting tired of karma fortunes by now.Gudy ought to be getting tired of karma fortunes by now.Gudy ought to be getting tired of karma fortunes by now.Gudy ought to be getting tired of karma fortunes by now.Gudy ought to be getting tired of karma fortunes by now.Gudy ought to be getting tired of karma fortunes by now.Gudy ought to be getting tired of karma fortunes by now.Gudy ought to be getting tired of karma fortunes by now.Gudy ought to be getting tired of karma fortunes by now.Gudy ought to be getting tired of karma fortunes by now.Gudy ought to be getting tired of karma fortunes by now.
 
Gudy's Avatar
 
Posts: 1,154
Karma: 3252017
Join Date: Jan 2008
Location: Germany
Device: Pocketbook Touch Lux (623)
Quote:
Originally Posted by tompe View Post
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.
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.
Attached Files
File Type: txt Makefile.txt (3.2 KB, 354 views)
File Type: zip mobiperl-0.0.31-win.zip (9.43 MB, 324 views)
Gudy is offline   Reply With Quote
Old 02-14-2008, 05:36 PM   #254
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
Quote:
Originally Posted by tompe View Post
I meant that I did not find this line in the Perl code.

Yes, maybe the library I use (GD) will work? Look at how I handle images.
Sorry, now I know what you meant (I hope). You have version 2 of 'mobi2imp' included in your distribution. That line of code is in version 3 posted below.

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;
I did so because I was getting compile erros due to my setup/code not being 100% accurate. Do you know what breaks when I use:
Code:
use strict;
Attached Files
File Type: pl mobi2imp.pl (15.7 KB, 324 views)

Last edited by nrapallo; 02-14-2008 at 10:35 PM. Reason: Ignore p.s. to this post. Problem solved!
nrapallo is offline   Reply With Quote
Old 02-14-2008, 05:40 PM   #255
tompe
Grand Sorcerer
tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.
 
Posts: 7,452
Karma: 7185064
Join Date: Oct 2007
Location: Linköpng, Sweden
Device: Kindle Voyage, Nexus 5, Kindle PW
Quote:
Originally Posted by Gudy View Post
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.
Yes, it was easy. Just tested it and put the Windows binaries on the web page.
tompe is offline   Reply With Quote
Reply

Tags
mobi2mobi, mobils


Forum Jump

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


All times are GMT -4. The time now is 06:06 AM.


MobileRead.com is a privately owned, operated and funded community.