Comments (2)
Thanks for sending this, looks like an interesting issue. I will need some time to figure out what is going on here but try this code. I think the code bellow is what you need.
Looking quickly I would say the issue is here volume_chapters.append((chapter, chapter.file_name))
. 2nd value in the tuple should be tuple or list with sub chapters. When I do that I get the saame issue, empty
- .
for volume_title in volumes:
volume_chapters = []
for i in range(chapter_index, chapter_index + 2):
chapter_title = chapters[i]
chapter = epub.EpubHtml(file_name=f'{volume_title}_{chapter_title}.xhtml',
media_type='application/xhtml+xml',
title=chapter_title,
content = '<p>Content</p>')
book.add_item(chapter)
volume_chapters.append(chapter)
chapter_index += 1
book.spine.extend(volume_chapters)
toc_section = (epub.Section(volume_title), volume_chapters)
book.toc.append(toc_section)
from ebooklib.
There is no doubt that you're right. Thanks for your help!
By the way, my Epub reader may be too censorious. I tried other Epub readers, and they can recognize the book correctly that contains redundant <ol/>
.
Have a nice day at work!
Thanks for sending this, looks like an interesting issue. I will need some time to figure out what is going on here but try this code. I think the code bellow is what you need.
Looking quickly I would say the issue is here
volume_chapters.append((chapter, chapter.file_name))
. 2nd value in the tuple should be tuple or list with sub chapters. When I do that I get the saame issue, empty.
for volume_title in volumes: volume_chapters = [] for i in range(chapter_index, chapter_index + 2): chapter_title = chapters[i] chapter = epub.EpubHtml(file_name=f'{volume_title}_{chapter_title}.xhtml', media_type='application/xhtml+xml', title=chapter_title, content = '<p>Content</p>') book.add_item(chapter) volume_chapters.append(chapter) chapter_index += 1 book.spine.extend(volume_chapters) toc_section = (epub.Section(volume_title), volume_chapters) book.toc.append(toc_section)
from ebooklib.
Related Issues (20)
- Slashes in TOC file paths are converted to backslashes in EpubNav (on Windows) HOT 3
- Epub not showing up on kindle HOT 2
- Cant write epub HOT 1
- broken chapters in an ebook HOT 4
- Images not shown between pages HOT 5
- Get page as image HOT 3
- In some HTML elements, attribute names need to be case-sensitive to take effect, for example, the viewBox attribute within the <svg> element.
- Option ignore_ncx (warning) HOT 3
- Saving with `set_content` produces empty HTML HOT 1
- Is there any plan on typing supports?
- Can't change the metadata
- Non-image cover?
- Include a font file, or any arbitrary file? HOT 1
- Write ebook file directly into db instead file HOT 1
- Warning on opening ebook HOT 2
- nsmap = metadata.nsmap HOT 1
- epub does not function with Kivy HOT 4
- item.get_type() does not recognize webm HOT 1
- write_epub() is deleting the css link HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ebooklib.