View Single Post
Old 01-03-2009, 10:48 PM   #647
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
OK, I see the problem now. The prc file does not contain HTML code and I think the MobiPocket format requires HTML code. And if you do mobi2html followed by html2mobi you loose the formatting.

So I think the mistake was to generate files of type TEXt with the content as ordinary text.

This is the same problem as for the file in the other thread.

My lit2mobi can of course be used in a batch job.
My Mobi2IMP can handle that TEXt/REAd .prc because I included a simple detection for text files (in bold) as follows:
Code:
my $text = $pdb->text;

if (defined $opt_rawhtml) {
    binmode (STDOUT);
    print $text;
}
if (substr ($text, 0, 6) ne "<html>" && substr ($text, 0, 6) ne "<HTML>" ) {                                       
    open TEMPFILE, ">$explodedir/$htmlfile.txt" or die "Cannot create .txt file";
    binmode (TEMPFILE);
    print TEMPFILE $text;
    close TEMPFILE;

    open TEMPFILE, "$explodedir/$htmlfile.txt" or die "Cannot open .txt file";
    my @lines = <TEMPFILE>;               # Read it into an array
    close TEMPFILE;                       # Close the file

    #unlink "$explodedir/$htmlfile.txt";

    $text = "<HTML><HEAD></HEAD>\n<BODY>\n" ;

    my $line;
    foreach $line (@lines) {              # assign @lines to $line, one at a time
       $text .= "<P>" . $line . "</P>" unless (length($line) == 1);  
    }

    $text .= "\n</BODY>\n</HTML>\n";

}
nrapallo is offline   Reply With Quote