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 Yesterday, 07:00 AM   #1
Whip
Junior Member
Whip began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Sep 2024
Device: none
how to use command line to automatically create ToC from all headings?

Hello,

I want to use the command line to convert an html book to epub and select the setting "Generate ToC from all headings." I don't see this option available in the command line interface in the documentation, but it is available in the calibre edit GUI.

Currently, I have to drag the html into calibre, convert to epub, click edit on the converted file, open the ToC GUI, delete the auto-generated ToC, then click "Generate ToC from all headings".

Can someone tell me how to automate this process from the command line with ebook-convert, ebook-edit, or some other tool?

Thank you!
Whip is offline   Reply With Quote
Old Yesterday, 08:07 AM   #2
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: 44,270
Karma: 23661992
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
https://manual.calibre-ebook.com/gen...le-of-contents
kovidgoyal is offline   Reply With Quote
Advert
Old Yesterday, 08:50 AM   #3
Whip
Junior Member
Whip began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Sep 2024
Device: none
I looked at that documentation and I don't see an option for exactly what I'm looking for.

Is there a flag for "Generate ToC from all headings"? When I click that button in the GUI, the ToC comes out perfectly. I just don't see a command-line flag for that setting. Can you please point me to it?
Whip is offline   Reply With Quote
Old Yesterday, 09:00 AM   #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,288
Karma: 57979022
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
ebook-convert input_file output_file [options]

Did you scroll down in the Help file? There is a TOC section with options
theducks is offline   Reply With Quote
Old Yesterday, 03:07 PM   #5
Whip
Junior Member
Whip began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Sep 2024
Device: none
I do not see any setting described in the help documentation that does what I am asking for. I specifically want a command line option that matches the GUI button for "Generate ToC from all headings"

None of the flags in the documentation that I've found describe that option. Do you know how I could select that setting from the command line?
Whip is offline   Reply With Quote
Advert
Old Yesterday, 10:45 PM   #6
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: 44,270
Karma: 23661992
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
There is no such flag. You need to specify the level1 through level3 settings manually. The button in the GUI does just that under the hood. Read their docs to understand what you need to put there, or look at the conversion log of the GUI conversion to see what values those settings have.
kovidgoyal is offline   Reply With Quote
Old Today, 07:56 AM   #7
Whip
Junior Member
Whip began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Sep 2024
Device: none
Alright, thank you for clarifying.

Also, thanks for making Calibre and releasing it for free. I am a big fan of the software.
Whip is offline   Reply With Quote
Old Today, 08:16 AM   #8
Whip
Junior Member
Whip began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Sep 2024
Device: none
I hate to keep asking for help but - can you tell me where the conversion logs are stored?

I tried running calibre-debug --gui and calibre-debug --edit-book and those logs didn't contain the ToC conversion commands.

And I don't see a reference to conversion logs in the manual: https://manual.calibre-ebook.com/edit.html

I tried running calibre in debug mode as suggested here (https://www.mobileread.com/forums/sh...d.php?t=344814) but those logs didn't contain the conversion details.

How can I access the conversion logs? Thank you for your help!
Whip is offline   Reply With Quote
Old Today, 09:35 AM   #9
thiago.eec
Guru
thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.
 
Posts: 990
Karma: 1183425
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite
Quote:
Originally Posted by Whip View Post
How can I access the conversion logs? Thank you for your help!
After converting, look at the bottom right of calibre main window. There is a button to show the Jobs window. Click on the last conversion job, then click on 'Show job details'.
thiago.eec is online now   Reply With Quote
Old Today, 11:45 AM   #10
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,288
Karma: 57979022
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by thiago.eec View Post
After converting, look at the bottom right of calibre main window. There is a button to show the Jobs window. Click on the last conversion job, then click on 'Show job details'.
I think the OP is doing everything from the command line.
theducks is offline   Reply With Quote
Old Today, 02:55 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: 38,983
Karma: 153098470
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by theducks View Post
I think the OP is doing everything from the command line.
A couple of message back, Kovid Goyal suggested running a GUI conversion and looking at the log from that to see what values the level1 to level3 settings were using.

The problem I see with that is that after the conversion, the OP was opening the ebook in calibre's ebook-editor, deleting the ToC generated in the GUI mode conversion and using the ebook-editor to recreate it with "Generate ToC from all headings" button.

I suspect that the OP might be able to do this by playing with the XPath for the levels so any h? tag would be used to create a ToC entry. Something like //*[name()='h1' or name()='h2' or name()='h3' or name()='h4' or name()='h5' or name()='h6'] though I haven't played enough with XPath to feel comfortable making recommendations.

Last edited by DNSB; Today at 03:10 PM.
DNSB is offline   Reply With Quote
Old Today, 03:35 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,288
Karma: 57979022
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Me neither
But looking at the CLI, I suspect that xpath needs to be separated into 3 because the CLI has a separate option for each level

ebook-convert input_file output_file --level1-toc <xpath> --level2-toc <xpath>--level3-toc <xpath>
theducks is offline   Reply With Quote
Old Today, 04:56 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: 38,983
Karma: 153098470
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
I think what I posted would handle multiple h? headings for testing. The OP might want to split out the various headings for other purposes but for testing, what I posted should work though I haven't tested it.
DNSB is offline   Reply With Quote
Reply

Tags
toc, toc creation


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
create a useable TOC when book uses images for chapter headings stumped Sigil 23 06-09-2019 03:12 PM
How to insert automatically valid id's in ToC headings? chaot Editor 18 02-01-2017 06:55 AM
Generated TOC at beginning of PDF via command line alexandreaquiles Conversion 1 10-12-2014 03:24 AM
HTML to Epub conversion isn't generating TOC through command line marcosalles Conversion 1 02-20-2014 10:09 PM
Calibre Command Line Interface TOC bcolflesh Calibre 3 02-04-2010 04:09 PM


All times are GMT -4. The time now is 07:20 PM.


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