Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 08-27-2010, 08:53 AM   #1
erion
Member
erion began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Aug 2010
Device: none
An auto-toc problem

Hello all,
I am relatively new to Calibre.
I have a html file I wish to convert to epub format. It has an inline toc, but I also would like to create an auto-generated one.
The book has chapters and parts which encapsulate the chapters, thus I have set parts to be heading level 1, while chapters as level 2.
I also have a batch file, which uses ebook-convert to add the detection of heading 1 and 2, thus Calibre can generate the multi-level toc.
However, the problem is that if I specify --level1-toc and the --level2-toc options as //h:h1 and //h:h2 respectively, Calibre auto-generates a toc which is based on the 2nd level headings only, i.e. the heading 1 parts are missing.
Here's how my command looks like:
Code:
ebook-convert %1 %2 --level1-toc //h:h1 --level2-toc //h:h2 --use-auto-toc
Later on I'd also like to insert metadata automatically after the conversion is done, based on online sources, but that is not important for now

Could anyone explain what I'm missing here please?

Erion
erion is offline   Reply With Quote
Old 08-27-2010, 09:15 AM   #2
jackie_w
Wizard
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 2,689
Karma: 3818505
Join Date: Sep 2009
Location: UK
Device: Sony PRS-350, PB360, Kobo Glo/AuraHD/Aura6"
Hi erion, Welcome to the forum.

I use the GUI so I'm not a commandline expert, but I think you're missing a --chapter conversion option.

In the GUI to detect chapters at <h1> or <h2> you need this code:
Code:
//*[name()='h1' or name()='h2']
so my guess is you need to add something like
Code:
--chapter "//*[name()='h1' or name()='h2']"
to the command you showed above.
(I get confused with quotes usage on the commandline, so apologies if I haven't got it exactly correct)

Last edited by jackie_w; 08-27-2010 at 09:17 AM.
jackie_w is offline   Reply With Quote
Old 08-27-2010, 10:15 AM   #3
erion
Member
erion began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Aug 2010
Device: none
Hi,
This seems to solve my problem wonderfully. The question is though, if I specify the xpaths for the multi-level contents, how come they are not used... seems a mystery to me.
Anyways, thank you very much for your quick reply and your solution, it's really appreciated.

Time to look for an epub auto tagger...

Cheers,
Erion
erion is offline   Reply With Quote
Old 08-27-2010, 11:34 AM   #4
jackie_w
Wizard
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 2,689
Karma: 3818505
Join Date: Sep 2009
Location: UK
Device: Sony PRS-350, PB360, Kobo Glo/AuraHD/Aura6"
Quote:
Originally Posted by erion View Post
...if I specify the xpaths for the multi-level contents, how come they are not used... seems a mystery to me...
I think the --chapter and --leveln-toc options are to be used in tandem, but the --chapter option seems to be the most important, telling calibre how to split the chapters.

For instance, (at least in the GUI) if you run your conversion with just the --chapter option set as specified and leave the --level-tocs blank then you still get all the <h1>s and <h2>s in the epub TOC, but they have a flat hierarchy instead of the <h2>s being children of the <h1>s. So it appears that the --level-tocs fine-tune the --chapter.

If I've got this completely wrong maybe someone more technical can chip in and enlighten us.
jackie_w is offline   Reply With Quote
Old 08-27-2010, 11:37 AM   #5
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 25,376
Karma: 4961459
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
IIRC the toc level options, if specified (and if they match) take precedence.
kovidgoyal is offline   Reply With Quote
Old 08-27-2010, 11:42 AM   #6
jackie_w
Wizard
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 2,689
Karma: 3818505
Join Date: Sep 2009
Location: UK
Device: Sony PRS-350, PB360, Kobo Glo/AuraHD/Aura6"
Thanks for quick response. So it seems I've got things the wrong way round. You learn something new every day.
jackie_w is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Email auto transfer problem JimKelly Calibre 24 01-24-2011 09:25 PM
How not to auto-generate TOC in Calibre -setting? Jundle Calibre 0 05-05-2010 02:53 AM
TOC Problem Zipr Calibre 0 03-19-2010 05:01 PM
Kindle on IPod auto-rotate problem hbreder Amazon Kindle 3 02-12-2010 01:20 PM
Why HTML2LRF auto create 1 row TOC ? alophind Sony Reader 0 02-04-2008 01:44 AM


All times are GMT -4. The time now is 06:50 AM.


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