![]() |
#1 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 142
Karma: 669192
Join Date: Nov 2013
Device: Kindle 4.1.1 no touch
|
How to influence the ToC when creating an ebook
Hi!
I'm compiling an ebook from 26 short stories which appeared in a german magazin. My HTML files contain headlines similar to this: Code:
<div class="headline"> <h1 id="u094aaa39-0c47-43d1-9343-d5190bf2d74d">Unter allen Wipfeln (1)</h1> <address class="author">Arno Endler</address> <address class="published">c't 2014, Heft 1, Seite 192</address> </div> Code:
<li><a href="ct-2014-01.html#u094aaa39-0c47-43d1-9343-d5190bf2d74d">Unter allen Wipfeln (1)</a></li> Code:
<li><a href="ct-2014-01.html#u094aaa39-0c47-43d1-9343-d5190bf2d74d">Arno Endler: Unter allen Wipfeln (1)</a></li> I already found the ToC generation using XPath, but this did not seem to help as it only allows to select elements and each selected element's text content seems to become an ToC entry. It seems to me there's no way to pick more than one element and somehow style them to an entry. Am I right or do you have any proposal what I can do? |
![]() |
![]() |
![]() |
#2 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 129
Karma: 1135446
Join Date: Nov 2014
Location: Miami, Florida
Device: iBooks
|
Edit the TOC after you create the book. Though I don't use Calibre, I use Sigil for this and it works beautifully.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,939
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Use some fancy Regex (not shown) on the source lines in the book to add a:
title="\3: \2 " inside the H1 tag fwiw \3 is the author captured \2 is the title captered title= "" overrides the normal H# text choice for the TOC generator |
![]() |
![]() |
![]() |
#4 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 142
Karma: 669192
Join Date: Nov 2013
Device: Kindle 4.1.1 no touch
|
Thanks for your replies.
So it seems what I wanted to do isn't possible. Sigil I can't use (at the moment) as my OS X is too old and it won't work here. Regex to set the title attribute could be an idea - maybe I'll take that approach. Thanks for that hint! Update: Tried it by manually setting the title attribute in one of the stories: No success. The title attribute wasn't taken by Calibre 1.48's automatic ToC creation. Maybe my Calibre is too old (same issue as with sigil: My OS X is too old) Last edited by Skeeve; 02-12-2015 at 12:29 PM. |
![]() |
![]() |
![]() |
#5 |
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 563
Karma: 403106
Join Date: Aug 2014
Device: PRS-T1
|
You can always edit the TOC by hand to point to the exact targets.
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,939
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
@Skeeve
![]() the title =solution does work if you get it correct title = must be part of the H tag |
![]() |
![]() |
![]() |
#7 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 142
Karma: 669192
Join Date: Nov 2013
Device: Kindle 4.1.1 no touch
|
|
![]() |
![]() |
![]() |
#8 | |||
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,660
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Quote:
Quote:
Quote:
BR |
|||
![]() |
![]() |
![]() |
#9 | |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 142
Karma: 669192
Join Date: Nov 2013
Device: Kindle 4.1.1 no touch
|
Quote:
|
|
![]() |
![]() |
![]() |
#10 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 142
Karma: 669192
Join Date: Nov 2013
Device: Kindle 4.1.1 no touch
|
Thanks @BetterRed!
I found a solution that works for me! First I create the ToC based on XPath. Level 1 is //h:h1 Level 2 is //h:address[@class="author"] This will give me a toc.ncx which I open in the editor. On that I apply this Search: Code:
(<text>)(.*?</text>\s*</navLabel>\s*<content src=".*?)#.*?("/>)\s*<navPoint.*?>\s*<navLabel>\s*<text>(.*?)</text>\s*</navLabel>\s*<conten.*?/>\s*</navPoint> Code:
\1\4: \2\3 |
![]() |
![]() |
![]() |
#11 | |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Quote:
|
|
![]() |
![]() |
![]() |
#12 | |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,660
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Great, its always satisfying to arrive at a destination solution under one's own steam.
Quote:
![]() ![]() BR Last edited by BetterRed; 02-12-2015 at 10:59 PM. |
|
![]() |
![]() |
![]() |
#13 |
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 563
Karma: 403106
Join Date: Aug 2014
Device: PRS-T1
|
|
![]() |
![]() |
![]() |
#14 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 142
Karma: 669192
Join Date: Nov 2013
Device: Kindle 4.1.1 no touch
|
I do trust it. Why not?
I already convert the PDFs, which are the source of this book, using automated scripts I wrote myself. They are not perfect, but I trust that they don't mess everything up. They especially are able to create the meta-info properly. So I also trust my found half-automated way of creating the ToC. But still I would like to get proof-readers. Unfortunately it's german text. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Creating kindle ebook without a TOC? | emerika | Kindle Formats | 0 | 03-04-2012 01:09 PM |
Creating a TOC | taraboom11 | Conversion | 2 | 02-04-2011 02:04 PM |
Creating TOC | thibaulthalpern | 3 | 03-27-2010 04:21 PM | |
Creating TOC for dummies. | Anarel | Calibre | 2 | 01-26-2010 11:48 PM |
200 Pomegranates and an Audience of One: Creating a Life of Meaning and Influence | arshield | Deals and Resources (No Self-Promotion or Affiliate Links) | 0 | 08-04-2009 06:50 PM |