Name | nonebot-plugin-easymarkdown JSON |
Version |
1.0.3
JSON |
| download |
home_page | None |
Summary | 格式化markdown语法,并转化为可读性较好的图片 |
upload_time | 2024-10-13 08:23:55 |
maintainer | None |
docs_url | None |
author | phquathi |
requires_python | <4.0,>=3.8 |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Nonebot-Plugin-EasyMarkdown
[![Markdown](https://img.shields.io/badge/Markdown-000000?style=for-the-badge&logo=markdown&logoColor=white)](https://daringfireball.net/projects/markdown/)
![License: MIT](https://img.shields.io/badge/License-MIT-yellow)
![PyPI](https://img.shields.io/badge/PyPI-blue)
![Python 3.8](https://img.shields.io/badge/Python-3.8-blue)
基于`fitz`与`xhtml2pdf`的格式化markdown语法,并转化为图片发送的插件
## 介绍
对于大语言模型越来越广泛使用的今天,大部分人在网页复制其回答总是会带有md的正则语法。导致许多时候我们要将其粘贴至word等地方时格式会很乱,并且还要手动去除这些语法,徒增麻烦。
同样的,并不是大多数人都会使用typora等md编辑软件
因此,本项目提供了一个简易的解决方案,只需将文本发送至bot,bot便能够将文本格式化并转化成图片发送回来,同时也包括去除了md语法的纯文本内容
## 安装
使用nb-cli进行安装:
```
nb plugin install nonebot-plugin-easymarkdown
```
或使用pip安装:
```
pip install nonebot-plugin-easymarkdown
```
## 使用
@机器人+``.md``+空格+md文本内容
## 原理
使用``markdown2``库将md文本转化为html,再使用``xhtml2pdf``库将html文本转化为pdf文件,最后使用``fitz``库将pdf文件转化为图片
```mermaid
graph TD
A[md文本] --> |markdown2库| B[html文本]
B --> |xhtml2pdf库| C[pdf文件]
C --> |fitz库| D[图片]
```
图片发送完毕会立即删除生成的图片与pdf文件,不会占用服务器空间
为了保证插件的易用性,因此不使用``html2image``等需要自行安装第三方工具的库,所以bot运行起来可能会稍慢
## 图例
![output_page_1](src/output_page_1.png)
![output_page_2](src/output_page_2.png)
![output_page_3](src/output_page_3.png)
## 存在的问题
由于xhtml2pdf库对于中文较少的支持,所以不支持**粗体**、*斜体*、***倾斜粗体***的md文本
不支持latex表达式
代码块不支持代码高亮(有,但是不会高亮)
其余大部分md文本均可较好显示
## 贡献
欢迎提交Pull Request或报告Issues。
## 许可
[MIT License](LICENSE)
Raw data
{
"_id": null,
"home_page": null,
"name": "nonebot-plugin-easymarkdown",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": null,
"author": "phquathi",
"author_email": "yangziqi233@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/8f/ed/bab1d1d23322d41cf940f1960f899f5099a3513c38b43d27c9db01025168/nonebot_plugin_easymarkdown-1.0.3.tar.gz",
"platform": null,
"description": "# Nonebot-Plugin-EasyMarkdown\n\n[![Markdown](https://img.shields.io/badge/Markdown-000000?style=for-the-badge&logo=markdown&logoColor=white)](https://daringfireball.net/projects/markdown/)\n\n![License: MIT](https://img.shields.io/badge/License-MIT-yellow)\n![PyPI](https://img.shields.io/badge/PyPI-blue)\n![Python 3.8](https://img.shields.io/badge/Python-3.8-blue)\n\n\n\u57fa\u4e8e`fitz`\u4e0e`xhtml2pdf`\u7684\u683c\u5f0f\u5316markdown\u8bed\u6cd5\uff0c\u5e76\u8f6c\u5316\u4e3a\u56fe\u7247\u53d1\u9001\u7684\u63d2\u4ef6\n\n## \u4ecb\u7ecd\n\u5bf9\u4e8e\u5927\u8bed\u8a00\u6a21\u578b\u8d8a\u6765\u8d8a\u5e7f\u6cdb\u4f7f\u7528\u7684\u4eca\u5929\uff0c\u5927\u90e8\u5206\u4eba\u5728\u7f51\u9875\u590d\u5236\u5176\u56de\u7b54\u603b\u662f\u4f1a\u5e26\u6709md\u7684\u6b63\u5219\u8bed\u6cd5\u3002\u5bfc\u81f4\u8bb8\u591a\u65f6\u5019\u6211\u4eec\u8981\u5c06\u5176\u7c98\u8d34\u81f3word\u7b49\u5730\u65b9\u65f6\u683c\u5f0f\u4f1a\u5f88\u4e71\uff0c\u5e76\u4e14\u8fd8\u8981\u624b\u52a8\u53bb\u9664\u8fd9\u4e9b\u8bed\u6cd5\uff0c\u5f92\u589e\u9ebb\u70e6\u3002\n\n\u540c\u6837\u7684\uff0c\u5e76\u4e0d\u662f\u5927\u591a\u6570\u4eba\u90fd\u4f1a\u4f7f\u7528typora\u7b49md\u7f16\u8f91\u8f6f\u4ef6\n\n\u56e0\u6b64\uff0c\u672c\u9879\u76ee\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7b80\u6613\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u53ea\u9700\u5c06\u6587\u672c\u53d1\u9001\u81f3bot\uff0cbot\u4fbf\u80fd\u591f\u5c06\u6587\u672c\u683c\u5f0f\u5316\u5e76\u8f6c\u5316\u6210\u56fe\u7247\u53d1\u9001\u56de\u6765\uff0c\u540c\u65f6\u4e5f\u5305\u62ec\u53bb\u9664\u4e86md\u8bed\u6cd5\u7684\u7eaf\u6587\u672c\u5185\u5bb9\n\n## \u5b89\u88c5\n\n\u4f7f\u7528nb-cli\u8fdb\u884c\u5b89\u88c5\uff1a\n\n```\nnb plugin install nonebot-plugin-easymarkdown\n```\n\n\u6216\u4f7f\u7528pip\u5b89\u88c5\uff1a\n\n```\npip install nonebot-plugin-easymarkdown\n```\n\n## \u4f7f\u7528\n\n@\u673a\u5668\u4eba+``.md``+\u7a7a\u683c+md\u6587\u672c\u5185\u5bb9\n\n## \u539f\u7406\n\n\u4f7f\u7528``markdown2``\u5e93\u5c06md\u6587\u672c\u8f6c\u5316\u4e3ahtml\uff0c\u518d\u4f7f\u7528``xhtml2pdf``\u5e93\u5c06html\u6587\u672c\u8f6c\u5316\u4e3apdf\u6587\u4ef6\uff0c\u6700\u540e\u4f7f\u7528``fitz``\u5e93\u5c06pdf\u6587\u4ef6\u8f6c\u5316\u4e3a\u56fe\u7247\n\n```mermaid\ngraph TD\n A[md\u6587\u672c] --> |markdown2\u5e93| B[html\u6587\u672c]\n B --> |xhtml2pdf\u5e93| C[pdf\u6587\u4ef6]\n C --> |fitz\u5e93| D[\u56fe\u7247]\n```\n\n\u56fe\u7247\u53d1\u9001\u5b8c\u6bd5\u4f1a\u7acb\u5373\u5220\u9664\u751f\u6210\u7684\u56fe\u7247\u4e0epdf\u6587\u4ef6\uff0c\u4e0d\u4f1a\u5360\u7528\u670d\u52a1\u5668\u7a7a\u95f4\n\n\u4e3a\u4e86\u4fdd\u8bc1\u63d2\u4ef6\u7684\u6613\u7528\u6027\uff0c\u56e0\u6b64\u4e0d\u4f7f\u7528``html2image``\u7b49\u9700\u8981\u81ea\u884c\u5b89\u88c5\u7b2c\u4e09\u65b9\u5de5\u5177\u7684\u5e93\uff0c\u6240\u4ee5bot\u8fd0\u884c\u8d77\u6765\u53ef\u80fd\u4f1a\u7a0d\u6162\n\n## \u56fe\u4f8b\n\n![output_page_1](src/output_page_1.png)\n\n![output_page_2](src/output_page_2.png)\n\n![output_page_3](src/output_page_3.png)\n\n## \u5b58\u5728\u7684\u95ee\u9898\n\n\u7531\u4e8exhtml2pdf\u5e93\u5bf9\u4e8e\u4e2d\u6587\u8f83\u5c11\u7684\u652f\u6301\uff0c\u6240\u4ee5\u4e0d\u652f\u6301**\u7c97\u4f53**\u3001*\u659c\u4f53*\u3001***\u503e\u659c\u7c97\u4f53***\u7684md\u6587\u672c\n\n\u4e0d\u652f\u6301latex\u8868\u8fbe\u5f0f\n\n\u4ee3\u7801\u5757\u4e0d\u652f\u6301\u4ee3\u7801\u9ad8\u4eae\uff08\u6709\uff0c\u4f46\u662f\u4e0d\u4f1a\u9ad8\u4eae\uff09\n\n\u5176\u4f59\u5927\u90e8\u5206md\u6587\u672c\u5747\u53ef\u8f83\u597d\u663e\u793a\n\n## \u8d21\u732e\n\u6b22\u8fce\u63d0\u4ea4Pull Request\u6216\u62a5\u544aIssues\u3002\n\n## \u8bb8\u53ef\n[MIT License](LICENSE) ",
"bugtrack_url": null,
"license": null,
"summary": "\u683c\u5f0f\u5316markdown\u8bed\u6cd5\uff0c\u5e76\u8f6c\u5316\u4e3a\u53ef\u8bfb\u6027\u8f83\u597d\u7684\u56fe\u7247",
"version": "1.0.3",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "87255537ba8278daeb02fdb8b3e41aa18985a2bb72997e57c37dc549d0bffeff",
"md5": "4efe96a462f64fa43cb5fc17ca2114c6",
"sha256": "3f89f6aaa9f7b581a23676d5dd6e4efa9d5b3806f6897a2dda14db4d861bee8d"
},
"downloads": -1,
"filename": "nonebot_plugin_easymarkdown-1.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4efe96a462f64fa43cb5fc17ca2114c6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 11936,
"upload_time": "2024-10-13T08:23:54",
"upload_time_iso_8601": "2024-10-13T08:23:54.342908Z",
"url": "https://files.pythonhosted.org/packages/87/25/5537ba8278daeb02fdb8b3e41aa18985a2bb72997e57c37dc549d0bffeff/nonebot_plugin_easymarkdown-1.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8fedbab1d1d23322d41cf940f1960f899f5099a3513c38b43d27c9db01025168",
"md5": "5bc4da5fbbab52f2108af0024688bbb4",
"sha256": "ddc8b20cc5b62b3f07bbc5c78ea16d4009d960277c1f6bd42cc3ed1fbabc6cc8"
},
"downloads": -1,
"filename": "nonebot_plugin_easymarkdown-1.0.3.tar.gz",
"has_sig": false,
"md5_digest": "5bc4da5fbbab52f2108af0024688bbb4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 9612,
"upload_time": "2024-10-13T08:23:55",
"upload_time_iso_8601": "2024-10-13T08:23:55.940917Z",
"url": "https://files.pythonhosted.org/packages/8f/ed/bab1d1d23322d41cf940f1960f899f5099a3513c38b43d27c9db01025168/nonebot_plugin_easymarkdown-1.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-13 08:23:55",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "nonebot-plugin-easymarkdown"
}