nonebot-plugin-markdown2img


Namenonebot-plugin-markdown2img JSON
Version 0.0.6 PyPI version JSON
download
home_pageNone
Summary可作为函数调用的Markdown渲染图片插件
upload_time2025-10-28 13:19:50
maintainerNone
docs_urlNone
authorANGJustinl
requires_python>=3.10
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center">
  <a href="https://v2.nonebot.dev/store"><img src="https://github.com/A-kirami/nonebot-plugin-template/blob/resources/nbp_logo.png" width="180" height="180" alt="NoneBotPluginLogo"></a>
  <br>
  <p><img src="https://github.com/A-kirami/nonebot-plugin-template/blob/resources/NoneBotPlugin.svg" width="240" alt="NoneBotPluginText"></p>
</div>

<div align="center">

# nonebot-plugin-markdown2img

_✨ 可作为函数调用的Markdown渲染图片插件 ✨_


<a href="./LICENSE">
    <img src="https://img.shields.io/github/license/ANGJustinl/nonebot_plugin_markdown2img.svg" alt="license">
</a>
<a href="https://pypi.python.org/pypi/nonebot_plugin_markdown2img">
    <img src="https://img.shields.io/pypi/v/nonebot_plugin_markdown2img.svg" alt="pypi">
</a>
<img src="https://img.shields.io/badge/python-3.11+-blue.svg" alt="python">

</div>

## 📖 介绍

可作为函数调用的Markdown渲染图片插件

> **注意**  
> 若你的Markdown中嵌入了图片,可能会极大增加渲染时间,请耐心等待!

### 直接作为插件使用

安装并配置好插件后,无需额外导入函数,直接在群聊中发送指令即可使用。例如:

发送 `md2img # 标题\n\n这是一段**粗体**文本。`,即可收到渲染后的图片。

### 作为函数调用
你可以直接导入并使用渲染函数:

```python
from nonebot_plugin_markdown2img.renderer import render_markdown_to_base64
# or
# from src.nonebot_plugin_markdown2img.renderer import render_markdown_to_base64

# 渲染Markdown文本为base64图片
markdown_text = "# 标题\n\n这是一段**粗体**文本。"
base64_image = render_markdown_to_base64(markdown_text)
```


## 💿 安装

> **注意**  
> 若遇到缺少`Markdown渲染图片失败,原因:Linkify enabled but not installed.. 请检查日志。`报错,  请额外安装`linkify-it-py`或在`.env`文件中配置`LINKIFY_ENABLED=false`来禁用Linkify功能。

<details open>
<summary>使用 nb-cli 安装</summary>
在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装

    nb plugin install nonebot_plugin_markdown2img

</details>

<details>
<summary>使用包管理器安装</summary>
在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令

<details>
<summary>pip</summary>

    pip install nonebot_plugin_markdown2img
</details>
<details>
<summary>pdm</summary>

    pdm add nonebot_plugin_markdown2img
</details>
<details>
<summary>poetry</summary>

    poetry add nonebot_plugin_markdown2img
</details>
<details>
<summary>conda</summary>

    conda install nonebot_plugin_markdown2img
</details>

打开 nonebot2 项目根目录下的 `pyproject.toml` 文件, 在 `[tool.nonebot]` 部分追加写入

    plugins = ["nonebot_plugin_markdown2img"]

</details>

## ⚙️ 配置

在 nonebot2 项目的`.env`文件中添加下表中的必填配置

| 配置项 | 必填 | 默认值 | 说明 |
|:-----:|:----:|:----:|:----:|
| markdown2img_font_path | 否 | 无 | 字体文件路径 |
| markdown2img_disable_gpu | 否 | True | 是否禁用GPU |
| markdown2img_disable_linkify | 否 | True | 是否禁用Linkify |

## 🎉 使用
### 指令表
| 指令 | 权限 | 需要@ | 范围 | 说明 |
|:-----:|:----:|:----:|:----:|:----:|
| md2img | 群员 | 否 | 群聊 | `md2img` + 想要生成图片的markdown文本 |

### 效果图
![test_markdown_output](test_markdown_output.png)

## 🙏 特别感谢
感谢 [nonebot_plugin_easymarkdown](https://github.com/phquathi/nonebot_plugin_easymarkdown) 项目提供的灵感和参考。

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "nonebot-plugin-markdown2img",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": "ANGJustinl",
    "author_email": "ANGJustinl <angjustinl@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/b9/b0/4f40a1b95fb5a6f7723f8608781ed0664e1f15f1555a36f1b5f3b79c662b/nonebot_plugin_markdown2img-0.0.6.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\n  <a href=\"https://v2.nonebot.dev/store\"><img src=\"https://github.com/A-kirami/nonebot-plugin-template/blob/resources/nbp_logo.png\" width=\"180\" height=\"180\" alt=\"NoneBotPluginLogo\"></a>\n  <br>\n  <p><img src=\"https://github.com/A-kirami/nonebot-plugin-template/blob/resources/NoneBotPlugin.svg\" width=\"240\" alt=\"NoneBotPluginText\"></p>\n</div>\n\n<div align=\"center\">\n\n# nonebot-plugin-markdown2img\n\n_\u2728 \u53ef\u4f5c\u4e3a\u51fd\u6570\u8c03\u7528\u7684Markdown\u6e32\u67d3\u56fe\u7247\u63d2\u4ef6 \u2728_\n\n\n<a href=\"./LICENSE\">\n    <img src=\"https://img.shields.io/github/license/ANGJustinl/nonebot_plugin_markdown2img.svg\" alt=\"license\">\n</a>\n<a href=\"https://pypi.python.org/pypi/nonebot_plugin_markdown2img\">\n    <img src=\"https://img.shields.io/pypi/v/nonebot_plugin_markdown2img.svg\" alt=\"pypi\">\n</a>\n<img src=\"https://img.shields.io/badge/python-3.11+-blue.svg\" alt=\"python\">\n\n</div>\n\n## \ud83d\udcd6 \u4ecb\u7ecd\n\n\u53ef\u4f5c\u4e3a\u51fd\u6570\u8c03\u7528\u7684Markdown\u6e32\u67d3\u56fe\u7247\u63d2\u4ef6\n\n> **\u6ce8\u610f**  \n> \u82e5\u4f60\u7684Markdown\u4e2d\u5d4c\u5165\u4e86\u56fe\u7247\uff0c\u53ef\u80fd\u4f1a\u6781\u5927\u589e\u52a0\u6e32\u67d3\u65f6\u95f4\uff0c\u8bf7\u8010\u5fc3\u7b49\u5f85\uff01\n\n### \u76f4\u63a5\u4f5c\u4e3a\u63d2\u4ef6\u4f7f\u7528\n\n\u5b89\u88c5\u5e76\u914d\u7f6e\u597d\u63d2\u4ef6\u540e\uff0c\u65e0\u9700\u989d\u5916\u5bfc\u5165\u51fd\u6570\uff0c\u76f4\u63a5\u5728\u7fa4\u804a\u4e2d\u53d1\u9001\u6307\u4ee4\u5373\u53ef\u4f7f\u7528\u3002\u4f8b\u5982\uff1a\n\n\u53d1\u9001 `md2img # \u6807\u9898\\n\\n\u8fd9\u662f\u4e00\u6bb5**\u7c97\u4f53**\u6587\u672c\u3002`\uff0c\u5373\u53ef\u6536\u5230\u6e32\u67d3\u540e\u7684\u56fe\u7247\u3002\n\n### \u4f5c\u4e3a\u51fd\u6570\u8c03\u7528\n\u4f60\u53ef\u4ee5\u76f4\u63a5\u5bfc\u5165\u5e76\u4f7f\u7528\u6e32\u67d3\u51fd\u6570\uff1a\n\n```python\nfrom nonebot_plugin_markdown2img.renderer import render_markdown_to_base64\n# or\n# from src.nonebot_plugin_markdown2img.renderer import render_markdown_to_base64\n\n# \u6e32\u67d3Markdown\u6587\u672c\u4e3abase64\u56fe\u7247\nmarkdown_text = \"# \u6807\u9898\\n\\n\u8fd9\u662f\u4e00\u6bb5**\u7c97\u4f53**\u6587\u672c\u3002\"\nbase64_image = render_markdown_to_base64(markdown_text)\n```\n\n\n## \ud83d\udcbf \u5b89\u88c5\n\n> **\u6ce8\u610f**  \n> \u82e5\u9047\u5230\u7f3a\u5c11`Markdown\u6e32\u67d3\u56fe\u7247\u5931\u8d25\uff0c\u539f\u56e0:Linkify enabled but not installed.. \u8bf7\u68c0\u67e5\u65e5\u5fd7\u3002`\u62a5\u9519,  \u8bf7\u989d\u5916\u5b89\u88c5`linkify-it-py`\u6216\u5728`.env`\u6587\u4ef6\u4e2d\u914d\u7f6e`LINKIFY_ENABLED=false`\u6765\u7981\u7528Linkify\u529f\u80fd\u3002\n\n<details open>\n<summary>\u4f7f\u7528 nb-cli \u5b89\u88c5</summary>\n\u5728 nonebot2 \u9879\u76ee\u7684\u6839\u76ee\u5f55\u4e0b\u6253\u5f00\u547d\u4ee4\u884c, \u8f93\u5165\u4ee5\u4e0b\u6307\u4ee4\u5373\u53ef\u5b89\u88c5\n\n    nb plugin install nonebot_plugin_markdown2img\n\n</details>\n\n<details>\n<summary>\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u5b89\u88c5</summary>\n\u5728 nonebot2 \u9879\u76ee\u7684\u63d2\u4ef6\u76ee\u5f55\u4e0b, \u6253\u5f00\u547d\u4ee4\u884c, \u6839\u636e\u4f60\u4f7f\u7528\u7684\u5305\u7ba1\u7406\u5668, \u8f93\u5165\u76f8\u5e94\u7684\u5b89\u88c5\u547d\u4ee4\n\n<details>\n<summary>pip</summary>\n\n    pip install nonebot_plugin_markdown2img\n</details>\n<details>\n<summary>pdm</summary>\n\n    pdm add nonebot_plugin_markdown2img\n</details>\n<details>\n<summary>poetry</summary>\n\n    poetry add nonebot_plugin_markdown2img\n</details>\n<details>\n<summary>conda</summary>\n\n    conda install nonebot_plugin_markdown2img\n</details>\n\n\u6253\u5f00 nonebot2 \u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u7684 `pyproject.toml` \u6587\u4ef6, \u5728 `[tool.nonebot]` \u90e8\u5206\u8ffd\u52a0\u5199\u5165\n\n    plugins = [\"nonebot_plugin_markdown2img\"]\n\n</details>\n\n## \u2699\ufe0f \u914d\u7f6e\n\n\u5728 nonebot2 \u9879\u76ee\u7684`.env`\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4e0b\u8868\u4e2d\u7684\u5fc5\u586b\u914d\u7f6e\n\n| \u914d\u7f6e\u9879 | \u5fc5\u586b | \u9ed8\u8ba4\u503c | \u8bf4\u660e |\n|:-----:|:----:|:----:|:----:|\n| markdown2img_font_path | \u5426 | \u65e0 | \u5b57\u4f53\u6587\u4ef6\u8def\u5f84 |\n| markdown2img_disable_gpu | \u5426 | True | \u662f\u5426\u7981\u7528GPU |\n| markdown2img_disable_linkify | \u5426 | True | \u662f\u5426\u7981\u7528Linkify |\n\n## \ud83c\udf89 \u4f7f\u7528\n### \u6307\u4ee4\u8868\n| \u6307\u4ee4 | \u6743\u9650 | \u9700\u8981@ | \u8303\u56f4 | \u8bf4\u660e |\n|:-----:|:----:|:----:|:----:|:----:|\n| md2img | \u7fa4\u5458 | \u5426 | \u7fa4\u804a | `md2img` + \u60f3\u8981\u751f\u6210\u56fe\u7247\u7684markdown\u6587\u672c |\n\n### \u6548\u679c\u56fe\n![test_markdown_output](test_markdown_output.png)\n\n## \ud83d\ude4f \u7279\u522b\u611f\u8c22\n\u611f\u8c22 [nonebot_plugin_easymarkdown](https://github.com/phquathi/nonebot_plugin_easymarkdown) \u9879\u76ee\u63d0\u4f9b\u7684\u7075\u611f\u548c\u53c2\u8003\u3002\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "\u53ef\u4f5c\u4e3a\u51fd\u6570\u8c03\u7528\u7684Markdown\u6e32\u67d3\u56fe\u7247\u63d2\u4ef6",
    "version": "0.0.6",
    "project_urls": {
        "Homepage": "https://github.com/ANGJustinl/nonebot_plugin_markdown2img",
        "Issues": "https://github.com/ANGJustinl/nonebot_plugin_markdown2img/issues",
        "Repository": "https://github.com/ANGJustinl/nonebot_plugin_markdown2img.git"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "267ad4ff9e1bca8e66bdc8180cc4a561d63a05751a379181fd61e918b4c7b095",
                "md5": "da10d981a5c48434053e5462e1796d6f",
                "sha256": "a268718613b0e6c7b106f2d07f126a221969fa17d38ec40e5de042a8b0e74c8b"
            },
            "downloads": -1,
            "filename": "nonebot_plugin_markdown2img-0.0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "da10d981a5c48434053e5462e1796d6f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 11988,
            "upload_time": "2025-10-28T13:19:48",
            "upload_time_iso_8601": "2025-10-28T13:19:48.753967Z",
            "url": "https://files.pythonhosted.org/packages/26/7a/d4ff9e1bca8e66bdc8180cc4a561d63a05751a379181fd61e918b4c7b095/nonebot_plugin_markdown2img-0.0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b9b04f40a1b95fb5a6f7723f8608781ed0664e1f15f1555a36f1b5f3b79c662b",
                "md5": "241707babc630bb41c852e6794c4eac0",
                "sha256": "0097156b812cf6212781afd739e6ba99cc262b126b2f6fda6cf8b4318e56b63f"
            },
            "downloads": -1,
            "filename": "nonebot_plugin_markdown2img-0.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "241707babc630bb41c852e6794c4eac0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 11493,
            "upload_time": "2025-10-28T13:19:50",
            "upload_time_iso_8601": "2025-10-28T13:19:50.522652Z",
            "url": "https://files.pythonhosted.org/packages/b9/b0/4f40a1b95fb5a6f7723f8608781ed0664e1f15f1555a36f1b5f3b79c662b/nonebot_plugin_markdown2img-0.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-28 13:19:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ANGJustinl",
    "github_project": "nonebot_plugin_markdown2img",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "nonebot-plugin-markdown2img"
}
        
Elapsed time: 3.63134s