Skip to main content
nonebot-plugin-htmlrender

nonebot-plugin-htmlrender

面向 NoneBot 的可插拔 HTML 渲染库

PyPI Python License Docs

特性

  • 统一的 render_htmlrender_textrender_markdownrender_template API
  • 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 后端。按需增加pillowskiasentryprometheus;内置 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

nonebot_plugin_htmlrender-0.8.1.tar.gz (3.0 MB view details)

Uploaded Source

Built Distribution

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

nonebot_plugin_htmlrender-0.8.1-py3-none-any.whl (1.3 MB view details)

Uploaded Python 3

File details

Details for the file nonebot_plugin_htmlrender-0.8.1.tar.gz.

File metadata

File hashes

Hashes for nonebot_plugin_htmlrender-0.8.1.tar.gz
Algorithm Hash digest
SHA256 314c75357d8843573d337e0cf698f747eef551b4ffcdc624588eaf13ac22b3a5
MD5 5195999474cb7ed3fa330dacc9b61d80
BLAKE2b-256 b05023c063924aba438cc426fffb443d8079060a38c5707435eb75d088069972

See more details on using hashes here.

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

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_htmlrender-0.8.1-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_plugin_htmlrender-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ebf503834c9b0c6e397a1c0a172c4b71dbce2b4e8dad7c8b893b92c04b9193e8
MD5 36cd6955799183c1dcd05e78f83152fc
BLAKE2b-256 fde4050e5ea0ffbc05667d0cd5e0afc93d80571723d1da842a10aeb46a53b363

See more details on using hashes here.

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

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

Release history Release notifications | RSS feed

This release

0.8.1 This release

2 files

0.7.2

2 files

0.7.1

2 files

0.7.0

2 files

0.6.8

2 files

0.6.7

2 files

0.6.6

2 files

0.6.5

2 files

0.6.3

2 files

0.6.2

2 files

0.6.1

2 files

0.6.0

2 files

0.5.1

2 files

0.5.0

2 files

0.4.0

2 files

0.3.5

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0.3

2 files

0.2.0.2

2 files

0.2.0.1

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

2 files

0.0.5

2 files

0.0.4.8

2 files

0.0.4.6

2 files

0.0.4.5

2 files

0.0.4.4

2 files

0.0.4.3

2 files

0.0.4.2

2 files

0.0.4.1

2 files

0.0.4

2 files

0.0.3.1

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Supported by

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