Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 02-12-2015, 07:50 AM   #1
Skeeve
Zealot
Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.
 
Skeeve's Avatar
 
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>
When I let calibre (1.48) generate a ToC I get lines like this:

Code:
<li><a href="ct-2014-01.html#u094aaa39-0c47-43d1-9343-d5190bf2d74d">Unter allen Wipfeln (1)</a></li>
But I'd like to have the author added like so:

Code:
<li><a href="ct-2014-01.html#u094aaa39-0c47-43d1-9343-d5190bf2d74d">Arno Endler: Unter allen Wipfeln (1)</a></li>
Is there any way to achieve that?

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?
Skeeve is offline   Reply With Quote
Old 02-12-2015, 09:19 AM   #2
thewitt
Zealot
thewitt ought to be getting tired of karma fortunes by now.thewitt ought to be getting tired of karma fortunes by now.thewitt ought to be getting tired of karma fortunes by now.thewitt ought to be getting tired of karma fortunes by now.thewitt ought to be getting tired of karma fortunes by now.thewitt ought to be getting tired of karma fortunes by now.thewitt ought to be getting tired of karma fortunes by now.thewitt ought to be getting tired of karma fortunes by now.thewitt ought to be getting tired of karma fortunes by now.thewitt ought to be getting tired of karma fortunes by now.thewitt ought to be getting tired of karma fortunes by now.
 
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.
thewitt is offline   Reply With Quote
Advert
Old 02-12-2015, 09:41 AM   #3
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,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
theducks is offline   Reply With Quote
Old 02-12-2015, 12:26 PM   #4
Skeeve
Zealot
Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.
 
Skeeve's Avatar
 
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.
Skeeve is offline   Reply With Quote
Old 02-12-2015, 01:20 PM   #5
Ghitulescu
Fanatic
Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.
 
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.
Ghitulescu is offline   Reply With Quote
Advert
Old 02-12-2015, 01:31 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: 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
Seems to work in Sigil but not in Calibre TOC generator (2.19 W7x64)

the title =solution does work if you get it correct

title = must be part of the H tag
theducks is offline   Reply With Quote
Old 02-12-2015, 02:07 PM   #7
Skeeve
Zealot
Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.
 
Skeeve's Avatar
 
Posts: 142
Karma: 669192
Join Date: Nov 2013
Device: Kindle 4.1.1 no touch
Quote:
Originally Posted by Ghitulescu View Post
You can always edit the TOC by hand to point to the exact targets.
Sure I can. But I'm asking for an automated solution.
Skeeve is offline   Reply With Quote
Old 02-12-2015, 04:00 PM   #8
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 21,660
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by theducks View Post
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
Quote:
Originally Posted by Skeeve View Post
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)
Quote:
Originally Posted by theducks View Post
@Skeeve
Seems to work in Sigil but not in Calibre TOC generator (2.19 W7x64)

the title =solution does work if you get it correct

title = must be part of the H tag
I'm wondering if the Function Mode for Search & Replace in the Editor feature could be used to inject metadata element values into the Headers. If not then maybe the editor could be enhanced to make them available.

BR
BetterRed is offline   Reply With Quote
Old 02-12-2015, 04:35 PM   #9
Skeeve
Zealot
Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.
 
Skeeve's Avatar
 
Posts: 142
Karma: 669192
Join Date: Nov 2013
Device: Kindle 4.1.1 no touch
Quote:
Originally Posted by BetterRed View Post
I'm wondering if the Function Mode for Search & Replace in the Editor feature could be used
I think, that is really a good idea! Thanks a lot!
Skeeve is offline   Reply With Quote
Old 02-12-2015, 04:50 PM   #10
Skeeve
Zealot
Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.
 
Skeeve's Avatar
 
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>
And apply this replace:

Code:
\1\4: \2\3
After that I create the Inline ToC.
Skeeve is offline   Reply With Quote
Old 02-12-2015, 05:14 PM   #11
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
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:
Originally Posted by BetterRed View Post
I'm wondering if the Function Mode for Search & Replace in the Editor feature could be used to inject metadata element values into the Headers. If not then maybe the editor could be enhanced to make them available.

BR
Function mode was introduced in calibre 2.11 -- not ideal for those stuck on Qt4 versions.
eschwartz is offline   Reply With Quote
Old 02-12-2015, 08:29 PM   #12
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 21,660
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by Skeeve View Post
Thanks @BetterRed!

I found a solution that works for me!
Great, its always satisfying to arrive at a destination solution under one's own steam.

Quote:
Originally Posted by eschwartz View Post
Function mode was introduced in calibre 2.11 -- not ideal for those stuck on Qt4 versions.
I missed the reference to 1.48

BR

Last edited by BetterRed; 02-12-2015 at 10:59 PM.
BetterRed is offline   Reply With Quote
Old 02-13-2015, 08:17 AM   #13
Ghitulescu
Fanatic
Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.
 
Posts: 563
Karma: 403106
Join Date: Aug 2014
Device: PRS-T1
Quote:
Originally Posted by Skeeve View Post
Sure I can. But I'm asking for an automated solution.
I meant after. Don't tell me you're trusting automations?
Ghitulescu is offline   Reply With Quote
Old 02-13-2015, 12:52 PM   #14
Skeeve
Zealot
Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.
 
Skeeve's Avatar
 
Posts: 142
Karma: 669192
Join Date: Nov 2013
Device: Kindle 4.1.1 no touch
Quote:
Originally Posted by Ghitulescu View Post
I meant after. Don't tell me you're trusting automations?
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.
Skeeve is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
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 PDF 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


All times are GMT -4. The time now is 10:45 PM.


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