Code Monkey home page Code Monkey logo

Comments (12)

jgoguen avatar jgoguen commented on May 25, 2024

I think I might be able to do this, but it will depend a lot on how the TOC is constructed whether I can do this reliably. And it's something that I would set up as an option, default off, because there may be chapter names instead that may be preferred to be shown over "Chapter X". Some investigation will need to be done.

from calibre-kobo-driver.

mapline avatar mapline commented on May 25, 2024

Many thanks as I would like to know which chap as Kobo gives chap details not number. Await your further comments.
I seems .kepub.epub is ok in ver 2.4 although I have not received it yet.

from calibre-kobo-driver.

jgoguen avatar jgoguen commented on May 25, 2024

So, it seems like it would be possible to do, but there's no way it could be reliable. The closest I could come would be to find all navPoint elements with class="chapter" and run an incrementing counter to replace whatever chapter text is there with "Chapter X". However, this could be misleading and end up just as confusing for you as having only the text display. Take this fragment of a TOC file from a professionally-published ebook:

<navPoint class="chapter" id="971c6981-4d9a-4738-87df-9f7f11c6bb0f" playOrder="1">
    <navLabel>
        <text>Dedication</text>
    </navLabel>
    <content src="Into_the_Woods_split_001.html"/>
</navPoint>
<navPoint class="chapter" id="ba1a9e96-3f89-4ddd-a0d3-b6bee7d43883" playOrder="2">
    <navLabel>
        <text>The Hollows</text>
    </navLabel>
    <content src="Into_the_Woods_split_003.html"/>
</navPoint>
<navPoint class="chapter" id="eb50b2f0-cf6b-4fb2-a5cc-13da5cc3035c" playOrder="3">
    <navLabel>
        <text>The Bespelled</text>
    </navLabel>
    <content src="Into_the_Woods_split_004.html"/>
</navPoint>

What you should see as chapter titles down at the bottom of the page is:

  1. Dedication
  2. The Hollows
  3. Chapter 1 (alternatively: Chapter 1 — The Bespelled)

What you would actually see, because these navPoint elements all have class="chapter" even where they should have something more appropriate, is this:

  1. Chapter 1 — Dedication
  2. Chapter 2 — The Hollows
  3. Chapter 3 — The Bespelled

I can implement this, find all navPoint elements that claim to be chapters, but based on a sample from my personal library from different professional publishers it's highly likely that you would find the end result to be more confusing. I couldn't find any books in my library that would only show a page number, but the results would be the same as for books that do show chapter text of some kind. Take the same NCX fragment as above, but modified to remove the identifying text:

<navPoint class="chapter" id="971c6981-4d9a-4738-87df-9f7f11c6bb0f" playOrder="1">
    <content src="Into_the_Woods_split_001.html"/>
</navPoint>
<navPoint class="chapter" id="ba1a9e96-3f89-4ddd-a0d3-b6bee7d43883" playOrder="2">
    <content src="Into_the_Woods_split_003.html"/>
</navPoint>
<navPoint class="chapter" id="eb50b2f0-cf6b-4fb2-a5cc-13da5cc3035c" playOrder="3">
    <content src="Into_the_Woods_split_004.html"/>
</navPoint>

Based on what we already know, we should see something like this:

  1. Page 1 of 1
  2. Page 1 of 1
  3. Chapter 1 — Page 1 of X

However, you would actually see that your book starts on "Chapter 3":

  1. Chapter 1 — Page 1 of 1
  2. Chapter 2 — Page 1 of 1
  3. Chapter 3 — Page 1 of X

A third case is where the chapter text already includes "Chapter X". For me, that would be very simple: don't touch it.

So, in short, I can do this if you want but I want to make sure you understand that the results are most likely going to appear to be incorrect even if this feature functions perfectly.

from calibre-kobo-driver.

giorgio130 avatar giorgio130 commented on May 25, 2024

The text that appears on the footer are the names defined in the TOC... if this one is properly written, why would you want to change them?

from calibre-kobo-driver.

jgoguen avatar jgoguen commented on May 25, 2024

I don't think you can programmatically determine "properly written", so if this is to be done I think it will strictly be "only if there is no chapter text". I'm trying to think of how I could do it to be least confusing. I found a book after posting last night that has both chapter number and name in the TOC, so really it looks like it's only feasible to do this where no chapter text exists already.

from calibre-kobo-driver.

mapline avatar mapline commented on May 25, 2024

Thanks for your thoughts.
As I new to epubs does the TOC determine to table of contents.
How can I paste a copy of of 2 TOC as examples
Many thanks
Michael

from calibre-kobo-driver.

jgoguen avatar jgoguen commented on May 25, 2024

Take a look at https://help.github.com/articles/github-flavored-markdown for details on how to format things. Specifically, you'll want the Syntax Highlighting section. The example there is for Ruby, but if you replace "ruby" with "xml" and paste in your XML that will do it. You can use the Preview tab right above the editor to see what your comment looks like before you submit it.

from calibre-kobo-driver.

mapline avatar mapline commented on May 25, 2024

Thanks will do that.
Also "As I new to epubs does the TOC determine to table of contents?"

from calibre-kobo-driver.

jgoguen avatar jgoguen commented on May 25, 2024

Ahh, yes. For EPUB2 books, the NCX file (typically named toc.ncx in my experience) defines a few things:

  1. The Table of Contents that would be in a paper book, via the navMap element and its navPoint children.
  2. The order to show chapters in, via the playOrder attribute to navPoint, or by the order they appear in the document in the absence of playOrder.
  3. The title for each chapter, by the text content of navMap > navPoint > navLabel > text, and the file where the chapter starts, by the src attribute of navMap > navPoint > content.

from calibre-kobo-driver.

mapline avatar mapline commented on May 25, 2024

Thanks for thoughts will come back with reply but may not be soon as wife just taken into hospital

from calibre-kobo-driver.

jgoguen avatar jgoguen commented on May 25, 2024

Take your time, I hope everything turns out well for you both.

from calibre-kobo-driver.

jgoguen avatar jgoguen commented on May 25, 2024

I'm going to close this for now. Once everything has settled down for you and you have time, feel free to re-open this bug report. Again, I hope everything is going well for you and for your wife.

from calibre-kobo-driver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.