如何使用ebooklib python创建指向某章内容的链接

问题描述

我在DJango python中开发了一个应用程序,以动态创建EPub fies。我正在使用CKEditor和ebooklib。但是我对TOC表示怀疑,我的意图是在TOC中创建一个链接,以指向一章的内容。我们可以创建与本节相同的内容链接到本章,但是当我创建本节以作为单独的页面加载时,请参见下面的示例代码

请参阅示例代码

 c2 = epub.EpubHtml(title='About this book',file_name='about.xhtml')
    c2.content='<h1>About this book</h1><p>Helou,this is my book! There are many books,but this one is mine.</p>'
    c2.set_language('hr')
    c2.properties.append('rendition:layout-pre-paginated rendition:orientation-landscape rendition:spread-none')
    c2.add_item(default_css)

    # add chapters to the book
    book.add_item(c1)
    book.add_item(c2)

  
    # create table of contents
    # - add manual link
    # - add section
    # - add auto created links to chapters

    book.toc = (epub.Link('intro.xhtml','Introduction','intro'),(epub.Section('Languages'),(c1,c2))
                )

但是当我执行时,我将在单独的页面中获得该部分。我的目的是指向本章的该部分,而不是将其作为单独的页面。 (就像指向章节中的小标题一样),并在TOC中添加章节链接(目录)。请帮忙吗?

谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)