Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 05-20-2020, 08:32 PM   #1
spartanhooah
Member
spartanhooah began at the beginning.
 
Posts: 19
Karma: 10
Join Date: May 2020
Device: Kobo Clara HD
Question Create table of contents with CSS tags

I found the nicely-documented Auto-create a table of contents function, but that requires the chapter headings be simple <h/> tags. I've got a book where the chapter headings look like this:
Code:
<p class="calibre4">
    <span class="calibre3">
        <strong class="calibre5">
            <span lang="EN-US">Chapter 2</span>
        </strong>
        <span lang="EN-US"></span>
    </span>
</p>
Is there a way to adapt the example function to work in this instance?
spartanhooah is offline   Reply With Quote
Old 05-20-2020, 08:38 PM   #2
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,812
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
I simply REGEX that kind of mess into
<h3 class="chapno">\1</h3>

Where .chapno (CSS) contains the consolidated styling of those 3 cascaded classes
theducks is offline   Reply With Quote
Old 05-20-2020, 08:39 PM   #3
spartanhooah
Member
spartanhooah began at the beginning.
 
Posts: 19
Karma: 10
Join Date: May 2020
Device: Kobo Clara HD
Oohhh, that's a good idea.
spartanhooah is offline   Reply With Quote
Old 05-20-2020, 08:44 PM   #4
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,812
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Visually, it looks the same, but now the Auto-tools work

BTW I use H3 for chapters, H2 for Parts (when needed), H1 for Titles in Anthologies
Since you are using stylesheets, the H level is stylistically meaningless
theducks is offline   Reply With Quote
Old 05-20-2020, 09:07 PM   #5
spartanhooah
Member
spartanhooah began at the beginning.
 
Posts: 19
Karma: 10
Join Date: May 2020
Device: Kobo Clara HD
I just realized another possible snag: this e-book is split across four HTML files. Is there any reason I shouldn't combine them all before running the table of contents function?
spartanhooah is offline   Reply With Quote
Old 05-20-2020, 10:00 PM   #6
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,812
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:
Originally Posted by spartanhooah View Post
I just realized another possible snag: this e-book is split across four HTML files. Is there any reason I shouldn't combine them all before running the table of contents function?
Nope.
The beauty of using an e-book editor is that it is aware of the structure.
All that is needed is the files are in the proper order within the book (file) browser
theducks is offline   Reply With Quote
Old 05-20-2020, 10:24 PM   #7
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 35,498
Karma: 145557716
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by spartanhooah View Post
I just realized another possible snag: this e-book is split across four HTML files. Is there any reason I shouldn't combine them all before running the table of contents function?
Personally, I would suggest merging the files and then splitting the one file into multiple files at chapter boundaries.
DNSB is offline   Reply With Quote
Old 05-20-2020, 10:39 PM   #8
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,812
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
I believe these are already split properly as the OP said Line 14 of each, so this is not needed in THIS case
theducks is offline   Reply With Quote
Old 05-20-2020, 11:51 PM   #9
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 35,498
Karma: 145557716
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Is that a reference to estevam's posts in the Sigil regex thread? That's the only line 14 reference that comes to mind in the recent past. The OP in this thread has 3 posts all in this thread.
DNSB is offline   Reply With Quote
Old 05-21-2020, 12:09 AM   #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,552
Karma: 14325282
Join Date: Nov 2019
Device: none
Another way to accomplish what theducks said about a regular expression is to use the plugin Diaps editing toolbag. With it you can delete the outer p, span, and strong, and then convert the span around the chapter title to h3. When cleaning up books from Gutenberg I nuke all of their classes and whatnot, merge the files like DNSB said, copy everything between the body tags and paste it into a new file, then in that split on the h3 or whatever tags.
hobnail is offline   Reply With Quote
Old 05-21-2020, 09:47 PM   #11
spartanhooah
Member
spartanhooah began at the beginning.
 
Posts: 19
Karma: 10
Join Date: May 2020
Device: Kobo Clara HD
Alright, I'll go the merge route. Any gotchas to look out for that may not be obvious?
spartanhooah is offline   Reply With Quote
Old 05-21-2020, 10:02 PM   #12
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 35,498
Karma: 145557716
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by spartanhooah View Post
Alright, I'll go the merge route. Any gotchas to look out for that may not be obvious?
I'd make sure that you have no significant errors in the files before merging. If you don't have the epubcheck plugin, I'd install and use it as well the the builtin checker. Some errors won't affect the merge process but I've had a couple of times where merging files with errors in those files produced total garbage as the output file.
DNSB is offline   Reply With Quote
Reply

Tags
css classes, table of contents


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Create and use my Table of Contents hymie Conversion 13 03-29-2020 11:30 PM
How can I create subsections in Table of Contents SampleAndy Sigil 3 05-18-2017 05:42 PM
how to create Table of Contents? Small Elephant Amazon Kindle 2 11-17-2012 01:17 AM
Create a table of contents? RobLikesBrunch Amazon Kindle 13 03-09-2009 07:59 PM
Is there a way to create a table of contents for notes timezone iRex 0 08-03-2008 03:54 PM


All times are GMT -4. The time now is 05:28 AM.


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