08-04-2020, 05:57 PM | #1 |
Junior Member
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. |
08-04-2020, 07:13 PM | #2 |
Running with scissors
Posts: 1,555
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"> Code:
<html xmlns="http://www.w3.org/1999/xhtml"> Last edited by hobnail; 08-04-2020 at 07:21 PM. |
Advert | |
|
08-04-2020, 07:17 PM | #3 |
Grand Sorcerer
Posts: 6,670
Karma: 86234809
Join Date: Nov 2011
Location: Charlottesville, VA
Device: Kindles
|
I don't see anything obviously wrong with that code. What is the validation error?
Conversion by calibre reorganizes CSS styles and assigns class names that start with "calibre". |
08-04-2020, 07:28 PM | #4 | |
Junior Member
Posts: 8
Karma: 10
Join Date: Aug 2020
Device: android
|
Quote:
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. |
|
08-04-2020, 07:31 PM | #5 |
Running with scissors
Posts: 1,555
Karma: 14325282
Join Date: Nov 2019
Device: none
|
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. |
Advert | |
|
08-04-2020, 07:32 PM | #6 |
Junior Member
Posts: 8
Karma: 10
Join Date: Aug 2020
Device: android
|
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. |
08-04-2020, 07:37 PM | #7 |
Running with scissors
Posts: 1,555
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. |
08-04-2020, 07:42 PM | #8 | |
Junior Member
Posts: 8
Karma: 10
Join Date: Aug 2020
Device: android
|
Quote:
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. |
|
08-04-2020, 07:44 PM | #9 | |
Junior Member
Posts: 8
Karma: 10
Join Date: Aug 2020
Device: android
|
Quote:
But thanks for the responses, you and jhowell have been useful! |
|
08-04-2020, 07:47 PM | #10 |
Running with scissors
Posts: 1,555
Karma: 14325282
Join Date: Nov 2019
Device: none
|
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.
|
08-04-2020, 08:41 PM | #11 |
Resident Curmudgeon
Posts: 75,810
Karma: 134321338
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. |
08-04-2020, 08:43 PM | #12 | |
Resident Curmudgeon
Posts: 75,810
Karma: 134321338
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
|
|
08-04-2020, 08:44 PM | #13 |
Resident Curmudgeon
Posts: 75,810
Karma: 134321338
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
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.
|
08-04-2020, 10:24 PM | #14 |
creator of calibre
Posts: 44,312
Karma: 23661992
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.
|
08-05-2020, 11:30 AM | #15 | |
Junior Member
Posts: 8
Karma: 10
Join Date: Aug 2020
Device: android
|
Quote:
|
|
|
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 |