返回顶部
T

Table2Image表格转图片

Convert markdown tables and JSON data to PNG images. Perfect for Discord, Telegram, and other platforms where markdown tables render poorly. Use when Claude needs to present tabular data in a visually appealing format, when sending tables to Discord/Telegram/WhatsApp, or when the user asks to convert a table to an image. Supports multiple themes (discord-light, discord-dark, finance, minimal), conditional formatting, and automatic markdown table detection.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.1.0
安全检测
已通过
136
下载量
免费
免费
1
收藏
概述
安装方式
版本历史

Table2Image

Table2Image

🇬🇧 English | 🇨🇳 中文

将表格转换为漂亮的PNG图片,适用于聊天平台。

GitHub: https://github.com/UMRzcz-831/table-to-image-skill

技术栈: Playwright + Chromium,实现完美的表情符号和字体渲染。

前置条件

  • - Node.js: >= 18.0.0
  • 网络: 首次运行需要网络连接(Chromium下载约100MB)

安装

bash

安装依赖


npm install

下载Chromium(一次性,约100MB)

npx playwright install chromium

性能

指标时间
首次运行(Chromium下载)~30-60秒(一次性)
浏览器启动(首次渲染)
~2-3秒 | | 后续渲染 | < 500毫秒(浏览器复用) |

💡 提示: 首次渲染后浏览器实例会自动复用,使后续表格生成几乎瞬间完成。

快速开始

方法一:命令行(适用于简单表格)

bash

将JSON数据转换为表格图片


echo [{name:Alice,score:95}] | node scripts/table-cli.mjs --dark --output table.png

或使用JSON文件

node scripts/table-cli.mjs --data-file data.json --theme discord-dark --output table.png

方法二:编程API(推荐)

typescript
import { renderTable, renderDiscordTable } from ./scripts/index.js;

// 快速生成Discord表格
const image = await renderDiscordTable(
[{ name: AAPL, change: +2.5% }],
[
{ key: name, header: 股票 },
{ key: change, header: 涨跌幅, align: right }
],
📊 市场观察
);

// 发送到Discord
await message.send({ attachment: image.buffer });

方法三:自动转换Markdown表格

typescript
import { autoConvertMarkdownTable } from ./scripts/index.js;

// 自动检测并转换
const result = await autoConvertMarkdownTable(message, discord);
if (result.converted) {
await message.send({ attachment: result.image });
}

何时使用此技能

  • - Discord/Telegram/WhatsApp: 这些平台对Markdown表格渲染不佳
  • 金融数据: 股票价格、投资组合报告(带条件格式)
  • 排行榜: 带奖牌和颜色编码排名的榜单
  • 对比表格: 并排功能对比
  • 任何表格数据: 当视觉呈现很重要时

主题

主题最佳用途预览
discord-lightDiscord浅色模式(默认)discord-light
discord-dark
Discord深色模式 | discord-dark | | finance | 财务报告 | finance | | minimal | 简洁/简约 | minimal | | sweet-pink | 时尚深色+粉色点缀 | sweet-pink | | deep-sea | 经典蓝色+奶油白 | deep-sea | | wisteria | 复古紫色+青柠绿 | wisteria | | pond-blue | 深海军蓝+柔和青色 | pond-blue | | camellia | 暖红+淡粉 | camellia |

自定义主题

您也可以直接将自定义主题对象传递给theme。为方便起见,您只需提供两种颜色——primary和secondary——完整主题将自动生成:

typescript
const image = await renderTable({
data: [{ name: Alice, score: 95 }],
columns: [
{ key: name, header: 姓名 },
{ key: score, header: 分数, align: right }
],
theme: {
primary: #e6397c, // 强调色(表头、文字、边框)
secondary: #1a1a1d // 基础色(背景、行)
}
});

custom-primary-secondary

或者传递包含全部7种颜色的完整自定义主题对象:

typescript
const image = await renderTable({
data: [{ name: Alice, score: 95 }],
columns: [...],
theme: {
background: #1a1a1d,
headerBg: #e6397c,
headerText: #1a1a1d,
rowBg: #1a1a1d,
rowAltBg: #2a2a2d,
text: #e6397c,
border: #e6397c
}
});

custom-full

高级用法

条件格式

typescript
import { renderTable } from ./scripts/index.js;

const image = await renderTable({
data: stocks,
columns: [
{ key: symbol, header: 代码 },
{
key: change,
header: 涨跌幅,
align: right,
formatter: (v) => ${v > 0 ? + : }${v}%,
style: (v) => ({ color: v > 0 ? #43b581 : #f04747 })
}
],
theme: discord-dark
});

自定义列宽

typescript
columns: [
{ key: name, header: 名称, width: 150 },
{ key: description, header: 描述, width: 300, wrap: true, maxLines: 3 }
]

脚本

  • - scripts/table-cli.mjs - 命令行界面
  • scripts/index.js - 编程API

完整API文档请参见references/api.md。

示例

常见用例和代码示例请参见references/examples.md。

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 markdowntable2image-1775976434 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 markdowntable2image-1775976434 技能

通过命令行安装

skillhub install markdowntable2image-1775976434

下载

⬇ 下载 Table2Image v1.1.0(免费)

文件大小: 19.65 KB | 发布时间: 2026-4-13 10:56

v1.1.0 最新 2026-4-13 10:56
- Added 5 new built-in table themes: sweet-pink, deep-sea, wisteria, pond-blue, camellia.
- Introduced support for custom theme objects with automatic theme generation based on primary and secondary colors.
- Updated documentation to include previews and details for new and custom themes.
- No breaking changes; previous theme names and API usage remain compatible.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部