Xpersona
M

Md To Share

CLAWHUB · Unverified

将 Markdown 文件转换为原生长图的 skill,可被 OpenClaw、Claude Code 等 AI Agent 直接调用。A skill that converts Markdown to long images, callable by AI Agents like OpenClaw and Cl... Skill: Md To Share Owner: dtacheng Summary: 将 Markdown 文件转换为原生长图的 skill,可被 OpenClaw、Claude Code 等 AI Agent 直接调用。A skill that converts Markdown to long images, callable by AI Agents like OpenClaw and Cl... Tags: image:1.0.0, latest:2.2.0, markdown:1.0.0, share:1.0.0 Version history: v2.2.0 | 2026-03-28T17:42:06.186Z | user v2.0: Migrate from puppeteer-core to Playwright (bundled Chromium, no system browser needed). v2

62
Rank
84
Safety
1.1k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.1K downloads reported by the source. Last updated 10/11/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s17bg152wk3rk1rf4vpekm44x583r0hz:md-to-share
  1. Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-dtacheng-md-to-share/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

84,999 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: md-to-share
version: 2.2.0
description: "将 Markdown 文件转换为原生长图的 skill,可被 OpenClaw、Claude Code 等 AI Agent 直接调用。A skill that converts Markdown to long images, callable by AI Agents like OpenClaw and Claude Code."
author: DTacheng
license: MIT
---

# MD to Share / MD 转长图

A skill that converts Markdown files to long images, directly callable by AI Agents like OpenClaw and Claude Code. Perfect for sharing on WeChat, Discord, and other platforms.

将 Markdown 文件转换为原生长图的 skill,可使用 OpenClaw、Claude Code 等 AI Agent 直接调用。方便分享到微信、Discord 等平台。

## Features / 特点

- **Environment Auto-Detection**: Automatically detects OpenClaw vs Claude Code and applies optimal settings
- **High Resolution**: Configurable width up to 1600px (2x scale factor) for crisp display
- **Auto Theme**: Light mode (6:00-18:00) / Dark mode (18:00-6:00) based on time
- **Discord Optimized**: JPEG format at 85% quality, auto-splits large files
- **Self-Contained**: Bundled Chromium via Playwright — no system browser needed
- **Smart Splitting**: Splits at semantic boundaries (headings, hr) not mid-paragraph
- **Robust Error Handling**: Clear exit codes for AI agents to understand failures

- **环境自动检测**:自动检测 OpenClaw 或 Claude Code 环境,应用最优设置
- **高分辨率**:可配置宽度最高 1600px(2x 缩放因子),在所有平台上清晰显示
- **自动主题**:根据时间自动切换浅色(6:00-18:00)/ 深色(18:00-6:00)模式
- **Discord 优化**:JPEG 格式 85% 质量,自动切分大文件
- **独立运行**:内置 Playwright Chromium,无需系统安装浏览器
- **智能切分**:在语义边界(标题、分隔线)处切分,不会在段落中间
- **健壮错误处理**:清晰的退出码,方便 AI Agent 理解错误

## Quick Start / 快速使用

Use this skill when user asks to "forward", "convert to image", "share", "generate long image".

当用户要求"转发"、"转成图片"、"方便分享"、"生成长图"时使用此 skill。

## ⚠️ Decision Flow for Agents / Agent 决策流程

**IMPORTANT: Before calling md2img, determine the target channel first.**

```
用户要求生成图片
  ├── 明确要发到 Discord → 使用 --channel=discord(自动切图,确保清晰)
  ├── 明确要发到 WeChat  → 使用 --channel=wechat(保留长图,微信原生支持)
  ├── 明确要发到 iMessage → 使用 --channel=imessage(保留长图)
  ├── 本地使用 / 保存文件  → 使用 --channel=local(保留长图)
  └── 不确定目标渠道      → ❗ 先反问用户确认渠道,再执行
```

**Why this matters**: Discord has strict image dimension limits (images taller than ~2000px get scaled down to unreadable sizes). WeChat and iMessage handle long images natively — splitting would break the reading experience.

**为什么这很重要**:Discord 对图片尺寸有严格限制(超过 ~2000px 高的图会被缩放到无法阅读)。微信和 iMessage 原生支持长图 — 切分反而会破坏阅读体验。

## Usage / 使用方法

### 1. Convert Command / 转换命令

```bash
md2img <input.md> [output] [options]
```

**Options / 选项:**

| Option | Description | Default |
|--------|-------------|---------|
| `--preset=<name>` | Configuration preset: `openclaw` \| `generic` | Auto-detect |
| `--channel=<name>` | Target channel: `discord` \| `wechat` \| `imessage` \| `local` | None |
| `--width=<px>` | CSS width in pixels | Preset value |
| `--scale=<factor>` | Device scale factor | 2 |
| `--max-size=<MB>` | Max file size before splitting | Preset value |
| `--max-height=<px>` | Max pixel height per image | Channel value |
| `--quality=<1-100>` | JPEG quality | 85 |
| 

README.md

# MD to Share

[中文](#中文) | [English](#english)

---

## 中文

将 Markdown 文件转换为原生长图的 skill,可使用 OpenClaw、Claude Code 等 AI Agent 直接调用。方便分享到微信、Discord 等平台。

### 安装

```bash
git clone https://github.com/DTacheng/md-to-share.git
cd md-to-share
npm install
```

### 使用方法

```bash
# 基本用法(默认输出 JPEG 格式)
node md2img.mjs <输入文件.md> [输出文件]

# 示例
node md2img.mjs "~/Downloads/文档.md"
node md2img.mjs "~/Downloads/文档.md" "~/Downloads/输出.jpg"
node md2img.mjs "~/Downloads/文档.md" "~/Downloads/输出.png"
```

也可以添加全局命令:
```bash
npm link
md2img <输入文件.md> [输出文件]
```

### 特点

- **高分辨率输出**:1600px 宽度(2x 缩放因子),在所有平台上清晰显示
- **自动主题切换**:根据时间自动切换浅色(6:00-18:00)/ 深���(18:00-6:00)模式
- **Discord 优化**:JPEG 格式 85% 质量,自动切分 >8MB 的文件
- **跨平台支持**:自动检测 macOS、Linux、Windows 上的 Chrome
- **智能切分**:在语义边界(标题、分隔线)处切分,不在段落中间
- **健壮错误处理**:清晰的退出码,方便 AI Agent 理解错误
- **原生长图**:真正的文档流排版,不是 PPT 分页拼接
- **美观排版**:使用系统字体,支持表���、代码块、引用、列表等

### 输出格式

- `.jpg` / `.jpeg` - JPEG 格式(默认,文件更小,推荐用于 Discord)
- `.png` - PNG 格式(无损,文件更大)

### 退出码

| 代码 | 描述 |
|------|------|
| 0 | 成功 |
| 1 | 参数无效 |
| 2 | 文件未找到 |
| 3 | 文件读取错误 |
| 4 | Chrome 未找到 |
| 5 | 浏览器启动错误 |
| 6 | 渲染错误 |
| 7 | 截图错误 |
| 8 | 输出写入错误 |

### 环境变量

| 变量 | 描述 |
|------|------|
| `CHROME_PATH` | 覆盖 Chrome 可执行文件路径 |

### 样式说明

生成的长图样式:
- 标题:大字号,红色底部边框
- 二级标题:蓝色左侧边框
- 表格:斑马纹,悬停高亮
- 代码块:深色背景
- 行内代码:浅灰背景,红色文字
- 引用:蓝色边框 + 浅灰背景
- 分隔线:优雅分割

### 依赖

- Node.js 18+
- puppeteer-core
- marked
- Google Chrome 或 Chromium(使用系统已安装的浏览器)

---

## English

A skill that converts Markdown files to long images, directly callable by AI Agents like OpenClaw and Claude Code. Perfect for sharing on WeChat, Discord, and other platforms.

### Installation

```bash
git clone https://github.com/DTacheng/md-to-share.git
cd md-to-share
npm install
```

### Usage

```bash
# Basic usage (defaults to JPEG format)
node md2img.mjs <input.md> [output]

# Examples
node md2img.mjs "~/Downloads/document.md"
node md2img.mjs "~/Downloads/document.md" "~/Downloads/output.jpg"
node md2img.mjs "~/Downloads/document.md" "~/Downloads/output.png"
```

You can also add it as a global command:
```bash
npm link
md2img <input.md> [output]
```

### Features

- **High Resolution Output**: 1600px width (2x scale factor) for crisp display on all platforms
- **Auto Theme Switching**: Light mode (6:00-18:00) / Dark mode (18:00-6:00) based on time
- **Discord Optimized**: JPEG format at 85% quality, auto-splits files >8MB
- **Cross-Platform Support**: Auto-detects Chrome on macOS, Linux, and Windows
- **Smart Splitting**: Splits at semantic boundaries (headings, hr) not mid-paragraph
- **Robust Error Handling**: Clear exit codes for AI agents to understand failures
- **Native Long Image**: True document flow layout, not PPT page stitching
- **Beautiful Typography**: System fonts with support for tables, code blocks, blockquotes, lists

### Output Formats

- `.jpg` / `.jpeg` - JPEG format (default, smaller files, recommended for Discord)
- `.png` - PNG format (lossless, larger files)

### Exit Codes

| Code | Description |
|

_meta.json

{
  "ownerId": "kn78etzn9tw1kdwsme5pnybtf5828eer",
  "slug": "md-to-share",
  "version": "2.2.0",
  "publishedAt": 1774719726186
}

CLAUDE.md

# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

MD to Share is a Markdown-to-long-image converter. It converts `.md` files to JPEG/PNG images using Playwright's bundled Chromium for rendering. Designed to be callable by AI Agents (OpenClaw, Claude Code).

## Commands

```bash
# Install dependencies (automatically installs Playwright Chromium)
npm install

# Convert markdown to image
node md2img.mjs <input.md> <output.jpg>

# With options
node md2img.mjs report.md report.jpg --preset=openclaw --theme=dark --timeout=60000

# Or use global command after npm link
npm link
md2img <input.md> <output.jpg>
```

## Architecture

Single-file architecture in `md2img.mjs`:
1. Reads markdown file → parses with `marked`
2. Wraps HTML in styled template with theme system (light/dark auto-detect)
3. Launches isolated Chromium via Playwright (bundled, no system Chrome needed)
4. Creates browser context with `deviceScaleFactor` for high-DPI rendering
5. Screenshots full page to JPEG/PNG
6. Auto-splits large images at semantic boundaries (h1/h2/hr)

**Key design**: Uses Playwright's bundled Chromium, completely independent of any system browser. This prevents conflicts when running alongside OpenClaw's Chrome MCP instance.

## Dependencies

- Node.js 18+
- playwright (bundles its own Chromium — no system browser required)
- marked (markdown parser)

## Environment Variables

- `CHROME_PATH` — Optional: override Playwright's bundled Chromium with a custom executable
- `MD2IMG_TIMEOUT` — Optional: override default 30s timeout (in ms)

## Exit Codes

AI agents should check these for error handling:
- 0: Success
- 1-3: Input errors (args, file not found, read error)
- 4: Browser not available (run `npx playwright install chromium`)
- 5: Browser launch failed
- 6-7: Render/screenshot errors
- 8: Output write error

IMAGE_QUALITY_INVESTIGATION.md

# md-to-share Skill 调研报告:图片清晰度问题分析与优化建议

## 问题描述

用户使用 `md-to-share` skill 生成 Markdown 长图发送到手机时,收到的图片**远远小于预期的 1600px 宽度**,清晰度不足,且图片没有被切分。

## 核心发现

### 发现 1:OpenClaw 有两层独立的图片压缩机制

当 skill 生成的图片通过 OpenClaw 发送到消息渠道时,会经过**两个独立的压缩层**:

| 压缩层 | 位置 | 默认限制 | 触发条件 |
|--------|------|----------|----------|
| **Agent 图片清理** | `src/agents/tool-images.ts` | `1200px`, 5MB | Agent 返回包含 base64 图片的 tool result |
| **媒体加载优化** | `src/web/media.ts` | 6MB → 逐步缩小到 800px | 通过 `loadWebMedia()` 加载图片发送到渠道 |

### 发现 2:md2img.mjs 的配置与 OpenClaw 限制不匹配

**md2img.mjs 的配置** (`md2img.mjs:28-44`):
```javascript
const CONFIG = {
  width: 800,              // CSS 像素
  deviceScaleFactor: 2,    // 实际输出 1600px
  jpegQuality: 85,
  maxFileSizeMB: 8,        // Discord 限制
};
```

**问题**:
- md2img 生成 1600px 宽度的图片
- OpenClaw Agent 层默认限制 `1200px`,会将图片缩小
- 如果图片超过 6MB,媒体加载层会进一步从 2048px → 800px 逐步缩小

### 发现 3:图片切分逻辑在 skill 层无效

md2img.mjs 的切分逻辑(第 524-588 行)基于文件大小(8MB)触发,但:
1. OpenClaw 的压缩在**内存中**处理 base64 数据
2. 压缩逻辑优先检查**尺寸**而非文件大小
3. 即使 skill 输出多个切分文件,每个文件仍会被独立压缩

### 发现 4:用户无法通过配置绕过压缩

| 配置项 | 作用域 | 能否解决清晰度问题 |
|--------|--------|-------------------|
| `agents.defaults.imageMaxDimensionPx` | Agent 层 | 部分解决(但媒体加载层仍会压缩) |
| `agents.defaults.mediaMaxMb` | Agent 层 | 只影响大小限制,不影响尺寸 |
| 渠道级 `mediaMaxMb` | 渠道层 | 只影响大小限制,不影响尺寸 |

**关键问题**:OpenClaw 没有提供 "发送原始图片不压缩" 的配置选项。

## 技术细节

### 压缩流程详解

```
Skill 生成图片 (1600px)
    ↓
Agent Tool Result (base64)
    ↓
[第一层] sanitizeContentBlocksImages() ← src/agents/tool-images.ts:269-335
    │  限制: maxDimensionPx=1200, maxBytes=5MB
    │  使用 buildImageResizeSideGrid() 逐步缩小
    │  尺寸网格: [sideStart, 1800, 1600, 1400, 1200, 1000, 800]
    │  质量网格: [85, 75, 65, 55, 45, 35]
    ↓
消息发送 → loadWebMedia()
    ↓
[第二层] optimizeImageToJpeg() ← src/web/media.ts:426-491
    │  限制: MAX_IMAGE_BYTES=6MB
    │  尺寸网格: [2048, 1536, 1280, 1024, 800]
    │  质量网格: [80, 70, 60, 50, 40]
    │  如果图片 > 6MB,从 2048px 开始逐步缩小
    ↓
发送到渠道 (Telegram/Discord/WhatsApp 等)
```

### 关键代码位置

1. **Agent 图片清理入口**:
   - `src/agents/tool-images.ts:269` - `sanitizeContentBlocksImages()`
   - `src/agents/image-sanitization.ts:8-9` - 默认限制常量

2. **媒体加载优化入口**:
   - `src/web/media.ts:404` - `loadWebMedia()`
   - `src/web/media.ts:426` - `optimizeImageToJpeg()`
   - `src/media/constants.ts:1` - `MAX_IMAGE_BYTES = 6MB`

3. **尺寸/质量网格**:
   - `src/media/image-ops.ts:15-20` - Agent 层网格
   - `src/web/media.ts:445-446` - 媒体加载层网格

4. **绕过压缩的例子**(仅特定场景):
   - `src/web/media.ts:415` - `loadWebMediaRaw()` (不优化)
   - `src/discord/send.emojis-stickers.ts:14,38` - Discord emoji/sticker 使用 raw 模式

## 问题根因总结

| 问题 | 根因 | skill 能否自行解决 |
|------|------|-------------------|
| 图片被缩小到 1200px 以下 | Agent 层 `imageMaxDimensionPx=1200` | 否(用户配置决定) |
| 大图片被进一步压缩 | 媒体加载层 6MB 限制 + 优化逻辑 | 否(系统内置) |
| 切分功能无效 | OpenClaw 压缩在内存中处理,切分后仍被压缩 | 部分有效(可减小单个文件大小) |
| 不同渠道行为不一致 | 各渠道使用不同的 `maxBytes` | 部分有效(需针对渠道优化) |

## 优化建议

### 方案 A:Skill 层优化(推荐,skill 可自行实现)

1. **降低输出分辨率到 1200px 以内**
   - 将 `width=800, deviceScaleFactor=2` 改为 `width=600, deviceSca

Sponsored

Ads related to Md To Share and adjacent AI workflows.