Tuesday, May 4, 2010

InDesign flubs CSS in ePub for exported lists

I think InDesign is a pretty powerful tool for generating ePub documents. But I've found an annoying mistake in one of their ePub export options.

InDesign has a cool feature that lets you format paragraphs as bulleted or numbered lists. You choose the system and InDesign inserts the bullets or numbers automatically. It's a very powerful and useful tool.

Bulleted List

Here is what the list looks like in InDesign:

bulleted list in Indesign

In the Digital Editions Export Options box, you can choose to convert paragraphs styled with InDesign's handy Bullet and Numbered List style characteristics into ordered and unordered lists in an ePub.

Map to Unordered Lists

If you choose Map to Unordered Lists, InDesign converts paragraphs styled with Bullets into <ul> elements, complete with <li> items. Seems good and it's what you'd expect.

Bullets exported with InDesign

But when you look at the CSS, you find that InDesign has missed a step. Though they convert the list to <ul> and <li> items, they leave the formatting assigned to <p> items.

bulleted list CSS from InDesign

As you might expect, the formatting is lost when you visualize the ePub (here on an iPad, but the same holds true in any eReader):

Bulleted list in iPad

If you choose not to Map to Unordered Lists, InDesign won't convert your lists to bulleted lists (<ul>) and instead leaves them as <p> items.

And since the CSS corresponds to <p> items, the formatting is now preserved:

No convert in iPad

So, you can either decide not to convert your lists in InDesign into actual lists in the ePub, or you can adjust your CSS manually by changing the selectors for the bulleted style so that they point to <li> items instead of <p> items.

Or you can wait for Adobe to fix the bug.

18 comments:

  1. Are you recommending that ePub books be created via InDesign-like tools, rather than XHTML directly?

    …and, I assume you can't recommend HTML editors by brand, but can you tell a novice the more subtle differences between, for example, TACO and BBedit? (I can't seem to get a live preview from the latter; have to "view in…"

    Or others you're familiar with? Perhaps you've already covered this question in a blog?

    ReplyDelete
  2. Brent,
    I think I'm going for a hybrid approach. Use InDesign for some serious document crunching, and then edit XHTML and CSS to achieve better code, and effects that InDesign doesn't yet support.

    I don't know TACO, but I'm a happy and longtime BBEdit user. Excellent GREP, which is really important with this stuff.

    ReplyDelete
  3. I have ID CS 3, and when I checked out epub-making a few weeks ago it seemed quite daunting: complex setup of all styles before hand, and even then the forums said things didn't always work. Is your (anxiously-awaited) new book going to cover InDesign too?

    (I'm doing text editing in Pages, which is easier than in ID.)

    ReplyDelete
  4. Yes, it covers InDesign too. Styling doesn't need to be complex, just make sure you use styles for EVERYTHING. No local formatting.

    ReplyDelete
  5. Hi Liz, am I glad to have found you! I'm having bullet problems as you describe here in CS5 because i don't see the option not to map to unordered lists? am I missing something?

    ReplyDelete
  6. @James... you mean you go to Export to ePub and click the General tab and it's not there? Can you send me a screenshot?

    ReplyDelete
  7. Hi Liz, happy to, but don't see an option to attach a file. That said after following your instructions (ie removing the "p." from the css) its working. The options I get for bullets in CS5 on Windows are only "map to unordered lists" or "convert to text", same as CS3 (I've skipped CS4)

    ReplyDelete
  8. You wrote:
    "or you can adjust your CSS manually by changing the selectors for the bulleted style so that they point to li items instead of p items."

    Just so I'm clear... in the template.css file, I remove the "p." from the name, and that'll fix it? i.e.
    p.bullet {
    to
    bullet {

    Thank you for your help. You're a great resource.

    ReplyDelete
  9. I removed the 'p.' from the 'bullet' but it didn't have any effect viewing it in Calibre's preview...

    Can I contact you offlist for a consultation?
    Thanks,
    Ben
    ben@dialogue.org

    ReplyDelete
  10. Do you know if this problem is fixed in CS5?

    ReplyDelete
  11. @Ben - You can either take the p away but leave the period

    .bullet {...}

    (this means apply these style rules to ANY element that has "bullet" as a class)

    or, add the li:

    li.bullet {...}

    (this means, apply these style rules to any li element that has "bullet" as a class)

    (more info in my HTML, XHTML, and CSS book :)

    ReplyDelete
  12. I spent about 45 minutes with Adobe tech, and at the end of it he admitted that there was likely a bug in In Design CS4 as well as CS5.

    I did go in and remove the 'p' from the bullet css (and changed the margins so they show correctly). Now the book views OK in calibre, but unfortunately doesn't view properly in Adobe Digital Editions, nor does Calibre send it to iTunes. The error I get is:

    ERROR: Error: Error communicating with device.

    Did I mess something up when modifying the css?

    ReplyDelete
  13. The Calibre Error details include:
    missing OCF container.xml file.

    Thanks.

    ReplyDelete
  14. Hi again,
    I also tried changing the p.bullet css entry to li.bullet, and while calibre was able to view it correctly (and the css style change worked), it still wasn't able to send it to iTunes, nor will it open in Digital Edition. Same error message. So close, and yet so far...

    ReplyDelete
  15. Hmm. Missing OCF container.xml file. That doesn't have anything to do with bulleted lists. Are you sure Calibre isn't doing something weird (or you are)? I've never seen InDesign not create the container.xml file. You should find it inside the META-INF folder.

    If it's not there. I'd recommend exporting the file anew from InDesign and then editing the code with a text editor. Let me know what you find.

    ReplyDelete
  16. You're right, the container.xml file is inside the META-INF folder. I wonder if it has something to do with the process I'm using. e.g. filename.epub
    1) change the name to filename.zip
    2) Use Unstuffit to unzip the file to a folder, filename.zip Folder
    3) Open the template.css file inside the OEBPS folder and edit/save it (using TextWrangler)
    4) Right-click on the filename.zip Folder and Compress it.
    5) Change the extension to .epub and import into Calibre.

    That's the version that gives me the error. Any clues?
    Thanks.

    ReplyDelete
  17. Hi Liz,
    Well, I think I've solved the problem. It ends up I was using the OSX Compress feature to create a zip/epub file, but it was compressing the files in the wrong order. This link:
    http://www.mobileread.com/forums/showthread.php?t=55681
    has an Applescript that takes a decompressed folder and Compresses it correctly. Changing the extension from .zip to .epub completes the process.

    FYI, I also found an excellent open-source epub editor, Sigil:
    http://code.google.com/p/sigil/

    Between these two, I now have an excellent-looking epub, especially the bullets, which were fixed when I changed the css item:
    p.bullet {
    to
    li.bullet {

    and changed all the margins to 0.

    ReplyDelete
  18. @Ben. Sorry, I thought you had my book and knew that already or I would have pointed it out ... there are detailed instructions for zipping an EPUB correctly therein.

    Also, I have gotten weird errors with Sigil. Many use it happily, I'm not one of them.

    Still, glad you're having success.

    ReplyDelete

More of my books