Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Conversion

Notices

Reply
 
Thread Tools Search this Thread
Old 10-06-2018, 02:43 PM   #1
XRaySpeX
Member
XRaySpeX began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Dec 2010
Location: Reading, UK
Device: Kindle 3 3G
Creating a ToC in a Kindle .AZW eBook that has none

My Kindle eBook has chapter headings like:
Chapter I

- AT MAYTREE COTTAGE


The equivalent HTML seems to be :
<p class="calibre_12"><font size="4"><span class="bold">Chapter I</span></font></p><p class="calibre_12">- AT MAYTREE COTTAGE</p>

How would I create a ToC like:
Chapter I - AT MAYTREE COTTAGE

using the Convert Books ToC function?

I can already create the ToC just with:
Chapter I
with the ToC function by just leaving its XPath Expressions as the default blank.
XRaySpeX is offline   Reply With Quote
Old 10-06-2018, 03:22 PM   #2
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: 29,800
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
I use the TOC tool in the Editor (or main Calibre toolbar )
But that is some ugly code (
Code:
<p class="calibre_12"><font size="4"><span class="bold">Chapter I</span></font></p><p class="calibre_12">- AT MAYTREE COTTAGE</p>
)

font sizing should be done in the CSS. <h tags are bold by default

First step is to 'pretty' the code using the flower icon (main toolbar) in the editor so any pattern match has a better chance


Personally, I would code this as:
Code:
<h3 class="chapno">Chapter I&nbsp<br />- AT MAYTREE COTTAGE</h3>
This creates a 2 line Visual, but shows up in the TOC as a single entry

where .chapno in the CSS would control the style
line-height: 2 ; spreads the lines further apart

I think this EDITOR REGEX search may work. (Replace and Search, NEVER all)

Find <p class="calibre_12"><font size="4"><span class="bold">(Chapter .+?)</span></font></p><p class="calibre_12">(- .+?)</p>

Replace <h3 class="chapno">\1&nbsp<br />\2</h3>
theducks is offline   Reply With Quote
Old 10-06-2018, 03:43 PM   #3
XRaySpeX
Member
XRaySpeX began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Dec 2010
Location: Reading, UK
Device: Kindle 3 3G
Thanks, but I didn't follow much of that. I a newbie in this. That code might be ugly but it's what's in the file. It's a given.

The Calibre editor works only on EPUB & AWZ3 files only. Are you suggesting I 1st convert my AWZ file to those & then search & replace the heading lines from 1 code to another?

Is there no way to convert my file directly & combine the 2 heading lines into 1 in a ToC or even to have them as a 2 level ToC?
XRaySpeX is offline   Reply With Quote
Old 10-06-2018, 07:39 PM   #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: 29,800
Karma: 54830978
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 XRaySpeX View Post
Thanks, but I didn't follow much of that. I a newbie in this. That code might be ugly but it's what's in the file. It's a given.

The Calibre editor works only on EPUB & AWZ3 files only. Are you suggesting I 1st convert my AWZ file to those & then search & replace the heading lines from 1 code to another?

Is there no way to convert my file directly & combine the 2 heading lines into 1 in a ToC or even to have them as a 2 level ToC?
Have you tried opening the AZW file with the editor? (I have none, so I don't know if it works)

AFAIK there is no way to convert-combine.
The only things obvious I saw that makes that code a chapter title is the word Chapter and a font-size tag

So, I would convert to AZW3 and then work on it.

BTW here is a snippet of code I use to search for Roman numeral chapter numbers ( stand alone. you will need to add pieces to match your specific code)
Code:
<p class="\w">([CLXVI]{1,7})</p>
theducks is offline   Reply With Quote
Old 10-06-2018, 08:08 PM   #5
XRaySpeX
Member
XRaySpeX began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Dec 2010
Location: Reading, UK
Device: Kindle 3 3G
Quote:
Originally Posted by theducks View Post
Have you tried opening the AZW file with the editor? (I have none, so I don't know if it works)
Yes & it objects:
Quote:
calibre, version 3.32.0
ERROR: Cannot edit book: The book must be in the EPUB or AZW3 formats to edit.

First convert the book to one of these formats.
Quote:
Originally Posted by theducks View Post
The only things obvious I saw that makes that code a chapter title is the word Chapter and a font-size tag
That's not the problem. The Calibre Converter already recognises that code as a Chapter as I said in my OP. It is just that I want to include the chapter title on the following line alongside the Chapter # in the ToC.

If you're going to edit that file the simplest edit would be to merge the 2 heading lines into 1 & then the "Chapter # - Title" would come out in the wash in the ToC.

Last edited by XRaySpeX; 10-06-2018 at 08:53 PM.
XRaySpeX is offline   Reply With Quote
Old 10-06-2018, 09:10 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: 29,800
Karma: 54830978
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 XRaySpeX View Post
Yes & it objects:
That's not the problem. The Calibre Converter already recognises that code as a Chapter as I said in my OP. It is just that I want to include the chapter title on the following line alongside the Chapter # in the ToC.

If you're going to edit that file the simplest edit would be to merge the 2 heading lines into 1 & then the "Chapter # - Title" would come out in the wash in the ToC.
That is what the code in post 2 did
It also included making it an H tag, so the TOC tool (and it does need to be redone after the change) will find by Headers
theducks is offline   Reply With Quote
Old 10-07-2018, 08:57 AM   #7
XRaySpeX
Member
XRaySpeX began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Dec 2010
Location: Reading, UK
Device: Kindle 3 3G
What exactly does <br /> do? I know <br> inserts a single line break. What's the difference?
XRaySpeX is offline   Reply With Quote
Old 10-07-2018, 10:02 AM   #8
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: 29,800
Karma: 54830978
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 XRaySpeX View Post
What exactly does <br /> do? I know <br> inserts a single line break. What's the difference?
<br /> (<hr />) is the proper form of a self closing tag
<br> </br> is the other form (a tag pair) and
theducks is offline   Reply With Quote
Old 10-10-2018, 08:44 PM   #9
XRaySpeX
Member
XRaySpeX began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Dec 2010
Location: Reading, UK
Device: Kindle 3 3G
I've given up on what I set out to do. From day 1 I was able to produce a full ToC with just the Chapter nos from my .AZW using the Calibre Converter with default settings. But after spending some days on this & trying everything I could see I got no futher forward. It's a crazy program!
  1. I soon discovered that the Converter contains a Search & Replace (S&R) function. So there was no need to use the Editor. But even using that did not replace with the desired code.

    For example, your <h3> replacement ended up as:

    <p class="calibre_36"><font size="4"><span class="bold">(Chapter .+?)&nbsp</span></font><br/><font size="4"><span class="bold">(- .+?)</span></font></p>

    Also whatever S&R I did the ToC ended up as as empty ToC with just its heading "Table of Contents".
  2. As I said I was able to produce a full ToC with just the Chapter nos from my .AZW containing the code:

    <p class="calibre_12"><font size="4"><span class="bold">(Chapter .+?)</span></font></p><p class="calibre_12">(- .+?)</p>

    using only default settings but when I attempted to merge the 2 lines Chapter & Title into 1 by S&Ring the above into:

    <p class="calibre_12"><font size="4"><span class="bold">\1&nbsp\2</span></font></p>

    I ended up with a .MOBI file contaning the code:

    <p class="calibre_14"><font size="4"><span class="bold">(Chapter .+?)&nbsp(-.+?)</span></font></p>

    but still with an empty ToC. Then when I tried to use the Converter on that .MOBI using only default settings I still ended up with an empty ToC.

    How can the Converter produce different results when using only default settings on 2 seemingly similar codes:

    <p class="calibre_12"><font size="4"><span class="bold">(Chapter .+?)</span></font></p><p class="calibre_12">(- .+?)</p>
    vs.
    <p class="calibre_14"><font size="4"><span class="bold">(Chapter .+?)&nbsp(-.+?)</span></font></p>

    ? It doesn't make sense!
  3. Perhaps the ToC tool needs some manual assistance? Can you suggest a ToC XPath expression to id:

    <p class="calibre_14"><font size="4"><span class="bold">(Chapter .+?)&nbsp(-.+?)</span></font></p>

    as a Chapter heading?
I've learnt a lot about the Calibre Converter in the last few days thanks to you but it seems I might never put it into use. Thanks
XRaySpeX is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to influence the ToC when creating an ebook Skeeve Calibre 13 02-13-2015 12:52 PM
Creating Hanging TOC for Kindle Menu pypo Editor 17 07-15-2014 05:08 PM
Creating kindle ebook without a TOC? emerika Kindle Formats 0 03-04-2012 01:09 PM
Creating Proper TOC in Kindle - regex help needed lyric Conversion 1 10-17-2011 06:19 PM
Seeing an AZW ebook on my Kindle without having to first upload it? wornways Amazon Kindle 5 04-29-2011 12:46 AM


All times are GMT -4. The time now is 05:07 AM.


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