05-20-2020, 08:32 PM | #1 |
Member
Posts: 19
Karma: 10
Join Date: May 2020
Device: Kobo Clara HD
|
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> |
05-20-2020, 08:38 PM | #2 |
Well trained by Cats
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 |
05-20-2020, 08:39 PM | #3 |
Member
Posts: 19
Karma: 10
Join Date: May 2020
Device: Kobo Clara HD
|
Oohhh, that's a good idea.
|
05-20-2020, 08:44 PM | #4 |
Well trained by Cats
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 |
05-20-2020, 09:07 PM | #5 |
Member
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?
|
05-20-2020, 10:00 PM | #6 | |
Well trained by Cats
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:
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 |
|
05-20-2020, 10:24 PM | #7 |
Bibliophagist
Posts: 35,498
Karma: 145557716
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Personally, I would suggest merging the files and then splitting the one file into multiple files at chapter boundaries.
|
05-20-2020, 10:39 PM | #8 |
Well trained by Cats
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
|
05-20-2020, 11:51 PM | #9 |
Bibliophagist
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.
|
05-21-2020, 12:09 AM | #10 |
Running with scissors
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.
|
05-21-2020, 09:47 PM | #11 |
Member
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?
|
05-21-2020, 10:02 PM | #12 |
Bibliophagist
Posts: 35,498
Karma: 145557716
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
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.
|
Tags |
css classes, table of contents |
|
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 |