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 09-29-2024, 11:37 AM   #1
foosion
Evangelist
foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.
 
Posts: 431
Karma: 41524
Join Date: Sep 2011
Device: Kobo Libra 2 & Clara BW
TOC h2: h3

If I have an ebook where chapter titles are

Code:
<h2>Chapter 1</h2>
<h3>Title of C1</h3>
how do I create a TOC of the form

Code:
Chapter 1: Title of C1
?

Generate TOC from headings doesn't quite do this.

I feel I'm missing something obvious.

EDIT: Is there a way to have the TOC be a bit different from the text in the heading, for example "1: Title" while in the text it's "Chapter 1: Title". Or to add a word throughout the TOC.

Last edited by foosion; 09-29-2024 at 03:04 PM.
foosion is offline   Reply With Quote
Old 09-29-2024, 02:24 PM   #2
jjk
Enthusiast
jjk began at the beginning.
 
Posts: 46
Karma: 10
Join Date: Aug 2018
Location: Paris (France)
Device: Kobo Kindle Vivlio-Inkpad3
Why not write simply this :
Code:
<h2>Chapter 1<br/><span class="small">Title of C1</small></h2>
...
<h2>Chapter 2<br/><span class="small">Title of C2</small></h2>
...
with in styles.css :
Code:
span.small{
  font-size: 90%;
/* or the whole character format you want to give to h3 */
}
jjk is offline   Reply With Quote
Advert
Old 09-29-2024, 03:03 PM   #3
foosion
Evangelist
foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.
 
Posts: 431
Karma: 41524
Join Date: Sep 2011
Device: Kobo Libra 2 & Clara BW
That's basically what I ended up doing. I was hoping there was a way to combine different headings.

I edited the OP to ask another question.
foosion is offline   Reply With Quote
Old 09-29-2024, 03:13 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: 30,440
Karma: 58055868
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
<h2 class-"whatever" title="the real words for the TOC">

A little REGEXfoo and you can build the title= bit
theducks is offline   Reply With Quote
Old 09-29-2024, 03:14 PM   #5
Karellen
Wizard
Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.
 
Karellen's Avatar
 
Posts: 1,351
Karma: 6794938
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
I normally use...

PHP Code:
<h2>My Heading</h2>
<
class="chapterh2">My Sub heading</p
That way I can style the sub heading separately to the main heading

For your second question, use the title="" property

PHP Code:
<h2 title="1 - Title">Chapter 1 Big Title</h2
Karellen is offline   Reply With Quote
Advert
Old 09-29-2024, 03:32 PM   #6
foosion
Evangelist
foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.
 
Posts: 431
Karma: 41524
Join Date: Sep 2011
Device: Kobo Libra 2 & Clara BW
Quote:
Originally Posted by theducks View Post
<h2 class-"whatever" title="the real words for the TOC">

A little REGEXfoo and you can build the title= bit
What does "title=" do? When I look all I can find is <title>.

My regex was:
Search:
Code:
<p class="cn" id=".*?">(.*?)</p>\
<p class="ct">(.*?)</p>
Replace:
Code:
<h2>\1: \2</h2>
If there were a useful index I might have kept the ids, but word search seems as good.
foosion is offline   Reply With Quote
Old 09-29-2024, 03:35 PM   #7
foosion
Evangelist
foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.
 
Posts: 431
Karma: 41524
Join Date: Sep 2011
Device: Kobo Libra 2 & Clara BW
Quote:
Originally Posted by Karellen View Post
I normally use...

PHP Code:
<h2>My Heading</h2>
<
class="chapterh2">My Sub heading</p
That way I can style the sub heading separately to the main heading

For your second question, use the title="" property

PHP Code:
<h2 title="1 - Title">Chapter 1 Big Title</h2
Doesn't that just put "My Heading" into the TOC?

Please explain or link the title="" property. As I mention above, when I search I just find <title>.
foosion is offline   Reply With Quote
Old 09-29-2024, 03:50 PM   #8
Karellen
Wizard
Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.
 
Karellen's Avatar
 
Posts: 1,351
Karma: 6794938
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
Quote:
Originally Posted by foosion View Post
Doesn't that just put "My Heading" into the TOC?
Yes. Sorry. I missed the crux of your comment. Then I would use the title="" attribute for the full TOC entry.
PHP Code:
<h2 title="My Heading - My Sub heading">My Heading</h2>
<
class="chapterh2">My Sub heading</p
Quote:
Originally Posted by foosion View Post
Please explain or link the title="" property. As I mention above, when I search I just find <title>.
https://www.w3schools.com/tags/att_global_title.asp
Karellen is offline   Reply With Quote
Old 09-29-2024, 04:01 PM   #9
Karellen
Wizard
Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.
 
Karellen's Avatar
 
Posts: 1,351
Karma: 6794938
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
And your S&R regex will be...

Search:
PHP Code:
<h2>(.*?)</h2>
<
class="chapterh2">(.*?)</p
Replace:
PHP Code:
<h2 title="\1 - \2">\1</h2>
<
class="chapterh2">\2</p
Karellen is offline   Reply With Quote
Old 09-29-2024, 04:01 PM   #10
foosion
Evangelist
foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.
 
Posts: 431
Karma: 41524
Join Date: Sep 2011
Device: Kobo Libra 2 & Clara BW
Quote:
Originally Posted by Karellen View Post
Then generate TOC from major headings and click the use title attribute.

foosion is offline   Reply With Quote
Old 09-29-2024, 04:04 PM   #11
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: 40,372
Karma: 156982136
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
If you do a search for say, 'title attribute', you will get quite a few hits. One that you may find useful, IMNSHO, is HTML Global title Attribute.

The title attribute is not the same as the title tag.

Sigil and calibre's ebook-editor will use the content of the title="<insert text here>" attribute of the h tag when generating the ToC.

In the examples given, you could use regex to extract the text from the h2 and p tags and concatenate them into a title="whatever" as an attribute of the h2 tag.

Last edited by DNSB; 09-29-2024 at 04:05 PM. Reason: Edit: once again read to end of thread before replying...
DNSB is offline   Reply With Quote
Old 09-29-2024, 04:16 PM   #12
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: 30,440
Karma: 58055868
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
You can also use title= when you want a slight different version to appear in a TOC.

PS It is also NEEDED when your chapter title heads are Graphical
theducks is offline   Reply With Quote
Old 09-29-2024, 05:27 PM   #13
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: 40,372
Karma: 156982136
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
An example of that is one ebook where the author used graphics for the chapter headers. Looked great until you recreated the ToC and either manually edited in the chapter numbers or added them using title=. I ended up selecting all the chapter images and renaming the them into a usable format and then a simple regex did the deal.

<h3 class="chapnum" title="Chapter 18"><img class="glyphw25" src="../Images/chapter_18.jpeg" alt="Chapter 18"/></h3>
DNSB is offline   Reply With Quote
Old 09-29-2024, 11:22 PM   #14
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,557
Karma: 14325282
Join Date: Nov 2019
Device: none
Quote:
Originally Posted by theducks View Post
<h2 class-"whatever" title="the real words for the TOC">

A little REGEXfoo and you can build the title= bit

I think this is similar to what I had used. But it's been years and I've forgotten. There's a chapter numbering plugin for Sigil that I used to generate the "Chapter One" etc. with h1 tags, and then below that I think I had an h2 tag with the descriptive name. Then I used a regex to convert that to something like
Code:
<h2>Chapter One <span>Descriptive Title</span></h2>
In my CSS file I had
Code:
h2 span, h3 span {
    display: block;
    font-size: larger;
    font-style: italic;
    font-variant: normal;
    font-weight: bold;
    margin-top: 1.25em
     }
The "trick" is that display:block; the above CSS applies to the span inside the h2, not the h2. The display:block puts on a separate line what's inside the span.

If you look for the book Batwing Bowles by Dane Coolidge here in the mobileread library you can see the final result. Both the TOC and the chapter first pages.

Last edited by hobnail; 09-29-2024 at 11:25 PM.
hobnail is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple HTML files w/ TOC to MOBI, not added in order listed in TOC dysfunction Conversion 3 01-03-2014 12:40 AM
Ho do I create a TOC for ePub which does convert to an active TOC in Kindle Previewer K-Thom Calibre 1 09-24-2013 06:32 PM
Kindler previewer not recognizing toc.ncx file, my html toc, or the start point... petercrowell Kindle Formats 2 05-01-2012 08:14 AM
Use Regex to Code an Inline TOC, from an External TOC's .ncx File mostlynovels ePub 2 03-16-2011 12:15 PM
Making a TOC for LRFs? Issues with Calibre + LRF TOC editor not working Magitek LRF 0 05-06-2009 01:25 PM


All times are GMT -4. The time now is 10:54 AM.


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