Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Conversion

Notices

Reply
 
Thread Tools Search this Thread
Old 08-04-2020, 05:57 PM   #1
etihwmot
Junior Member
etihwmot began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Aug 2020
Device: android
html to EPUB - added class into <html> tag

I'm converting a pretty clean .html file into EPUB using Calibre 4.20 and have run into a validation problem. The EPUB 'works' fine on my test reading apps/devices, but it does not validate due to:

class="calibre" being inserted into the <html> tag, with the resulting string in each chapter split file:

<html xmlns="http://www.w3.org/1999/xhtml" class="calibre">

Now, I can go in and edit the 30+ chapter files and remove the offending string, but I'd like to know how it got there in the first place!

Tom
interestingly, Amazon and Kobo didn't mind the EPUB, it was Apple that was fussy and forced me to validate the code.
etihwmot is offline   Reply With Quote
Old 08-04-2020, 07:13 PM   #2
hobnail
Running with scissors
hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.
 
Posts: 1,553
Karma: 14325282
Join Date: Nov 2019
Device: none
You could use the calibre editor and select all of the html / xhtml files and using a search and replace, replace
Code:
<html .* class="calibre">
with
Code:
<html xmlns="http://www.w3.org/1999/xhtml">
For converting html to epub I prefer to start with a new / blank epub and add an html / xhtml file for each chapter and select and copy each chapter in the html file (if they're in separate files then select what's between the body tags) and paste it between the body tags in each html / xhtml file in the epub. As you've discovered, converting can introduce problems.

Last edited by hobnail; 08-04-2020 at 07:21 PM.
hobnail is offline   Reply With Quote
Advert
Old 08-04-2020, 07:17 PM   #3
jhowell
Grand Sorcerer
jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.
 
jhowell's Avatar
 
Posts: 6,630
Karma: 85000001
Join Date: Nov 2011
Location: Tampa Bay, Florida
Device: Kindles
Quote:
Originally Posted by etihwmot View Post
<html xmlns="http://www.w3.org/1999/xhtml" class="calibre">
I don't see anything obviously wrong with that code. What is the validation error?

Quote:
Originally Posted by etihwmot View Post
...I'd like to know how it got there in the first place!
Conversion by calibre reorganizes CSS styles and assigns class names that start with "calibre".
jhowell is offline   Reply With Quote
Old 08-04-2020, 07:28 PM   #4
etihwmot
Junior Member
etihwmot began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Aug 2020
Device: android
Quote:
Originally Posted by jhowell View Post
I don't see anything obviously wrong with that code. What is the validation error?
CSS styles/attributes shouldn't be in the <html> tag. And there's none in my .html file before sticking it through Calibre. Here's the error:

Error while parsing file: attribute "class" not allowed here; expected attribute "dir", "lang", "version" or "xml:lang"

The error makes sense to me, but Calibre adding a styling attribute where there were none, does not.
etihwmot is offline   Reply With Quote
Old 08-04-2020, 07:31 PM   #5
hobnail
Running with scissors
hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.
 
Posts: 1,553
Karma: 14325282
Join Date: Nov 2019
Device: none
Quote:
Originally Posted by etihwmot View Post
CSS styles/attributes shouldn't be in the <html> tag.
As jhowell said, that class on the html tag is valid. You don't often see that but it's ok. Try running it through an epub validator and it should pass. It's Apple that's making it a problem.

Last edited by hobnail; 08-04-2020 at 07:35 PM.
hobnail is offline   Reply With Quote
Advert
Old 08-04-2020, 07:32 PM   #6
etihwmot
Junior Member
etihwmot began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Aug 2020
Device: android
Quote:
Originally Posted by hobnail View Post
You could use the calibre editor ....
Good point about using calibre's editor - I always work in a text editor, so hadn't thought of it.

I don't want to go down the route of not trusting the conversion. My files are super clean and light and calibre does exactly what I need with a coupla clicks.
etihwmot is offline   Reply With Quote
Old 08-04-2020, 07:37 PM   #7
hobnail
Running with scissors
hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.
 
Posts: 1,553
Karma: 14325282
Join Date: Nov 2019
Device: none
Here's the standard/official validator for Calibre that you can use:

https://www.mobileread.com/forums/sh...ight=validator

You should always check your epubs with that before you submit them to amazon, et. al.

Last edited by hobnail; 08-04-2020 at 07:40 PM.
hobnail is offline   Reply With Quote
Old 08-04-2020, 07:42 PM   #8
etihwmot
Junior Member
etihwmot began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Aug 2020
Device: android
Quote:
Originally Posted by hobnail View Post
As jhowell said, that class on the html tag is valid. You don't often see that but it's ok. Try running it through an epub validator and it should pass. It's Apple that's making it a problem.
Your pre-edit was right - the html is valid. But your post edit is what I'd done to check Apple's error-finding. I stuck it through epub validator on ebookit's site, and it flagged the same issues.

But that doesn't mean it isn't Apple messing it up by being weird, and then the validator following suit. I'm used to having to add extra shizzle for Apple systems, and having Apple ignore stuff, but I've never had to remove something to get it to work.
etihwmot is offline   Reply With Quote
Old 08-04-2020, 07:44 PM   #9
etihwmot
Junior Member
etihwmot began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Aug 2020
Device: android
Quote:
Originally Posted by hobnail View Post
Here's the standard/official validator for Calibre that you can use:

https://www.mobileread.com/forums/sh...ight=validator

You should always check your epubs with that before you submit them to amazon, et. al.
I do not have java running on this machine, so can't run that plugin for now.

But thanks for the responses, you and jhowell have been useful!
etihwmot is offline   Reply With Quote
Old 08-04-2020, 07:47 PM   #10
hobnail
Running with scissors
hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.
 
Posts: 1,553
Karma: 14325282
Join Date: Nov 2019
Device: none
Quote:
Originally Posted by etihwmot View Post
I do not have java running on this machine, so can't run that plugin for now.

But thanks for the responses, you and jhowell have been useful!
The installation instructions for java may sound a bit hairy but it's really no big deal. And that calibre plugin is using the validator that is the official one.
hobnail is offline   Reply With Quote
Old 08-04-2020, 08:41 PM   #11
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 75,407
Karma: 133807966
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
@etihwmot go into the Calibre editor and go to Edit > Preferences > Integration with Calibre and uncheck Update metadata embedded in the book when opening. This will prevent the editor from making any changes to your ePub when opening them in the editor and all changes will be done by you.

And you do not need to use a text editor after this change is made.
JSWolf is offline   Reply With Quote
Old 08-04-2020, 08:43 PM   #12
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 75,407
Karma: 133807966
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by hobnail View Post
Here's the standard/official validator for Calibre that you can use:

https://www.mobileread.com/forums/sh...ight=validator

You should always check your epubs with that before you submit them to amazon, et. al.
I use both the Calibre editor's validater and epubcheck and make sure both say there are no errors. I do sometimes let warnings go with the Calibre validater but that's my choice.
JSWolf is offline   Reply With Quote
Old 08-04-2020, 08:44 PM   #13
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 75,407
Karma: 133807966
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by etihwmot View Post
I do not have java running on this machine, so can't run that plugin for now.

But thanks for the responses, you and jhowell have been useful!
If you do install Java, go for the 64-bit version if you are running a 64-bit OS as there are less problems with the 64-bit Java.
JSWolf is offline   Reply With Quote
Old 08-04-2020, 10:24 PM   #14
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,205
Karma: 23446406
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
calibre only inserts a class on html if there are some styles applied to html in the input document.
kovidgoyal is offline   Reply With Quote
Old 08-05-2020, 11:30 AM   #15
etihwmot
Junior Member
etihwmot began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Aug 2020
Device: android
Quote:
Originally Posted by JSWolf View Post
@etihwmot go into the Calibre editor and go to Edit > Preferences > Integration with Calibre and uncheck Update metadata embedded in the book when opening. This will prevent the editor from making any changes to your ePub when opening them in the editor and all changes will be done by you.

And you do not need to use a text editor after this change is made.
Thanks for the heads up on this!
etihwmot is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
html img tag versus svg wrapped image tag hobnail ePub 8 02-27-2020 03:16 AM
HTML to epub disable class change chittu Calibre 1 12-25-2013 01:33 PM
html to epub CLI conversion / html input m4mmon Conversion 2 05-05-2012 02:10 AM
Conversionproblems from HTML to ePub with the <pre>-Tag matthias2011 Conversion 16 07-29-2011 08:47 AM
Calibre Recipe HTML content differs from raw html of index.html. krunk Calibre 4 09-20-2010 09:48 PM


All times are GMT -4. The time now is 07:54 PM.


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