Skip to main content

Lightweight HTML rendering plugin for NoneBot

Project description

nonebot-plugin-htmlkit

一个基于 litehtml 的轻量级 HTML 渲染插件。

特性

  • 基于 fontconfig 的字体管理, 支持系统字体和自定义字体
  • 提供了 HTML,纯文本,markdown,和 Jinja2 模板渲染的快捷函数
  • 支持自定义图片和 CSS 的加载策略
  • 支持通过 CSS 控制样式
  • 支持自适应控制渲染宽度

安装

使用 nb-cli 安装:

nb plugin install nonebot-plugin-htmlkit

或者,使用你选择的 Python 包管理器工具安装 nonebot-plugin-htmlkit 即可。

使用

API

from nonebot import require

require("nonebot_plugin_htmlkit")
from nonebot_plugin_htmlkit import (
    text_to_pic,
    md_to_pic,
    template_to_pic,
    html_to_pic,
)

[!CAUTION] 注意:请先 require("nonebot_plugin_htmlkit") 后再 import 插件!!!

配置项

plugin-htmlkit 的配置项主要为 fontconfig 的相关配置。

对于 FC/FONTCONFIG 开头的配置项,请参考 fontconfig 文档 以了解更多。

# ===============================
# Fontconfig 配置
# ===============================

# FONTCONFIG_FILE
# 用于覆盖默认的配置文件路径。
FONTCONFIG_FILE: str

# FONTCONFIG_PATH
# 用于覆盖默认的配置目录。
FONTCONFIG_PATH: str

# FONTCONFIG_SYSROOT
# 用于设置默认的 sysroot 目录。
FONTCONFIG_SYSROOT: str

# FC_DEBUG
# 用于输出详细的调试信息。
# 详细见 fontconfig 文档。
FC_DEBUG: str

# FC_DBG_MATCH_FILTER
# 用于在调试时过滤特定模式。
# 仅当 FC_DEBUG 设置为 MATCH2 时生效。
FC_DBG_MATCH_FILTER: str

# FC_LANG
# 用于指定查询时的默认语言(弱绑定)。
# 如果未设置,则从当前 locale 推导。
FC_LANG: str

# FONTCONFIG_USE_MMAP
# 控制是否使用 mmap(2) 来处理缓存文件(如果可用)。
# 值为布尔类型(yes/no, 1/0)。
# 如果显式设置该变量,将跳过系统检查并强制启用或禁用。
FONTCONFIG_USE_MMAP: str

构建说明

受限于 XMake, 构建时须使用 Python 3.10.11,并且在 uv sync 时需一同安装 build 组的依赖(pip setuptools wheel 等)。

许可证

本插件的 Python 部分(所有 .py 文件)在 MIT 许可证下发布,C++ 部分在 LGPL-3.0-or-later 许可证下发布。

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_htmlkit-0.1.0rc1.tar.gz (45.5 kB view details)

Uploaded Source

Built Distributions

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

nonebot_plugin_htmlkit-0.1.0rc1-cp310-abi3-win_amd64.whl (3.0 MB view details)

Uploaded CPython 3.10+Windows x86-64

nonebot_plugin_htmlkit-0.1.0rc1-cp310-abi3-manylinux_2_34_x86_64.whl (5.6 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.34+ x86-64

nonebot_plugin_htmlkit-0.1.0rc1-cp310-abi3-manylinux_2_34_aarch64.whl (5.3 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.34+ ARM64

nonebot_plugin_htmlkit-0.1.0rc1-cp310-abi3-macosx_11_0_arm64.whl (4.2 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

Details for the file nonebot_plugin_htmlkit-0.1.0rc1.tar.gz.

File metadata

File hashes

Hashes for nonebot_plugin_htmlkit-0.1.0rc1.tar.gz
Algorithm Hash digest
SHA256 8cd6c1f84b69532c6a914fd2d2cdd3e245d448bb9b19a5f56f66faa5f67f672f
MD5 d976123e09e6e7e52625a66cbc5cec52
BLAKE2b-256 bfa06c34e909ed78b085c51a5ae2a5072e6bbb66a67187a0ba55f1a3e95d2438

See more details on using hashes here.

File details

Details for the file nonebot_plugin_htmlkit-0.1.0rc1-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for nonebot_plugin_htmlkit-0.1.0rc1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 979af2d5e8cbe2fad3b9e952bb990b6106a7d326e26eada1640c0d82d0efaf22
MD5 ec52a83da17af3588251017e6f659223
BLAKE2b-256 c4489f43d5dc800afcbbcedd7ceb4dd2d52881c57e8d22a5d873295266b14ab1

See more details on using hashes here.

File details

Details for the file nonebot_plugin_htmlkit-0.1.0rc1-cp310-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for nonebot_plugin_htmlkit-0.1.0rc1-cp310-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 d1f69f7be0b81b4e97778080e14275d10713b0cff022493d7cd01af841a543d0
MD5 cb338842bcb4de5acdbb5d8e340ea609
BLAKE2b-256 51f2b3b938aa88a74b53759a9e8d574c59d30bfaef18928680e2d850cc095d5f

See more details on using hashes here.

File details

Details for the file nonebot_plugin_htmlkit-0.1.0rc1-cp310-abi3-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for nonebot_plugin_htmlkit-0.1.0rc1-cp310-abi3-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 40df2ed39b3d0899806f0fb39175fddd792df79d5eb7baf0b3cca03a2a4d51a4
MD5 027bef9395db3f8df5064babb14cbc29
BLAKE2b-256 0eb5e595cd76419392d51ebd6046f714becf1641fdfe39878a4ca07635309578

See more details on using hashes here.

File details

Details for the file nonebot_plugin_htmlkit-0.1.0rc1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nonebot_plugin_htmlkit-0.1.0rc1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6084bf859ba6f24c493d27d15d7dad52cbe34dc2fa867d65105c2adea23c065e
MD5 1bf2ccd5fb1ce6b446c548af4532b69a
BLAKE2b-256 547d1a1c93853417f9acc5b2384d9c287a9db422453c27bce86c949d95f7997b

See more details on using hashes here.

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