Skip to main content

entari-plugin-htmlrender

Entari 的 provider-neutral HTML、Markdown、模板与栅格场景渲染库。

普通调用收口为四个显式 contract:HtmlRenderer rasterize 内容,TemplateRenderer render 模板 HTML,ResourceAccess fetch/publish 资源,GraphicsRenderer rasterize RasterScene。Entari 只负责组合并拥有 HtmlRenderService 的生命周期;业务代码不查找默认 runtime。

安装

Python 版本要求保持为 >=3.10,<4.0。按实际能力选择 extra:

uv add "entari-plugin-htmlrender[playwright]>=0.1.0,<0.2"
uv run playwright install chromium
# 或选择:takumi / pillow / skia / filehost / sentry / prometheus

Entari 配置中的插件短名为 htmlrender,字段直接对应 HtmlRenderConfig:

plugins:
  htmlrender:
    provider: playwright
    startup: probe
    provider_config:
      engine: chromium
    graphics:
      backend: pillow

provider 可为 playwright、takumi、第三方 Provider ID 或 null。Pillow/Skia 实现独立的 Graphics contract,不属于 HTML Provider。

常用 API

在 Entari handler 中让 DI 注入 concrete HtmlRenderService:

from entari_plugin_htmlrender import (
    RasterOptions,
    RenderedImage,
)
from entari_plugin_htmlrender.entari import HtmlRenderService


async def build_card(service: HtmlRenderService) -> RenderedImage:
    return await service.renderer.rasterize_markdown(
        "# Hello, Entari",
        raster=RasterOptions(width=720),
    )

框架无关的业务函数应进一步收窄为它真正需要的 contract:

from entari_plugin_htmlrender import HtmlRenderer, RenderedImage


async def render_badge(renderer: HtmlRenderer) -> RenderedImage:
    return await renderer.rasterize_html("<b>ready</b>")

HtmlRenderService 直接暴露 .renderer、.templates、.resources、.graphics 与 .capabilities。Playwright/Takumi 原生对象只通过service.capabilities 的显式 lease 使用;Pillow/Skia 的选择留在配置中,调用方始终使用 service.graphics。

生命周期

插件通过 Entari add_service 注册 HtmlRenderService。Launart 在 preparing阶段启动所需 filehost 并按 startup 策略启动/探测 Provider;在 cleanup 阶段停止接纳新操作、排空在途操作、关闭 runtime,最后关闭 filehost。热卸载复用同一边界,业务代码不调用 service 的内部启动或关闭方法。

文档与示例

License

项目使用 MIT License。启用第三方 Provider 或 native backend 前,请同时检查其依赖与分发许可。

Metadata

Release files for entari-plugin-htmlrender 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for entari-plugin-htmlrender 0.1.0
File Size Uploaded
entari_plugin_htmlrender-0.1.0.tar.gz 2.9 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for entari-plugin-htmlrender 0.1.0
File Interpreter ABI Platform
entari_plugin_htmlrender-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 4.2 MB

Release files / entari_plugin_htmlrender-0.1.0.tar.gz

Download URL entari_plugin_htmlrender-0.1.0.tar.gz
Size 2.9 MB
Tags Source
SHA-256 checksum
How to use checksums
95e582d7d1f5f9e538ef667306d21edea8361990e694cbbad36080918d820cf4
BLAKE2b-256 checksum
How to use checksums
d0a01383d39294d24113912d8bce011032642da0fbcbb8e3b8895cea54ec272f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 14, 2026.

Transparency log

Release files / entari_plugin_htmlrender-0.1.0-py3-none-any.whl

Download URL entari_plugin_htmlrender-0.1.0-py3-none-any.whl
Size 1.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
c982d3e8846f80598d66bd5039810d0d21303070b8a153014457ec4a6782c9fb
BLAKE2b-256 checksum
How to use checksums
0dd1229c5569dc41eb5ab82ae94b2ca98803f266c6f2390712dd094173024694
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 14, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page