最新消息:20190717 VPS服务器:Vultr新加坡,WordPress主题:大前端D8,统一介绍入口:关于

【已解决】calibre报错:calibre.ebooks.oeb.transforms.split.SplitError无法找到合适的折分点

Calibre crifan 145浏览 0评论
折腾:
【记录】给crifan的gitbook的books去批量make deploy部署
期间,去给gitbook编译期间:
make deploy
期间,有个book:python_common_code_snippet
去用calibre转换epub期间报错:
        No large trees found
        Looking for large trees in baidu_ocr.html...
        Found large tree #0
Python function terminated unexpectedly: 无法找到合适的折分点:baidu_ocr.html 子树大小: 302 KB
Traceback (most recent call last):
  File "/Applications/calibre.app/Contents/Resources/Python/lib/python2.7/site.py", line 154, in main
    return run_entry_point()
  File "/Applications/calibre.app/Contents/Resources/Python/lib/python2.7/site.py", line 114, in run_entry_point
    return getattr(pmod, func)()
  File "site-packages/calibre/ebooks/conversion/cli.py", line 391, in main
  File "site-packages/calibre/ebooks/conversion/plumber.py", line 1252, in run
  File "site-packages/calibre/ebooks/conversion/plugins/epub_output.py", line 198, in convert
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 64, in __call__
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 74, in split_item
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 222, in __init__
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 370, in split_to_size
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 370, in split_to_size
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 370, in split_to_size
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 370, in split_to_size
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 355, in split_to_size
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 355, in split_to_size
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 355, in split_to_size
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 355, in split_to_size
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 355, in split_to_size
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 355, in split_to_size
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 348, in split_to_size
calibre.ebooks.oeb.transforms.split.SplitError: 无法找到合适的折分点:baidu_ocr.html 子树大小: 302 KB

make[1]: *** [../../common/gitbook_makefile.mk:323: epub] Error 1
make[1]: Leaving directory '/Users/crifan/dev/dev_root/gitbook/GitbookTemplate/gitbook_template/books/python_common_code_snippet'
make: *** [Makefile:19: deploy] Error 2
去对应book中单独试试
make deploy
期间,感觉是:
Found large tree #0
找到了 大的内容
然后去拆分,结果拆分期间出错的
错误依旧:
debug: Creating EPUB Output...
67% 正在运行 EPUB Output 插件
Rescaling image from 2340x1080 to 1586x732 anheijuexing_announcement_popop.jpg
Rescaling image from 2340x1080 to 1586x732 anheijuexing_first_charge.jpg
Splitting markup on page breaks and flow limits, if any...
    Looking for large trees in requests.html...
    No large trees found
    Looking for large trees in collections.html...
    No large trees found
    Looking for large trees in math.html...
    No large trees found
    Looking for large trees in system.html...
    No large trees found
    Looking for large trees in reference.html...
    No large trees found
    Looking for large trees in date_time.html...
    No large trees found
    Looking for large trees in char_string.html...
    No large trees found
    Looking for large trees in index8.html...
    No large trees found
    Looking for large trees in dict.html...
    No large trees found
    Looking for large trees in index3.html...
    No large trees found
    Looking for large trees in list_set.html...
    No large trees found
    Looking for large trees in file.html...
    No large trees found
    Looking for large trees in sort.html...
    No large trees found
    Looking for large trees in common_logic.html...
    No large trees found
    Looking for large trees in folder.html...
    No large trees found
    Looking for large trees in index4.html...
    No large trees found
    Looking for large trees in function_parameter.html...
    No large trees found
    Looking for large trees in index5.html...
    No large trees found
    Looking for large trees in pillow.html...
    No large trees found
    Looking for large trees in variable.html...
    No large trees found
    Looking for large trees in baidu_ocr.html...
    Found large tree #0
debug:     return run_entry_point()
  File "/Applications/calibre.app/Contents/Resources/Python/lib/python2.7/site.py", line 114, in run_entry_point
debug:     return getattr(pmod, func)()
  File "site-packages/calibre/ebooks/conversion/cli.py", line 391, in main
  File "site-packages/calibre/ebooks/conversion/plumber.py", line 1252, in run
  File "site-packages/calibre/ebooks/conversion/plugins/epub_output.py", line 198, in convert
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 64, in __call__
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 74, in split_item
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 222, in __init__
debug:   File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 370, in split_to_size
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 370, in split_to_size
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 370, in split_to_size
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 370, in split_to_size
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 355, in split_to_size
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 355, in split_to_size
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 355, in split_to_size
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 355, in split_to_size
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 355, in split_to_size
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 355, in split_to_size
debug:   File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 348, in split_to_size
calibre.ebooks.oeb.transforms.split.SplitError: 无法找到合适的折分点:baidu_ocr.html 子树大小: 302 KB


EbookError: Error during ebook generation: Conversion options changed from defaults:
  title: u'Python\u5e38\u7528\u4ee3\u7801\u6bb5'
  no_chapters_in_toc: True
  publisher: u'GitBook'
  dont_split_on_page_breaks: True
  book_producer: u'GitBook'
  breadth_first: True
  comments: u'\u6574\u7406\u51facrifan\u603b\u7ed3\u7684Python\u5404\u4e2a\u65b9\u9762\u5e38\u7528\u7684\u4ee3\u7801\u6bb5\uff0c\u4f9b\u9700\u8981\u7684\u53c2\u8003\u3002\u5305\u62ec\u901a\u7528\u903b\u8f91\u3001\u53d8\u91cf\u3001\u7cfb\u7edf\u3001\u65e5\u671f\u65f6\u95f4\u3001\u5b57\u7b26\u548c\u5b57\u7b26\u4e32\u3001\u6587\u4ef6\u7cfb\u7edf\uff0c\u6bd4\u5982\u6587\u4ef6\u548c\u6587\u4ef6\u5939\u7b49\u3001\u4ee5\u53ca\u7b2c\u4e09\u65b9\u5e93\uff0c\u6bd4\u5982BeautifulSoup\u3001\u4ee5\u53ca\u591a\u5a92\u4f53\u97f3\u89c6\u9891\u7c7b\u3001\u5305\u62ecPillow\u3001\u4ee5\u53ca\u7f51\u7edc\u7684Requests\u7b49\uff1b\u4ee5\u53ca\u5176\u4ed6\u5e38\u89c1\u8bed\u6cd5\uff0c\u5305\u62ecdict\u5b57\u5178\u3001list\u5217\u8868\u3001set\u96c6\u5408\u3001enum\u679a\u4e3e\u3001collections\u96c6\u5408\u7b49\u3002'
  level2_toc: u"descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-2 ')]"
  chapter: u"descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter ')]"
  level1_toc: u"descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-1 ')]"
  authors: u'Crifan Li <xxx>'
  level3_toc: u"descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-3 ')]"
  language: u'zh-hans'
  max_levels: 1
1% 将输入转换为HTML中...
InputFormatPlugin: HTML Input running
on /var/folders/46/2hjxz38n22n3ypp_5f6_p__00000gn/T/tmp-69341Hxr3Tjk9tteK/SUMMARY.html
Building file list...
Normalizing filename cases
Rewriting HTML links
34% Running transforms on e-book...
Merging user specified metadata...
Detecting structure...
    Detected chapter: 前言
    Detected chapter: 背景
    Detected chapter: 常用代码段
    Detected chapter: 通用逻辑
    Detected chapter: 变量
    Detected chapter: 系统
    Detected chapter: 日期时间
    Detected chapter: 字符和字符串
    Detected chapter: 文件系统
    Detected chapter: 文件
    Detected chapter: 文件夹
    Detected chapter: 多媒体
    Detected chapter: 图像
    Detected chapter: Pillow
    Detected chapter: 百度OCR
    Detected chapter: 音频
    Detected chapter: 视频
    Detected chapter: 网络相关
    Detected chapter: BeautifulSoup
    Detected chapter: requests
    Detected chapter: 数学
    Detected chapter: 常见语法
    Detected chapter: 函数参数
    Detected chapter: dict字典
    Detected chapter: list列表和set集合
    Detected chapter: sort排序
    Detected chapter: enum枚举
    Detected chapter: collections集合
    Detected chapter: 附录
    Detected chapter: 参考资料
Auto generated TOC with 28 entries.
Flattening CSS and remapping font sizes...
Source base font size is 10.20000pt
Removing fake margins...
Cleaning up manifest...
Trimming unused files from manifest...
Creating EPUB Output...
67% 正在运行 EPUB Output 插件
Rescaling image from 2340x1080 to 1586x732 anheijuexing_announcement_popop.jpg
Rescaling image from 2340x1080 to 1586x732 anheijuexing_first_charge.jpg
Splitting markup on page breaks and flow limits, if any...
    Looking for large trees in requests.html...
    No large trees found
    Looking for large trees in collections.html...
    No large trees found
    Looking for large trees in math.html...
    No large trees found
    Looking for large trees in system.html...
    No large trees found
    Looking for large trees in reference.html...
    No large trees found
    Looking for large trees in date_time.html...
    No large trees found
    Looking for large trees in char_string.html...
    No large trees found
    Looking for large trees in index8.html...
    No large trees found
    Looking for large trees in dict.html...
    No large trees found
    Looking for large trees in index3.html...
    No large trees found
    Looking for large trees in list_set.html...
    No large trees found
    Looking for large trees in file.html...
    No large trees found
    Looking for large trees in sort.html...
    No large trees found
    Looking for large trees in common_logic.html...
    No large trees found
    Looking for large trees in folder.html...
    No large trees found
    Looking for large trees in index4.html...
    No large trees found
    Looking for large trees in function_parameter.html...
    No large trees found
    Looking for large trees in index5.html...
    No large trees found
    Looking for large trees in pillow.html...
    No large trees found
    Looking for large trees in variable.html...
    No large trees found
    Looking for large trees in baidu_ocr.html...
    Found large tree #0
Python function terminated unexpectedly: 无法找到合适的折分点:baidu_ocr.html 子树大小: 302 KB
Traceback (most recent call last):
  File "/Applications/calibre.app/Contents/Resources/Python/lib/python2.7/site.py", line 154, in main
    return run_entry_point()
  File "/Applications/calibre.app/Contents/Resources/Python/lib/python2.7/site.py", line 114, in run_entry_point
    return getattr(pmod, func)()
  File "site-packages/calibre/ebooks/conversion/cli.py", line 391, in main
  File "site-packages/calibre/ebooks/conversion/plumber.py", line 1252, in run
  File "site-packages/calibre/ebooks/conversion/plugins/epub_output.py", line 198, in convert
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 64, in __call__
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 74, in split_item
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 222, in __init__
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 370, in split_to_size
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 370, in split_to_size
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 370, in split_to_size
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 370, in split_to_size
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 355, in split_to_size
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 355, in split_to_size
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 355, in split_to_size
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 355, in split_to_size
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 355, in split_to_size
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 355, in split_to_size
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 348, in split_to_size
calibre.ebooks.oeb.transforms.split.SplitError: 无法找到合适的折分点:baidu_ocr.html 子树大小: 302 KB

 ✘ crifan@licrifandeMacBook-Pro  ~/dev/dev_root/gitbook/GitbookTemplate/gitbook_template/books/python_common_code_snippet   master ● 
calibre.ebooks.oeb.transforms.split.SplitError 无法找到合适的折分点
Bug #1427694 “Converting MOBI to EPUB fails with “SplitError: Co…” : Bugs : calibre
    File "/usr/lib/calibre/calibre/ebooks/oeb/transforms/split.py", line 340, in split_to_size
      raise SplitError(self.item.href, root)
  calibre.ebooks.oeb.transforms.split.SplitError: Could not find reasonable point at which to split: index.html Sub-tree size: 280 KB

    ebook-convert book.mobi book.epub --flow-size 1000000
文件限制是:260KB

Could not find reasonable point at which to split
好像这个问题,之前有遇到过,或者是类似的
但是此处搜:
flow-size
ebook-convert
都没搜到。
代码中
/Users/crifan/dev/dev_root/gitbook/GitbookTemplate/gitbook_template/common/gitbook_makefile.mk
是:
## Generate ePub file
epub: sync_content clean_epub create_folder_epub
    @echo ================================================================================
    @echo Generate ePub for $(BOOK_NAME)
    gitbook epub $(CURRENT_DIR) $(EPUB_FULLNAME) $(GITBOOK_COMMON_FLAGS)
好像是
gitbook epub
内部调用对应工具的?
那要看看如何传递参数–flow-size过去
Converting Large Text Files to epub with Calibre | Mad Computer Scientist
crifan.com ebook-convert –flow-size
 gitbook epub --help
warn: no summary file in this book 
info: 7 plugins are installed 
info: 6 explicitly listed 
info: loading plugin "highlight"... OK 
info: loading plugin "search"... OK 
info: loading plugin "lunr"... OK 
info: loading plugin "sharing"... OK 
info: loading plugin "fontsettings"... OK 
info: loading plugin "theme-default"... OK 
想要看help语法的,结果不支持,直接开始运行了。
crifan.com ebook-convert 260KB
ebook-convert — calibre 5.9.0 文档
默认值260KB 是Adobe Digital Editions 的文件大小要求。
gitbook epub pass parameter
感觉是之前有加过这个参数啊?
但是找不到
crifan gitbook ebook-conver
搜自己的 印象笔记
果然找到了:
【已解决】crifan的gitbook的模板make deploy出错:Could not find reasonable point at which to split Sub-tree size KB
去改源码:
/Users/crifan/.gitbook/versions/3.2.3/lib/output/ebook/getConvertOptions.js
加上:
        if (format === 'epub') {
            options["--flow-size"] = '512' // default 260KB, change to 512KB to allow bigger content
        }
变成:
function getConvertOptions(output) {
...
        var options = {
            ...
        };


        if (format === 'epub') {
            options["--flow-size"] = '512' // default 260KB, change to 512KB to allow bigger content
        }


        if (format !== 'pdf') {
            return options;
        }
即可,正常生成epub:
    Looking for large trees in baidu_ocr.html...
    No large trees found
。。。
    Looking for large trees in requests.html...
    No large trees found
Generating default cover
EPUB output written to /var/folders/46/2hjxz38n22n3ypp_5f6_p__00000gn/T/tmp-71190L6IfifLJkdXB/index.epub
debug: 输出保存到   /var/folders/46/2hjxz38n22n3ypp_5f6_p__00000gn/T/tmp-71190L6IfifLJkdXB/index.epub
debug: calling hook "finish"
finish!
info: >> generation finished with success in 22.5s !
info: >> 1 file(s) generated
debug: cleaning up... OK
【总结】
此处:
make deploy
内部调用
gitbook epub xxx
去生成epub文件期间报错:
        Looking for large trees in baidu_ocr.html...
        Found large tree #0
Python function terminated unexpectedly: 无法找到合适的折分点:baidu_ocr.html 子树大小: 302 KB
。。。
  File "site-packages/calibre/ebooks/oeb/transforms/split.py", line 348, in split_to_size
calibre.ebooks.oeb.transforms.split.SplitError: 无法找到合适的折分点:baidu_ocr.html 子树大小: 302 KB
原因:
此处epub的输入的html,302KB,文件超过了,默认的260KB(Adobe Digital Editions 的文件大小要求),无法转换。
解决思路:
  • 使输入文件小于260KB的限制
    • 可以手动编辑输入的html
    • 或者用calibre自带的电子书编辑器ebook editor去编辑
  • 或 扩大限制
    • 给(calibre的ebook-convert)传入参数–flow-size,甚至更大的值
      • 举例
        • 设置为512KB
          • 命令行
            • ebook-convert xxx book.epub –flow-size 512
          • gitbook中
            • 没法直接传递参数–flow-size
            • 原因:
              • 命令
                • gitbook epub inputFolder outputFile.epub
              • 的内部调用了ebook-convert
            • 规避办法
              • 找到gitbook的js,改调用ebook-convert的js代码,加上参数–flow-size
(1)找到gitbook的js代码,给调用epub时的ebook-convert传递–flow-size参数
具体步骤:
确定当前gitbook所用版本,此处是:
  gitbook --version
CLI version: 2.3.2
GitBook version: 3.2.3
-》gitbook版本:3.2.3
-》对应的gitbook安装后的目录是:
/Users/{YourMacUser}/.gitbook/versions/3.2.3/lib/output/ebook
比如我的是:
/Users/crifan/.gitbook/versions/3.2.3/lib/output/ebook
其下有:getConvertOptions.js
修改其中的代码为:
function getConvertOptions(output) {
。。。
        var options = {
            '--cover':                      coverPath,
            ...
        };


            if (format === 'epub') {
                options['--flow-size'] = '512'; // default 260KB, change to 512KB to allow bigger content
            }
即可。
相关参数解释:
ebook-convert — calibre 5.9.0 文档
“–flow-size
将大于该大小 (以KB为单位) 的HTML文件切分。由于很多EPUB阅读器无法打开巨大的文件,故此功能十分有用。默认值 260KB 是Adobe Digital Editions 的文件大小要求。设置为0来禁用大小为基准的切分。”

转载请注明:在路上 » 【已解决】calibre报错:calibre.ebooks.oeb.transforms.split.SplitError无法找到合适的折分点

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
19 queries in 0.096 seconds, using 9.43MB memory