# gen-epub
用于生成 EPUB 的小工具。
## 安装
通过 pypi(推荐):
```
pip install GenEpub
```
从源码安装:
```
pip install git+https://github.com/apachecn/gen-epub
```
## 导入
```js
from GenEpub import gen_epub
```
## 函数参考
```js
gen_epub(articles, imgs, name, path)
```
+ `articles: [{title: String, content: String}]`
文章列表,每个文章以对象表示,`title`属性为标题(纯文本),`content`属性为正文(HTML)。
在正文中引用图片时,将`<img>`的`src`属性设为`../Images/{文件名}`。
+ `imgs: Map{String: Buffer}`
图片字典,键为文件名,值为图片二进制数据。
+ `name: String`
在书籍元信息中显示的书名,默认为`articles[0].title`。
+ `path: String`
保存文件的路径名,默认为当前工作目录下的`name + '.epub'`。
## 协议
本项目基于 SATA 协议发布。
您有义务为此开源项目点赞,并考虑额外给予作者适当的奖励。
## 赞助我们
![](https://home.apachecn.org/img/about/donate.jpg)
## 另见
+ [ApacheCN 学习资源](https://docs.apachecn.org/)
+ [计算机电子书](http://it-ebooks.flygon.net)
+ [布客新知](http://flygon.net/ixinzhi/)
Raw data
{
"_id": null,
"home_page": "https://github.com/apachecn/gen-epub",
"name": "GenEpub",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "epub,ebook,\u7535\u5b50\u4e66",
"author": "wizardforcel",
"author_email": "wizard.z@qq.com",
"download_url": "https://files.pythonhosted.org/packages/82/89/524a74e4915cb897b578d0aaafc43d61c9a18feba1bcc6bb745c87b122d9/GenEpub-2023.7.9.0.tar.gz",
"platform": null,
"description": "# gen-epub\r\n\r\n\u7528\u4e8e\u751f\u6210 EPUB \u7684\u5c0f\u5de5\u5177\u3002\r\n\r\n## \u5b89\u88c5\r\n\r\n\u901a\u8fc7 pypi\uff08\u63a8\u8350\uff09\uff1a\r\n\r\n```\r\npip install GenEpub\r\n```\r\n\r\n\u4ece\u6e90\u7801\u5b89\u88c5\uff1a\r\n\r\n```\r\npip install git+https://github.com/apachecn/gen-epub\r\n```\r\n\r\n## \u5bfc\u5165\r\n\r\n```js\r\nfrom GenEpub import gen_epub\r\n```\r\n\r\n## \u51fd\u6570\u53c2\u8003\r\n\r\n```js\r\ngen_epub(articles, imgs, name, path)\r\n```\r\n\r\n+ `articles: [{title: String, content: String}]`\r\n \r\n \u6587\u7ae0\u5217\u8868\uff0c\u6bcf\u4e2a\u6587\u7ae0\u4ee5\u5bf9\u8c61\u8868\u793a\uff0c`title`\u5c5e\u6027\u4e3a\u6807\u9898\uff08\u7eaf\u6587\u672c\uff09\uff0c`content`\u5c5e\u6027\u4e3a\u6b63\u6587\uff08HTML\uff09\u3002\r\n \r\n \u5728\u6b63\u6587\u4e2d\u5f15\u7528\u56fe\u7247\u65f6\uff0c\u5c06`<img>`\u7684`src`\u5c5e\u6027\u8bbe\u4e3a`../Images/{\u6587\u4ef6\u540d}`\u3002\r\n \r\n+ `imgs: Map{String: Buffer}`\r\n\r\n \u56fe\u7247\u5b57\u5178\uff0c\u952e\u4e3a\u6587\u4ef6\u540d\uff0c\u503c\u4e3a\u56fe\u7247\u4e8c\u8fdb\u5236\u6570\u636e\u3002\r\n \r\n+ `name: String`\r\n\r\n \u5728\u4e66\u7c4d\u5143\u4fe1\u606f\u4e2d\u663e\u793a\u7684\u4e66\u540d\uff0c\u9ed8\u8ba4\u4e3a`articles[0].title`\u3002\r\n \r\n+ `path: String`\r\n\r\n \u4fdd\u5b58\u6587\u4ef6\u7684\u8def\u5f84\u540d\uff0c\u9ed8\u8ba4\u4e3a\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u4e0b\u7684`name + '.epub'`\u3002\r\n\r\n## \u534f\u8bae\r\n\r\n\u672c\u9879\u76ee\u57fa\u4e8e SATA \u534f\u8bae\u53d1\u5e03\u3002\r\n\r\n\u60a8\u6709\u4e49\u52a1\u4e3a\u6b64\u5f00\u6e90\u9879\u76ee\u70b9\u8d5e\uff0c\u5e76\u8003\u8651\u989d\u5916\u7ed9\u4e88\u4f5c\u8005\u9002\u5f53\u7684\u5956\u52b1\u3002\r\n\r\n## \u8d5e\u52a9\u6211\u4eec\r\n\r\n![](https://home.apachecn.org/img/about/donate.jpg)\r\n\r\n## \u53e6\u89c1\r\n\r\n+ [ApacheCN \u5b66\u4e60\u8d44\u6e90](https://docs.apachecn.org/)\r\n+ [\u8ba1\u7b97\u673a\u7535\u5b50\u4e66](http://it-ebooks.flygon.net)\r\n+ [\u5e03\u5ba2\u65b0\u77e5](http://flygon.net/ixinzhi/)\r\n",
"bugtrack_url": null,
"license": "",
"summary": "GenEpub\uff0c\u7528\u4e8e\u751f\u6210 EPUB \u7684\u5c0f\u5de5\u5177",
"version": "2023.7.9.0",
"project_urls": {
"Homepage": "https://github.com/apachecn/gen-epub"
},
"split_keywords": [
"epub",
"ebook",
"\u7535\u5b50\u4e66"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "61f9efbaf768f61367948d8a685971f304f80a8e39876bc3ec6b4d93f99be1f0",
"md5": "b68d6ac37146bfa3d37b7054de5dd791",
"sha256": "4a5e6bd68f8c805595502ce8cbedefd9599b3c25cdd29333010ed142695e9463"
},
"downloads": -1,
"filename": "GenEpub-2023.7.9.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b68d6ac37146bfa3d37b7054de5dd791",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 9714,
"upload_time": "2023-07-09T13:45:44",
"upload_time_iso_8601": "2023-07-09T13:45:44.035801Z",
"url": "https://files.pythonhosted.org/packages/61/f9/efbaf768f61367948d8a685971f304f80a8e39876bc3ec6b4d93f99be1f0/GenEpub-2023.7.9.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8289524a74e4915cb897b578d0aaafc43d61c9a18feba1bcc6bb745c87b122d9",
"md5": "e742e22846f1f1b082bdd70159614b54",
"sha256": "2a912914b4c44327ee9016c08748e1ccf3bc197e8fb8d36097a8a8380e93ba61"
},
"downloads": -1,
"filename": "GenEpub-2023.7.9.0.tar.gz",
"has_sig": false,
"md5_digest": "e742e22846f1f1b082bdd70159614b54",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 8297,
"upload_time": "2023-07-09T13:45:45",
"upload_time_iso_8601": "2023-07-09T13:45:45.869190Z",
"url": "https://files.pythonhosted.org/packages/82/89/524a74e4915cb897b578d0aaafc43d61c9a18feba1bcc6bb745c87b122d9/GenEpub-2023.7.9.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-09 13:45:45",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "apachecn",
"github_project": "gen-epub",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "genepub"
}