View Single Post
Old 12-29-2017, 04:58 PM   #23
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
This is how I automate it:

Do a regex search for the following (be sure to change the mode to Regex in the dropdown box):

>(\d+) (You might have to add a space before the (\d+), depending on the original coding.)

This might find all the chapter numbers, when the word "chapter" is not included anywhere. Then you can do a find and replace to replace the class with the "chapter" class.

Example (after you've found the class that was used; there could be inconsistent classes used by the creator, which is common):

Find the following: <p class="calibre_3">(\d+)</p>

Replace it with this: <p class="chapter">\1</p>

-or, if you prefer, replace it with the following:

<p class="chapter">Chapter \1</p>

Then go into the ToC editor, click on Generate ToC from XPath. Set up a macro to insert the following on the top Level 1 ToC line (mine is ctrl-shift-T -- or you can type it or you can fill out the lines on the next screen after you click on the wand at the right):

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

Then the Toc Editor will create entries for each chapter.

Create a CSS class for "chapter" to look the way you want it to look.

Here's mine:

.chapter {
display: block;
font-size: 1.4em; (this could change depending on length of the chapter title)
font-weight: bold;
text-align: center;
margin-bottom: 2em;
margin-left: 0;
margin-right: 0;
margin-top: 3em;
}

Convert the file again to have all the chapters start on a new page. You don't have to do this manually. You don't even need the line page-break-before: always; in your "chapter" class, because Convert will do it automatically.

Last edited by deback; 12-29-2017 at 05:04 PM.
deback is offline   Reply With Quote