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 04-05-2011, 06:12 PM   #1
Hatgirl
Addict
Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.
 
Hatgirl's Avatar
 
Posts: 296
Karma: 955301
Join Date: Oct 2008
Device: Sony PRS-300, Sony PRS-T2, Kindle (7th Gen)
Applying multiple classes to an element

I am attempting to create a mobi format ebook by using kindlegen to convert an epub. I've managed to figure out the solution to most of the problems I've encountered, like preventing the cover appearing twice and adding guide items, but one problem has me stumped: it seems I can't apply multiple classes to an element.

So let's say this is an excerpt from my css file
Code:
p.italic {
    font-style: italic; 
}

p.bold {
    font-weight: bold;
}

And this is excerpt from the code in my xhtml file
Code:
<p>Oh, do you know the muffin man,</p>
<p class="italic">The muffin man, the muffin man,</p>
<p class="bold">Do you know the muffin man,</p>
<p class="italic bold">Who lives in Drury Lane?</p>

My epub looks like this:
Quote:
Oh, do you know the muffin man,
The muffin man, the muffin man,
Do you know the muffin man,
Who lives in Drury Lane?

But when I convert that epub to a mobi, it looks like this!
Quote:
Oh, do you know the muffin man,
The muffin man, the muffin man,
Do you know the muffin man,
Who lives in Drury Lane?

Aaaaarrrgghh! Can I seriously not apply multiple classes to an element?! Damn you, Amazon, I don't want to be spending my time dealing with this idiocy. Epub Rules, Mobi Drools!

There are obvious work arounds for this (just create a unique class like p.ihatemobi {font-style: italic; font-weight: bold;} ) but I'm hoping I'm wrong and you'll point out some comma or semi-colon I've missed out that will allow multiple classes
Hatgirl is offline   Reply With Quote
Old 04-05-2011, 08:06 PM   #2
ATDrake
Wizzard
ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.
 
Posts: 11,517
Karma: 33048258
Join Date: Mar 2010
Location: Roundworld
Device: Kindle 2 International, Sony PRS-T1, BlackBerry PlayBook, Acer Iconia
No, multiple classes do not work via KindleGen (unless this is one of the bugfixes for 1.2), and as you've noticed, it also completely ignores the first class used, which I think technically it should try to render under CSS fallback rules.

You also can't do descendant selectors, even the generic catchall type supported by CSS1, so if you want to style, say, all list items within a div of a certain class type (or even any div in general), you're going to have to mark up all those <li> or at least their containing <ol>/<ul> separately with target classes unless you're willing to have the style you want apply to everything within the parent <div> to save effort.

Those are just two of the many ways in which KindleGen in particular and the Mobi format in general are made of fail, lose, and frustration. I say this from bitter personal experience.

Hope this helps!
ATDrake is offline   Reply With Quote
Advert
Old 04-05-2011, 08:34 PM   #3
Hatgirl
Addict
Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.
 
Hatgirl's Avatar
 
Posts: 296
Karma: 955301
Join Date: Oct 2008
Device: Sony PRS-300, Sony PRS-T2, Kindle (7th Gen)
Quote:
Originally Posted by ATDrake View Post
No, multiple classes do not work via KindleGen (unless this is one of the bugfixes for 1.2), and as you've noticed, it also completely ignores the first class used, which I think technically it should try to render under CSS fallback rules.
Gah. I was afraid of that. So, is this a problem with Mobi or Kindlegen? If it's just a problem with Kindlegen, is there another epub->mobi tool out there I can use?

I know I could use Calibre to convert, but given that I have handcoded my precious epub, I want a bit more control over the behind-the-scenes code than Calibre will allow
Hatgirl is offline   Reply With Quote
Old 04-05-2011, 08:57 PM   #4
ATDrake
Wizzard
ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.
 
Posts: 11,517
Karma: 33048258
Join Date: Mar 2010
Location: Roundworld
Device: Kindle 2 International, Sony PRS-T1, BlackBerry PlayBook, Acer Iconia
It's a problem with KindleGen*. If you were to do your .ihatemobi class, it would work perfectly well as things can be styled multiple ways at once. You just can't have multiple separate class instructions for styling them so, at least not all on the same tag.

The only Mobi conversion tools that I'm aware of are
  • KindleGen (including the Kindle Previewer variant)
  • Mobipocket Creator (with all the limitations of KindleGen and more!)
  • Calibre
  • Mobi2Mobi (does not handle Unicode, your book will have to be in Windows-1252 encoding and use escaped entities for any special characters)
  • the Perl Ebook-Tools package (front-end wrapper for mobigen/kindlegen and other command-line converters)
  • Stanza (pitifully bad as a simple e-book reader, consensus seem to be that its conversion produces crap)
Unfortunately, I guess you have a choice between ceding control to Calibre, or cluttering up your source to compensate for KindleGen†.

* Now, if you were to try and indent a right-hand margin and failed, that would be totally Mobi's fault…

† Don't forget that newer versions of KindleGen add bloat in the form of the complete source files to your Mobi and you should use Kindlestrip to fix that.

On the other hand, at least people would be able to admire your handcoding work?
ATDrake is offline   Reply With Quote
Old 04-06-2011, 04:31 AM   #5
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,516
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
I believe Calibre does some "CSS flattening" step in conversions, maybe you can convert your ePUB to ePUB (or something else) with Calibre, making sure the CSS is processed and flattened, and then convert to mobi with KindleGen or whatever.

Quote:
I know I could use Calibre to convert, but given that I have handcoded my precious epub, I want a bit more control over the behind-the-scenes code than Calibre will allow
But I'm sure Calibre allows more control than KindleGen...
Jellby is offline   Reply With Quote
Advert
Old 04-06-2011, 07:06 AM   #6
Hatgirl
Addict
Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.
 
Hatgirl's Avatar
 
Posts: 296
Karma: 955301
Join Date: Oct 2008
Device: Sony PRS-300, Sony PRS-T2, Kindle (7th Gen)
Quote:
Originally Posted by Jellby View Post
I believe Calibre does some "CSS flattening" step in conversions, maybe you can convert your ePUB to ePUB (or something else) with Calibre, making sure the CSS is processed and flattened, and then convert to mobi with KindleGen or whatever.

But I'm sure Calibre allows more control than KindleGen...
When I crack open the new epub Calibre produces from my epub, it has been altered rather radically internally, so that makes me wary of using Calibre for the mobi processing (not that I'm dissing Calibre. Love the thing for organising my collection, it's just not my cup of tea for converting).


I think I'll just have to make fat classes when I code my epubs. That will actually also solve the same problem I was having with the nasy, cheap, spare Binatone LCD eReader I have that runs FBReader. *sigh* Oh well, at least I've identified the problem, that's half the battle
Hatgirl is offline   Reply With Quote
Old 04-06-2011, 09:48 AM   #7
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,549
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
No, multiple classes do not work via KindleGen (unless this is one of the bugfixes for 1.2)
No, it's not addressed in 1.2. But thankfully, this thread has allowed me to at least identify the wall that I've been pounding my head against for so long.

Now me and my sore head can take a new tack.
DiapDealer is online now   Reply With Quote
Old 04-06-2011, 11:44 AM   #8
susan_cassidy
Wizard
susan_cassidy ought to be getting tired of karma fortunes by now.susan_cassidy ought to be getting tired of karma fortunes by now.susan_cassidy ought to be getting tired of karma fortunes by now.susan_cassidy ought to be getting tired of karma fortunes by now.susan_cassidy ought to be getting tired of karma fortunes by now.susan_cassidy ought to be getting tired of karma fortunes by now.susan_cassidy ought to be getting tired of karma fortunes by now.susan_cassidy ought to be getting tired of karma fortunes by now.susan_cassidy ought to be getting tired of karma fortunes by now.susan_cassidy ought to be getting tired of karma fortunes by now.susan_cassidy ought to be getting tired of karma fortunes by now.
 
Posts: 2,251
Karma: 3720310
Join Date: Jan 2009
Location: USA
Device: Kindle, iPad (not used much for reading)
Why don't you try changing that line to use a single bold, italic class (both attributes), and see if that converts?
susan_cassidy is offline   Reply With Quote
Old 04-06-2011, 12:25 PM   #9
Hatgirl
Addict
Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.
 
Hatgirl's Avatar
 
Posts: 296
Karma: 955301
Join Date: Oct 2008
Device: Sony PRS-300, Sony PRS-T2, Kindle (7th Gen)
Quote:
Originally Posted by susan_cassidy View Post
Why don't you try changing that line to use a single bold, italic class (both attributes), and see if that converts?
Oh, it does (see the .ihatemobi class I mention in my first post). It's a legitimate workaround. But we shouldn't have to be finding workarounds, we should just be able to write code that complies with the W3C specs and have it bloody work
Hatgirl is offline   Reply With Quote
Old 04-06-2011, 12:52 PM   #10
DaleDe
Grand Sorcerer
DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.
 
DaleDe's Avatar
 
Posts: 11,470
Karma: 13095790
Join Date: Aug 2007
Location: Grass Valley, CA
Device: EB 1150, EZ Reader, Literati, iPad 2 & Air 2, iPhone 7
Quote:
Originally Posted by Hatgirl View Post
Oh, it does (see the .ihatemobi class I mention in my first post). It's a legitimate workaround. But we shouldn't have to be finding workarounds, we should just be able to write code that complies with the W3C specs and have it bloody work
that will never happen. W3C is for a web browser, not an eBook reader. It would be more reasonable to ask for something that complies with ePUB spec which would have been ok for this problem. Amazon seems to be actively changing Kindlegen to be better at doing ePUB conversions so at some point they may fix this particular problem but so long as they hang on to Mobi/AZW format there will be some things that will never work.

Dale
DaleDe is offline   Reply With Quote
Old 04-06-2011, 01:23 PM   #11
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,516
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by Hatgirl View Post
It's a legitimate workaround. But we shouldn't have to be finding workarounds, we should just be able to write code that complies with the W3C specs and have it bloody work
Since mobi does not understand CSS at all, whatever you do with CSS must be converted into mobi-speak, and if it doesn't it's entirely the converter's fault, and a different converter might work differently.

If you don't like Calibre output (which I understand), maybe you can find something else that just processes the CSS and "flattens" it. It's quite likely there are other legitimate CSS construct (selectors, precedence...) that confuse KindleGen, and flattening the CSS would be a desirable pre-convert step.
Jellby is offline   Reply With Quote
Old 04-06-2011, 02:53 PM   #12
Hatgirl
Addict
Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.Hatgirl ought to be getting tired of karma fortunes by now.
 
Hatgirl's Avatar
 
Posts: 296
Karma: 955301
Join Date: Oct 2008
Device: Sony PRS-300, Sony PRS-T2, Kindle (7th Gen)
What makes me so cross is that Amazon insist in selling in mobi format. OK, fine. Their choice. But they specifically state that Kindlegen can "convert HTML, XHTML, XML (OPF/IDPF format), or ePub source into a Kindle Book."

The specs for HTML, ePub and the rest are available to them. The details of how mobi works are not available to us. The onus is on the people who insist on the black box format to make sure their conversion program can actually handle the input they claim it can, or to at the very least to describe what can't be converted. We, the users, shouldn't be forced to jam combination after combination through their meatgrinder to find out what does and doesn't work

It's... it's... it's... it's just bloody rude, is what it is.
Hatgirl is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
keeping or removing a div with multiple classes JohnsonZA Recipes 1 09-25-2010 10:33 AM
iLiad Applying DR GTK+ patches to iLiad ericshliao iRex Developer's Corner 16 03-14-2010 05:39 AM
Amazon applying for in-book advertisement patent for Kindle dreams News 57 07-13-2009 11:52 AM
Applying Calibre recipes to a folder of pre-existing HTML files MattK Calibre 3 09-24-2008 01:15 PM
Applying hacks without flashing (brick save) mkaluza Sony Reader Dev Corner 3 08-26-2008 04:45 AM


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


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