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 Today, 11:37 AM   #1
foosion
Addict
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: 373
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; Today at 03:04 PM.
foosion is offline   Reply With Quote
Old Today, 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 Today, 03:03 PM   #3
foosion
Addict
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: 373
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 Today, 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,385
Karma: 58053698
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 Today, 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,320
Karma: 6700864
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 online now   Reply With Quote
Advert
Old Today, 03:32 PM   #6
foosion
Addict
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: 373
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 Today, 03:35 PM   #7
foosion
Addict
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: 373
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 Today, 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,320
Karma: 6700864
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 online now   Reply With Quote
Old Today, 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,320
Karma: 6700864
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 online now   Reply With Quote
Old Today, 04:01 PM   #10
foosion
Addict
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: 373
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 Today, 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: 39,583
Karma: 154147704
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; Today at 04:05 PM. Reason: Edit: once again read to end of thread before replying...
DNSB is online now   Reply With Quote
Old Today, 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,385
Karma: 58053698
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 Today, 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: 39,583
Karma: 154147704
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 online now   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 06:15 PM.


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