特性
- 统一的
render_html、render_text、render_markdown、render_templateAPI Application/Renderer组合边界与可发现的渲染 Provider- Playwright 浏览器、Takumi 原生与实验性 HTMLKit Provider
- 与引擎无关的 Preparation、资源服务和
PreparedHtml RenderedImage/RenderedHtml类型化产物- Playwright、Takumi、Pillow 与 Skia 通过
app.extensions的静态属性直接补全;Playwright/Takumi 还可租借保留上游类型的原生对象 - 有界资源缓存、严格本地路径策略和可选观测集成
安装
本体默认不安装任何位图渲染后端,只提供 Preparation 与模板到 HTML。按需选择一个 HTML 后端(Provider):
uv add "nonebot-plugin-htmlrender[playwright]>=0.8.0,<0.9"
# 或
uv add "nonebot-plugin-htmlrender[takumi]>=0.8.0,<0.9"
# 或(实验性、asyncio-only)
uv add "nonebot-plugin-htmlrender[htmlkit]>=0.8.0,<0.9"
Pillow/Skia 是独立的 RasterScene Capability,不属于 HTML 后端。按需增加pillow、skia、sentry、prometheus;内置 filehost transport 可选增加filehost extra,以使用 py-machineid 派生默认请求头守卫值。all 会安装全部可选能力。
uv add "nonebot-plugin-htmlrender[playwright,filehost,prometheus]>=0.8.0,<0.9"
快速开始
render:
provider: playwright
startup: warmup
resources:
local_access:
allowed_paths: [templates]
from nonebot import require
require("nonebot_plugin_htmlrender")
from nonebot_plugin_htmlrender import render_markdown, render_template
async def demo() -> tuple[bytes, bytes]:
markdown = await render_markdown("# Hello\n\n**NoneBot**", width=720)
card = await render_template(
"templates",
"card.html",
variables={"name": "nonebot"},
width=480,
)
return bytes(markdown), bytes(card)
render_* 返回类型化产物;交给消息适配器时显式使用bytes(artifact),需要 MIME 类型时读取 artifact.media_type。
文档
开发
make prepare
make check
make docs-build
make test-local
make build-artifacts
远程浏览器联调使用 make remote-smoke-build;常规变更可复用镜像执行make remote-smoke。
许可
项目使用 MIT License。启用 Takumi、HTMLKit 或其他第三方 Provider 前,请同时检查其依赖与分发许可;HTMLKit rc5 的 native core 为 LGPL-3.0-or-later。
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nonebot_plugin_htmlrender-0.8.1.tar.gz.
File metadata
- Download URL: nonebot_plugin_htmlrender-0.8.1.tar.gz
- Upload date:
- Size: 3.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
314c75357d8843573d337e0cf698f747eef551b4ffcdc624588eaf13ac22b3a5
|
|
| MD5 |
5195999474cb7ed3fa330dacc9b61d80
|
|
| BLAKE2b-256 |
b05023c063924aba438cc426fffb443d8079060a38c5707435eb75d088069972
|
Provenance
The following attestation bundles were made for nonebot_plugin_htmlrender-0.8.1.tar.gz:
Publisher:
publish.yml on kexue-z/nonebot-plugin-htmlrender
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nonebot_plugin_htmlrender-0.8.1.tar.gz -
Subject digest:
314c75357d8843573d337e0cf698f747eef551b4ffcdc624588eaf13ac22b3a5 - Sigstore transparency entry: 2287306503
- Sigstore integration time:
-
Permalink:
kexue-z/nonebot-plugin-htmlrender@39ae545dc7babcce37b59759283f9b0c760b3c94 -
Branch / Tag:
refs/tags/v0.8.1 - Owner: https://github.com/kexue-z
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@39ae545dc7babcce37b59759283f9b0c760b3c94 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file nonebot_plugin_htmlrender-0.8.1-py3-none-any.whl.
File metadata
- Download URL: nonebot_plugin_htmlrender-0.8.1-py3-none-any.whl
- Upload date:
- Size: 1.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ebf503834c9b0c6e397a1c0a172c4b71dbce2b4e8dad7c8b893b92c04b9193e8
|
|
| MD5 |
36cd6955799183c1dcd05e78f83152fc
|
|
| BLAKE2b-256 |
fde4050e5ea0ffbc05667d0cd5e0afc93d80571723d1da842a10aeb46a53b363
|
Provenance
The following attestation bundles were made for nonebot_plugin_htmlrender-0.8.1-py3-none-any.whl:
Publisher:
publish.yml on kexue-z/nonebot-plugin-htmlrender
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nonebot_plugin_htmlrender-0.8.1-py3-none-any.whl -
Subject digest:
ebf503834c9b0c6e397a1c0a172c4b71dbce2b4e8dad7c8b893b92c04b9193e8 - Sigstore transparency entry: 2287306524
- Sigstore integration time:
-
Permalink:
kexue-z/nonebot-plugin-htmlrender@39ae545dc7babcce37b59759283f9b0c760b3c94 -
Branch / Tag:
refs/tags/v0.8.1 - Owner: https://github.com/kexue-z
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@39ae545dc7babcce37b59759283f9b0c760b3c94 -
Trigger Event:
workflow_dispatch
-
Statement type: