06-11-2018, 07:45 PM | #1 |
Member
Posts: 10
Karma: 116
Join Date: May 2011
Device: Multiple
|
Calibre changes HTML markup during convert
Running Calibre 3.13 and when I "Convert books" to EPUB much of my markup changes. Some code I have added to stylesheet.css is removed.
And, it completely removed a file (TableOfContents.html) which seems to be lost forever. |
06-11-2018, 09:25 PM | #2 | |
Well trained by Cats
Posts: 29,800
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
AFAIK, calibre only uses what is linked. AND you DO NOT want calibre to replace the TOC There are so many settings. Remember ! Preferences: ... is the DEFAULT that is used for the INITIAL conversion. Once used, the book retains the settings that were used (may be modified on the conversion start). Fro then on, the Conversion screen shows the settings that were used previously. This is PER BOOK There is a button (tick in bulk mode) to cause conversion to forget, and grab a fresh 'default' |
|
06-11-2018, 09:37 PM | #3 |
creator of calibre
Posts: 43,856
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
The only way calibre will completely remove a file is if you incorrectly marked it as the titlepage or it is not in the spine.
As for removing CSS, calibre completely rewrites all css, flattening it and keeping only the CSS that actually applies to your markup. |
06-11-2018, 09:44 PM | #4 | |
Member
Posts: 10
Karma: 116
Join Date: May 2011
Device: Multiple
|
Quote:
My biggest challenge at the moment is having my HTML markup changed when I run "Convert Book" (to EPUB). I add markup like <span id="chap1-2">some text </span> and after the conversion runs and I "Edit Book," the <span... markup is removed. Also, I will add <p class="bodyText"> to the beginning of each paragraph and after "Convert Book" that markup is changed to <p class="calibre7"> and the bodyText rule is removed from the css file. |
|
06-11-2018, 11:09 PM | #5 |
Grand Sorcerer
Posts: 12,166
Karma: 73448616
Join Date: Nov 2007
Location: Toronto
Device: Nexus 7, Clara, Touch, Tolino EPOS
|
I hate to be the bearer of bad news but if you do a conversion, calibre will rewrite / merge all the CSS and assign the new classes its own names.
Sent from my Nexus 7 using Tapatalk |
06-12-2018, 12:42 AM | #6 | |
Member
Posts: 10
Karma: 116
Join Date: May 2011
Device: Multiple
|
Quote:
I am not attached to the css classes I name, however I am very partial to the markup that is being removed completely. I am using the following markup to identify specific sub-headings in the text that are linked to the table of contents I created in TableOfContents.html, e.g.: excerpt from TableOfContents.html: <p class="toc-level1"><a href="chapter-1.html#chap1-3">Checking Goals at the Door</a></p> excerpt from chapter-1.html: <p class="subhead"><span id="chap1-3">Checking Goals at the Door</span></p> Oddly, the Calibri conversion process does not change the subhead class but it removes the span tags completely. Hence, my strategy to link my table of contents via HTML is foiled. excerpt from chapter1.html, post-conversion: <p class="subhead">Checking Goals at the Door</p> |
|
06-12-2018, 12:45 AM | #7 | |
Member
Posts: 10
Karma: 116
Join Date: May 2011
Device: Multiple
|
Quote:
I am not attached to the css classes I name, however I am very partial to the markup that is being removed completely. I am using the following markup to identify specific sub-headings in the text that are linked to the table of contents I created in TableOfContents.html, e.g.: excerpt from TableOfContents.html: <p class="toc-level1"><a href="chapter-1.html#chap1-3">Checking Goals at the Door</a></p> excerpt from chapter-1.html: <p class="subhead"><span id="chap1-3">Checking Goals at the Door</span></p> Oddly, the Calibri conversion process does not change the subhead class but it removes the span tags completely. Hence, my strategy to link my table of contents via HTML is foiled. excerpt from chapter1.html, post-conversion: <p class="subhead">Checking Goals at the Door</p> |
|
06-12-2018, 12:57 AM | #8 |
creator of calibre
Posts: 43,856
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
I dont see how calibre could possibly be removing span tags, unless you have set some conversion setting telling it to do so, such as heuristics or serach and replace, etc.
In any case those span tag are completely superflous, simply put your id on the <p> tag and you can link to it just the same. |
06-12-2018, 01:25 AM | #9 | |
Bibliophagist
Posts: 35,393
Karma: 145435140
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Quote:
As suggested, using <p class="subhead" id="chap1-3"> would be cleaner. If you really want to use the spans, something like <span class="dummy" id="chap1-3"> would survive the conversion process. Last edited by DNSB; 06-12-2018 at 01:27 AM. |
|
06-12-2018, 01:52 AM | #10 |
Bibliophagist
Posts: 35,393
Karma: 145435140
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Interesting. I added a span with a id to a test epub and then converted it from epub to epub. Not only was a span with an id not removed, it had a class added. My theory about the spans being removed seems to have been shot down. Calibre 3.25, BTW.
Original epub: Code:
<body class="epub"> <p class="paranon"><span id="tarfu_1.3">This is a sample ebook with a few lines of text though it's hard to say what is actually a line of text when font size, screen width, margin size are variables beyond the control of the author. Of course, we could go to absolute measurements if we really want odd effects. EOT</span></p> </body> Code:
<body class="epub"> <p class="paranon"><span id="tarfu_1.3" class="calibre">This is a sample ebook with a few lines of text though it's hard to say what is actually a line of text when font size, screen width, margin size are variables beyond the control of the author. Of course, we could go to absolute measurements if we really want odd effects. EOT</span></p> </body> Code:
.calibre { line-height: 1.2 } |
06-12-2018, 01:53 AM | #11 |
Member
Posts: 10
Karma: 116
Join Date: May 2011
Device: Multiple
|
Thanks, again, kovidgoyal,
Heuristics is turned off and there are no search and replace rules. I put the id in the <p> tag, as you suggested, and the id was retained in the first occurrence and removed in subsequent occurrences. This time, I named my table of contents file "Contents.html" and confirmed that it was included in content.opf. However, after conversion, Contents.html was removed. |
06-12-2018, 01:56 AM | #12 |
Member
Posts: 10
Karma: 116
Join Date: May 2011
Device: Multiple
|
Thank you, David,
Good suggestion to put the id in the <p> tag. I put the id in the <p> tag, as you suggested, and the id was retained in the first occurrence and removed in subsequent occurrences. This time, I named my table of contents file "Contents.html" and confirmed that it was included in content.opf. However, after conversion, Contents.html was removed. |
06-12-2018, 02:45 AM | #13 |
creator of calibre
Posts: 43,856
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Including it in content.opf is not enough you need to put it in the spine. Anyway, it's too difficult trying to guess what you are doing wrong, see https://www.mobileread.com/forums/sh...d.php?t=186697 for how to provide enough information to get useful answers.
Last edited by kovidgoyal; 06-12-2018 at 09:01 AM. |
Tags |
calibre, convert, css, html, markup |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Calibre convert Chinese PDF to EPUB well, but not TXT and HTML | jimmyzou | ePub | 15 | 12-27-2013 04:02 PM |
Calibre convert to html | 247wd | Calibre | 3 | 11-28-2013 02:48 AM |
Calibre does not convert HTML to MOBI completely | perchiper | Conversion | 1 | 09-03-2011 10:10 AM |
[Old Thread] unable to convert ebooks(rtf, txt,lit,html,pdf) to lrf in calibre .4.131 | jackdeth191 | Calibre | 9 | 05-02-2009 02:55 AM |
Why does Calibre need to go to the web to convert a zipped HTML file? | FizzyWater | Calibre | 4 | 06-30-2008 12:51 AM |