epub fails Ingram validation with error parsing CSS?!

I’m using Mac OSX v11.1 and Scrivener v3.2.2 (14632).

  1. I generate an epub of my book from Scrivener using “Compile->epub” output. Twice. When creating the epub, I specifically check “Optimize for Kindle Conversion” for one epub and specifically uncheck “Optimize for Kindle Conversion” for the other epub.

  2. Both epubs opens fine in AppleBook.

  3. I uploaded the “Optimize for Kindle Conversion” epub to Amazon KDP for them to convert to mobi for kindle books. That completed successfully, and is now available for sale on Amazon.

  4. I uploaded the “Not Optimize for Kindle Conversion” epub to Ingram and it failed with validation error (see below). As experiment, I uploaded the “Optimize for Kindle Conversion” epub to Ingram and failed with these same errors plus a whole bunch of other errors.

  5. I’ve searched these forums, Ingram’s docs and the internet without success. Anyone seen this before? Any ideas?


(CSS-008): /OPS/css/stylesheet.css: An error occurred while parsing the CSS: Token “list-style-type” not allowed here, expecting :.
(CSS-008): /OPS/css/stylesheet.css: An error occurred while parsing the CSS: Token “list-style-type” not allowed here, expecting :.
(CSS-008): /OPS/css/stylesheet.css: An error occurred while parsing the CSS: Token “}” not allowed here, expecting :.
(CSS-008): /OPS/css/stylesheet.css: An error occurred while parsing the CSS: Premature end of grammar (expecting: ‘;’ or ‘}’).

Have a look at:
ePub Zip/Unzip 2.0.1.app

Unzip both epubs and compare files to see where the difference is. It could be a simple syntax error in the code and caused by any number of things. If you don’t know/understand code, any web developer should be able to spot the problem. Diagnosing the cause might be more challenging.

  • T

Problem solved! And it was on me (not Scrivener). Here’s the details including steps taken to debug and fix, in case this is helpful to others later.

(Also, a big thank you to @CattailNu for the tip about unzipping an epub file! This started me down the right path to quickly finding the solution.)

To examine the contents of an epub file, simply rename the extension from “.epub” to “.zip”. You can then expand the contents using whatever unzip utility is provided on your version of Mac/Windows/Linux. No need to download/buy any special utilities. On my Mac OSX11.1, I renamed “book.epub” to “book.zip”, then used “unzip book.zip”. This created an expanded subdirectory tree of all files that were contents of the epub file. I found the file mentioned in the error message “/OPS/css/stylesheet.css” and opened this file in a text editor.

In the file “stylesheet.css”, I discovered the problem and the quick instant fix.

Back in 2018, when publishing the 1st edition of my book, I hit a problem with indenting of bullet lists in specific situations. This was to be fixed in later version of Scrivener, but to avoid delaying the book release, I was advised to manually add a workaround to the css file. The workaround was to manually add a specific “list-style-type” to the end of the CSS file. The workaround worked and I happily published that 1st edition.

I forgot all about this workaround until I was looking at stylesheet.css in the text editor.

In Scrivener v3.2.2, in Compile dialog box, select “epub” or “mobi” as needed. In bottom left corner of dialog box, there is a “edit settings” button which opens a new dialog box with list on left hand side. In that list, find “CSS” and click on that to see the CSS text in the main dialog box. At the bottom of the CSS text, I found the workaround I had added in 2018. After editing the text to remove the workaround, I saved everything, then recompiled for epub (for kindle and also for non-kindle) formats and mobi format. I then verified the lists look fine in all three formats; in takeaways, in lists-in-mid-chapters, top/bottom of pages, etc. This CSS is not in the print version, so nothing to change there. Uploaded the new epub to Ingram and it passed validation first time. Success!

Also, thank you Scrivener for fixing that bullet list bug as promised; I’m happy this workaround is no longer needed.

Hope that helps,

protip: when making changes to files like this, always add comments explaining why. I’m super glad I did this back in 2018, or else might not have noticed this change so quickly.

It’s always good to know about the zip file trick with ePub, but just so you know, there is a free and open source tool called Sigil, which will open .epub files directly, and allow full editing of all its internal components. It also comes with a good suite of utilities for checking validity (and even offering to try and fix common syntax errors for you). It’s a great “finisher” for those that need a little extra work done to their epub files, after compiling, never mind a great debugging tool when you get errors.

I cannot agree with that one more emphatically! For those that don’t know, you can insert a comment into a CSS file with:

/* Anything you want to say can go between these markers. */

Just do be aware that enterprising readers who are aware of the .zip trick or Sigil may read your comments some day. :slight_smile:

Incidentally, if you run into something like this with a newly compiled document, you can tell Scrivener to save the ePub source files for you. It’s one of the settings under the “gear” icon in the right-hand pane of the main Compile screen.