Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: Exclude content from TOC #33

Open
timtribers opened this issue Oct 12, 2016 · 7 comments
Open

FEATURE: Exclude content from TOC #33

timtribers opened this issue Oct 12, 2016 · 7 comments

Comments

@timtribers
Copy link

Hi,

It would be nice to see the features that Nodepub has which allows content to be:
a) excluded from the TOC, and
b) also placed before the TOC
(see: https://www.npmjs.com/package/nodepub#addsection--title-content-excludefromcontents-isfrontmatter- )

This could be by flags added to the content config - e.g:

content: [
            {
                title: "Down the Rabbit Hole",
                data: "<p>Alice was beginning to get very tired...</p>"
                excludeFromContents: false,
                isFrontMatter: false
            },

Thx.

@timtribers timtribers changed the title Feature: Exclude content from TOC FEATURE: Exclude content from TOC Oct 12, 2016
@cyrilis
Copy link
Owner

cyrilis commented Nov 8, 2016

Hi @timtribers ,

The features is added to newest version of Epub-gen, you can set option excludeFromToc and beforeToc of each chapter. refer to README.MD for more details.

😉

@pedrosanta
Copy link
Collaborator

Hi all!

Again, I was able to do this by simply leveraging the options for custom OPF and TOC templates, by feeding a bit more 'internal' data into the templates, and making the book 'spine' my way - such as passing a _tocIndex variable on options, and my TOC templates insert TOC at correct position, and TOC is generated from a subset of contents, etc.

I've got some comments about the config 'API' for this, beforeToc property seems a bit too rushed for this and can lead to some 'awkward' behaviour when one mixes several false and true throughout the contents, but I'll comment these out on the #35 PR.

@timtribers
Copy link
Author

Thanks @cyrilis for the new version. I am just testing it now. The beforeToc is working great, but not sure about the excludeFromToc yet. Also, as noted elsewhere, the images have got broken - but I see someone is on the case.

Many thanks for all the good work you guys do on this.

@matejcsok-istvan
Copy link

excludeFromToc: true exclude the chapter from TOC, but also exclude the content from the eBook at all

@waylaidwanderer
Copy link

Can confirm @matejcsok-istvan's report, this is happening to me as well.

@wishmerhill
Copy link

Hi all.

Nobody feels like the ToC entry in the ToC is somehow ouf of place? I would like have an option like excludeTocFromToc.

@mattwolff
Copy link

Was having the same issue described by @matejcsok-istvan and @waylaidwanderer. By setting the option exlcudeFromToc: true that chapter's content was excluded from the eBook as well.

Full disclosure, not super familiar with ePub standards / best practices. Nevertheless, here's a workaround that seems ~okay-ish:

  • Made a duplicate of content.opf.ejs
  • Used that duplicate as a custom OPF template by setting the ePub option: customOpfTemplatePath: path/to/duplicate/content.opf.ejs
  • In that custom OPF template, I modified the <spine> element for line 60 from:
<% if(content.beforeToc && !content.excludeFromToc){ %>

to:

<% if(content.beforeToc){ %>

and line 67 from:

<% if(!content.beforeToc && !content.excludeFromToc){ %>

to:

<% if(!content.beforeToc){ %>

Excludes the section from ToC but the data still renders in the actual Epub... Again, I'm not sure of the full repercussions of this yet... so no PR. I've also only tested with Mac and iPhone using Apple Books. Maybe there's a better way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants