Skip to main content

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

Project description

NoneBotPluginLogo

NoneBotPluginText

nonebot-plugin-markdown2img

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

license pypi python

📖 介绍

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

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

直接作为插件使用

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

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

作为函数调用

你可以直接导入并使用渲染函数:

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功能。

使用 nb-cli 安装 在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装
nb plugin install nonebot_plugin_markdown2img
使用包管理器安装 在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令
pip
pip install nonebot_plugin_markdown2img
pdm
pdm add nonebot_plugin_markdown2img
poetry
poetry add nonebot_plugin_markdown2img
conda
conda install nonebot_plugin_markdown2img

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

plugins = ["nonebot_plugin_markdown2img"]

⚙️ 配置

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

配置项 必填 默认值 说明
font_path 字体文件路径
disable_gpu True 是否禁用GPU
disable_linkify True 是否禁用Linkify
browser "chrome" 指定使用的浏览器类型, 可选值有 "chrome", "edge", "firefox" 等
browser_executable None 指定浏览器可执行文件的路径 (Windows比较常见的有 C:\Program Files (x86)\Microsoft\Edge\Application)

🎉 使用

指令表

指令 权限 需要@ 范围 说明
md2img 群员 群聊 md2img + 想要生成图片的markdown文本

效果图

test_markdown_output

🙏 特别感谢

感谢 nonebot_plugin_easymarkdown 项目提供的灵感和参考。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nonebot_plugin_markdown2img-0.0.4.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nonebot_plugin_markdown2img-0.0.4-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_plugin_markdown2img-0.0.4.tar.gz.

File metadata

File hashes

Hashes for nonebot_plugin_markdown2img-0.0.4.tar.gz
Algorithm Hash digest
SHA256 3a8b891b0f148dc4cc9cac619f62b8f37875cfd8143fa7f9fae0ca086d8169a9
MD5 229529d62bc8f213f61a9b258a3fc439
BLAKE2b-256 6b9d31bcd73c125a4676ccee7cb89de5322b54fb670178882b02c704d2454bff

See more details on using hashes here.

Provenance

The following attestation bundles were made for nonebot_plugin_markdown2img-0.0.4.tar.gz:

Publisher: release.yml on ANGJustinl/nonebot_plugin_markdown2img

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nonebot_plugin_markdown2img-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_plugin_markdown2img-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c75aea877fbd01baf9724b0cb3fce4fe4e9d989de39275d082968b6dcb65784f
MD5 5f9ac40c7155487e0e2d38825fc54954
BLAKE2b-256 2a69f1552079bf7b41eb65f2956c31d2821af0372f4965f64d0ea43cab5a05a7

See more details on using hashes here.

Provenance

The following attestation bundles were made for nonebot_plugin_markdown2img-0.0.4-py3-none-any.whl:

Publisher: release.yml on ANGJustinl/nonebot_plugin_markdown2img

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page