|
![]() |
|
Thread Tools | Search this Thread |
![]() |
#1 |
Member
![]() Posts: 12
Karma: 56
Join Date: Dec 2008
Device: None
|
Kindle Previewer: error converting from epub with specific CSS and `display: none`
I believe I have found a bug in Kindle Previewer 3.4 on Windows 10. Here are the details. I'd love to know if others have found anything similar or can shed more light on what causes it, or if I'm just wrong about something.
Essentially, conversion from epub throws an error when, in its CSS, `display: none` is set for a class that is referenced on its own *and* as a child of another element. So this HTML: Code:
<body> <div> <h1>Test heading</h1> <p class="test-class">Test chapter text, with a class of 'test-class'. I'm going to try to hide this with CSS.</p> </div> </body> Code:
body .test-class, .test-class { display: none; } Code:
Error(prcgen):E21018: Enhanced Mobi building failure, while parsing content in the file. The error message references the HTML file, even though (after extensive testing) it's clear the problem is with the CSS. If anyone would like to try reproduce this, I've included the full HTML and CSS files for testing below. I used Sigil 0.9.6 to create the epub. Naturally the workaround is simple: just structure your CSS differently. I happen to use Sass to generate my CSS, and if I nest classes to keep things neat in Sass, it's very easy to end up with this error-causing CSS structure. HTML file in full: Code:
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <link rel="stylesheet" type="text/css" href="../Styles/styles.css"/> </head> <body> <div> <h1>Test heading</h1> <p class="test-class">Test chapter text, with a class of 'test-class'. I'm going to try to hide this with CSS.</p> </div> </body> </html> Code:
/* This CSS shows a bug in conversion with Kindle Previewer 3.4 on Windows 10 * If a class is hidden with `display: none` and it is referenced both * on its own and as a child of a parent element, conversion breaks: * * "Error(prcgen):E21018: Enhanced Mobi building failure, while parsing content in the file. Content: <Test heading> in file: C:\Users\Arthur\AppData\Local\Temp\mbp_7E0_8_8_B_15_10_F0_17D0_F50_1\OEBPS\Text\test-file.xhtml line: 7" * * The error occurs during the phase indicated by KP3.4 as 'Optimizing' * KindleGen (command line) does not throw any errors and converts fine. * * So the following following line will cause the error: */ body .test-class, .test-class { display: none; } /* This will also fail: body .test-class { display: none; } .test-class { display: none; } */ /* With this layout, the conversion does not seem to complete or error, but hangs: body .test-class { display: none; } div .test-class { display: none; } */ |
![]() |
![]() |
![]() |
#2 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,598
Karma: 84812983
Join Date: Nov 2011
Location: Tampa Bay, Florida
Device: Kindles
|
Quote:
The Previewer has many other bugs that cause failure to convert books for Enhanced Typesetting. Since they happen silently, just reporting "Enhanced Typesetting not supported" for those books, it isn't obvious to the user just how buggy it really is. Bugs that prevent generation of a MOBI file, such as you found, are rarer. |
|
![]() |
![]() |
Advert | |
|
![]() |
#3 | |
mostly an observer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,515
Karma: 987654
Join Date: Dec 2012
Device: Kindle
|
Quote:
Thanks for your work on KFX. |
|
![]() |
![]() |
![]() |
#4 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,598
Karma: 84812983
Join Date: Nov 2011
Location: Tampa Bay, Florida
Device: Kindles
|
Quote:
Also, the stand-alone version appears to be more strict about what combinations of tags and styles it will allow when compared with the production version. I don't know why. I am in the process of testing Previewer version 3.4 and it does appear to be better at conversion than the previous 3.x versions. It also produces more useful error messages when a conversion failure occurs. Unfortunately it doesn't display these messages to the user! I am in the process of updating my KFX Output calibre plugin to support Previewer version 3.4. That plugin has the ability to capture conversion error messages from the Previewer and display them to the user. Even when they are cryptic, something is better than nothing. Older books that haven't yet been converted to support Enhanced Typesetting most likely have something in them that is being rejected by the conversion process. Feeding such a book though the Previewer may be useful in determining where the specific problem lies. You can iteratively cut out parts of the html/css until you narrow down what it doesn't like. |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Converting epub to mobi through Kindle Previewer | AThirstyMind | Kindle Formats | 26 | 12-28-2012 06:32 PM |
Converting Epub to Mobi: Calibre v KindleGen/Kindle Previewer | Jane12 | Kindle Formats | 16 | 11-22-2012 07:47 PM |
Editing epub's style.css when converting to epub | Pros | Calibre | 0 | 02-02-2012 01:13 PM |
Kindle Previewer Displays HTML lists incorrectly when converting from EPUB | Gandharva | Kindle Developer's Corner | 1 | 09-01-2011 06:52 PM |
Trouble converting CBZ/CBR to epub for specific hardware (Literati) | curtw | Conversion | 2 | 02-02-2011 09:12 PM |