View Single Post
Old 02-26-2018, 12:03 PM   #5
deback
Book E d i t o r
deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.
 
Posts: 432
Karma: 288184
Join Date: May 2015
Device: Laptop
Here are some easy and detailed instructions:

In your text file, add ## above each chapter heading and above any other section that you want to be in a separate html file after conversion. Calibre conversion will place each section below the ## into a separate html file, so when you create the ToC, you can choose "Generate ToC from Files."

Before converting the text file, change the following in the settings for Conversion -> Input Options -> TXT Input -> Structure:

Paragraph style - auto
Formatting style - markdown


If you don't want to do the above steps, then you can use "chapter" for the chapter class (or any other name you'd like), and when generating the ToC, choose "Generate ToC from XPath," and in the "Level 1 ToC" line in the following screen, enter one of the following (I have it in a ctrl-T macro):

If you use <p class="chapter">, enter the following:

//*[re:test(@class, "chapter", "i")]


If you use <h1 class="chapter">, enter the following:

//h:h1[re:test(@class, "chapter", "i")]

(Replace "chapter" with whatever name you used for the Chapter class.)

The above strings are generated after you click on the wand at the right and enter in h1, class, chapter or p, class, chapter, or whatever you use. If you save one of the above in a macro, you can just hit the macro hotkey to enter the string whenever you need it.

Last edited by deback; 02-26-2018 at 12:06 PM.
deback is offline   Reply With Quote