Telegram Markdown Adapter
Keep the structure and readability of Markdown, but output in a format Telegram actually renders well.
中文摘要 / 中文使用说明
这个技能的目标不是保留原始 Markdown 语法,而是保留 Markdown 的结构感、层次感、可读性,再把最终输出适配成 Telegram 真正适合阅读和渲染的形式。
适合这些场景:
- - 用户喜欢 Markdown 风格回复,但当前渠道是 Telegram
- 回复里包含标题、表格、任务列表、嵌套列表、代码块等 Markdown 元素
- 希望消息看起来清楚、整齐、有结构,但不要出现大量未渲染的原始 Markdown 符号
默认策略:
- - 先按 Markdown 结构组织内容
- 再根据 Telegram 场景自动选择更合适的最终表现形式
- 表格类内容优先在
伪表格 / 卡片式 / Emoji 分栏式 之间自动判断 - 如果不确定,默认使用可读性最稳的卡片式
Core Rule
When the destination is Telegram, do not dump raw Markdown just because it looks nice in plain text. Rewrite it into Telegram-safe formatting while preserving the original structure and emphasis.
Prefer these goals in order:
- 1. Readability in Telegram
- Structural clarity
- Visual polish
- Fidelity to original Markdown syntax
Workflow
0. Default output posture
Unless the user explicitly asks for plain text, draft the reply in Markdown-like structure first, then adapt it for Telegram-safe rendering.
Default writing style:
- - use bold section headers instead of raw Markdown headings when sending final Telegram text
- keep lists, spacing, and sectioning from Markdown
- preserve inline code for commands, paths, env vars, and identifiers
- prefer readable visual structure over literal Markdown syntax fidelity
1. Identify Markdown features that will break or degrade in Telegram
Watch for these problem patterns:
- - ATX headings like INLINECODE1
- Markdown tables
- task lists like INLINECODE2
- nested bullets deeper than Telegram renders comfortably
- fenced code blocks that are too long or too frequent
- inline HTML
- footnotes
- blockquotes stacked too heavily
If the original content uses these, adapt rather than preserve literally.
2. Convert to Telegram-safe structure
Use these conversions by default:
- -
# Heading → **Heading** on its own line, optionally with an emoji if it improves scanability - INLINECODE5 → INLINECODE6
- horizontal rules → INLINECODE7
- Markdown tables → bullet lists or compact field/value lines
- task lists →
- [ ] becomes - 待办:... or INLINECODE10 - checked items → INLINECODE11
- blockquotes → short lead-in lines, not layered
> stacks - long code fences → summarize first; keep raw code only when truly needed
- multi-column comparisons → split into repeated blocks instead of tables
- links → keep raw URLs visible when copy/paste matters; avoid Markdown link syntax if Telegram rendering is uncertain
If Telegram HTML mode or rich formatting is available through the runtime, prefer the subset that is widely supported and low-risk. Do not rely on fragile formatting tricks.
3. Keep Telegram output compact
Telegram reads better with short blocks.
Default style:
- - short paragraphs
- bullets instead of dense prose
- one idea per bullet
- whitespace between sections
- avoid giant monolithic messages
If a reply is long, split it into 2–3 chunks naturally.
4. Preserve meaning, not syntax
Do not say things like:
- - “Telegram doesn’t support this Markdown”
- “Here is a Telegram-compatible rewrite”
Just output the adapted version directly unless the user asks about the transformation itself.
5. Message splitting and fallbacks
When the reply is long, split naturally into multiple Telegram messages instead of forcing one giant block.
Preferred split order:
- 1. headline or answer first
- detail second
- optional code / appendix third
If a section would render awkwardly in Telegram:
- - replace tables with repeated item blocks
- replace dense hierarchy with 2–3 bold section labels
- collapse low-value detail into a short summary
- move exact raw content into a compact code block only if fidelity matters
6. Telegram-specific reply conventions
For Telegram-facing final output:
- - favor bold section labels over raw Markdown heading markers
- keep paragraphs short
- separate sections with blank lines
- prefer bullets over prose when scanning matters
- avoid markdown tables entirely
- avoid unnecessary escaping clutter
- when multiple links are present, keep each link on its own line or its own bullet for easy tapping
7. HTML mode guidance
OpenClaw's Telegram message-tool sending path supports HTML parse mode and falls back to plain text if HTML parsing fails. However, ordinary assistant reply rendering may not always preserve HTML parse mode. Therefore, HTML should be used selectively.
Prefer Telegram HTML when:
- - the reply will be sent through the
message tool - section headings should be clearly bolded
- inline code, paths, env vars, or commands matter
- links should render cleanly without MarkdownV2 escaping pain
- the message is a structured notification, report, alert, or summary
Do not assume raw HTML will render correctly in ordinary direct assistant replies. For standard conversational replies, prefer Telegram-safe structured text unless the runtime path is known to support HTML parse mode.
Safe tag subset to prefer:
- - INLINECODE14
- INLINECODE15
- INLINECODE16
- INLINECODE17
- INLINECODE18
- INLINECODE19
- INLINECODE20
Rules:
- - keep to simple, shallow HTML
- escape raw
<, >, and & when they are plain text - do not rely on exotic tags or deep nesting
- avoid mixing Markdown syntax and HTML in the same rendered output
- if content is highly dynamic or tag safety is uncertain, fall back to Telegram-safe structured text
- for normal assistant chat replies, structured plain Telegram text remains the safe default
Use HTML as the preferred rich-text mode for Telegram only when the send path is compatible, especially via the message tool.
Format Selection Heuristics
Choose the presentation style based on content shape, not personal habit.
Style 1: monospace pseudo-table
Use when all of these are mostly true:
- - the content is strongly comparative
- rows are few
- each cell is short
- alignment matters more than conversational tone
- the audience is reading status/config/parameter data
Good fits:
- - configuration snapshots
- model parameter comparisons
- short status matrices
- version / state / value grids
Avoid when:
- - one column contains sentence-length explanations
- many rows would make the block tall and heavy
- Chinese text width makes alignment unreliable
Style 2: card blocks
Use when any of these are true:
- - one or more fields are medium or long
- readability matters more than visual alignment
- the output is for explanation, reporting, or decision support
- mobile readability is the priority
This is the default fallback.
Good fits:
- - daily reports
- problem lists
- option comparisons with explanations
- anything the user needs to actually read, not just scan
Style 4: emoji column style
Use when all or most of these are true:
- - the content is short and easy to scan
- Telegram-native vibe is desirable
- status/priority/health cues matter
- the output is more like a dashboard, quick summary, or progress panel
Good fits:
- - quick status updates
- lightweight summaries
- group-chat friendly reports
- operational snapshots
Default selection order
- 1. If strict comparison matters and fields are short → Style 1
- If explanations are present or text is medium/long → Style 2
- If the content is short, status-heavy, and scan-first → Style 4
- If uncertain → Style 2
Rich-text mode choice
When the reply is Telegram-bound and rich formatting helps, prefer this order:
- 1. HTML mode for
message-tool sends, headings, inline code, links, and structured reports - Structured plain Telegram text for ordinary assistant replies when parse-mode compatibility is uncertain
- Avoid raw MarkdownV2 unless there is a specific reason to use it
In practice:
- - reports / alerts / dashboards sent via
message → often HTML or Style 4 - explanatory blocks in ordinary chat replies → Style 2
- technical short comparisons → Style 1, usually inside
<pre> if HTML mode is used through a compatible send path
Preferred Formatting Patterns
Pattern A: Sectioned explanation
Instead of raw Markdown:
CODEBLOCK0
Output like:
CODEBLOCK1
Pattern B: Replace tables with blocks
Instead of:
CODEBLOCK2
Output like:
CODEBLOCK3
Pattern C: Report-style Telegram output
Use when sending updates, summaries, or operational reports.
CODEBLOCK4
When to keep code formatting
Keep inline code for:
- - commands
- paths
- IDs
- short config keys
Keep fenced code blocks only when:
- - the code itself is the deliverable
- line breaks matter
- the user explicitly wants raw code
Otherwise, summarize and only include the critical snippet.
Anti-Patterns
Avoid these in Telegram replies unless the user explicitly asks for raw Markdown:
- - Markdown tables
- giant heading hierarchies
- deeply nested lists
- repeated fenced blocks
- decorative syntax that Telegram won’t render meaningfully
- literal raw Markdown when a cleaner Telegram rendering is obvious
Quick Decision Rule
If the content is mainly:
- - status / summary / plan / comparison → choose among Style 1 / 2 / 4 using the heuristics above
- code / config / command output → keep minimal code formatting
- mixed → explain in Telegram-friendly sections, then include only the necessary code snippet
When table-like data appears, do not default blindly. Decide like this:
- - short, rigid, technical rows → Style 1
- explanation-heavy rows → Style 2
- short status rows for scanability → Style 4
- uncertain → Style 2
Reference
Read references/telegram-format-rules.md when you need concrete conversion rules and examples for headings, tables, checklists, code, and long replies.
Telegram Markdown 适配器
保留 Markdown 的结构感和可读性,但以 Telegram 实际能良好渲染的格式输出。
中文摘要 / 中文使用说明
这个技能的目标不是保留原始 Markdown 语法,而是保留 Markdown 的结构感、层次感、可读性,再把最终输出适配成 Telegram 真正适合阅读和渲染的形式。
适合这些场景:
- - 用户喜欢 Markdown 风格回复,但当前渠道是 Telegram
- 回复里包含标题、表格、任务列表、嵌套列表、代码块等 Markdown 元素
- 希望消息看起来清楚、整齐、有结构,但不要出现大量未渲染的原始 Markdown 符号
默认策略:
- - 先按 Markdown 结构组织内容
- 再根据 Telegram 场景自动选择更合适的最终表现形式
- 表格类内容优先在 伪表格 / 卡片式 / Emoji 分栏式 之间自动判断
- 如果不确定,默认使用可读性最稳的卡片式
核心规则
当目标平台是 Telegram 时,不要仅仅因为原始 Markdown 在纯文本中看起来不错就直接输出。应将其改写为 Telegram 安全的格式,同时保留原始结构和重点。
按以下优先级追求目标:
- 1. Telegram 中的可读性
- 结构清晰度
- 视觉美观度
- 对原始 Markdown 语法的忠实度
工作流程
0. 默认输出姿态
除非用户明确要求纯文本,否则先用类似 Markdown 的结构起草回复,再适配为 Telegram 安全渲染格式。
默认写作风格:
- - 发送最终 Telegram 文本时,使用加粗段落标题代替原始 Markdown 标题
- 保留 Markdown 中的列表、间距和分段
- 对命令、路径、环境变量和标识符保留行内代码
- 优先考虑可读的视觉结构,而非字面 Markdown 语法忠实度
1. 识别会在 Telegram 中失效或降级的 Markdown 特性
注意以下问题模式:
- - ATX 标题如 # 标题
- Markdown 表格
- 任务列表如 - [ ]
- 嵌套层级超过 Telegram 舒适渲染范围
- 过长或过于频繁的围栏代码块
- 行内 HTML
- 脚注
- 过度堆叠的块引用
如果原始内容使用了这些,应进行适配而非字面保留。
2. 转换为 Telegram 安全结构
默认使用以下转换:
- - # 标题 → 单独一行的 标题,可酌情添加 emoji 提升可扫描性
- ## 章节 → 章节
- 水平分割线 → ───
- Markdown 表格 → 项目列表或紧凑的字段/值行
- 任务列表 → - [ ] 变为 - 待办:... 或 - ☐ ...
- 已完成项 → - ✅ ...
- 块引用 → 简短引导行,而非多层 > 堆叠
- 长代码围栏 → 先总结;仅在真正需要时保留原始代码
- 多列对比 → 拆分为重复块而非表格
- 链接 → 当复制/粘贴重要时保留原始 URL 可见;若 Telegram 渲染不确定则避免 Markdown 链接语法
如果运行时支持 Telegram HTML 模式或富文本格式,优先选择广泛支持且风险低的子集。不要依赖脆弱的格式技巧。
3. 保持 Telegram 输出紧凑
Telegram 更适合短块阅读。
默认风格:
- - 短段落
- 使用项目符号而非密集叙述
- 每个项目符号一个想法
- 段落间留空行
- 避免巨大的单块消息
如果回复较长,自然地分成 2-3 块。
4. 保留含义,而非语法
不要说类似这样的话:
- - Telegram 不支持这个 Markdown
- 这是 Telegram 兼容的重写版本
除非用户询问转换过程本身,否则直接输出适配后的版本。
5. 消息拆分与回退
当回复较长时,自然地拆分为多条 Telegram 消息,而非强制一个巨大的块。
优先拆分顺序:
- 1. 先放标题或答案
- 再放细节
- 最后放可选的代码/附录
如果某个部分在 Telegram 中渲染效果不佳:
- - 用重复的项目块替换表格
- 用 2-3 个加粗章节标签替换密集层级
- 将低价值细节折叠为简短摘要
- 仅在忠实度重要时将精确原始内容放入紧凑代码块
6. Telegram 特定回复约定
面向 Telegram 的最终输出:
- - 优先使用加粗章节标签而非原始 Markdown 标题标记
- 保持段落简短
- 用空行分隔章节
- 当扫描性重要时,优先使用项目符号而非叙述
- 完全避免 Markdown 表格
- 避免不必要的转义杂乱
- 当存在多个链接时,将每个链接放在单独行或单独项目符号中,便于点击
7. HTML 模式指南
OpenClaw 的 Telegram 消息工具发送路径支持 HTML 解析模式,若 HTML 解析失败则回退为纯文本。然而,普通助手回复渲染可能不总是保留 HTML 解析模式。因此,应选择性使用 HTML。
在以下情况优先使用 Telegram HTML:
- - 回复将通过 message 工具发送
- 章节标题需要清晰加粗
- 行内代码、路径、环境变量或命令很重要
- 链接应干净渲染,无需 MarkdownV2 转义烦恼
- 消息是结构化通知、报告、警报或摘要
不要假设原始 HTML 能在普通直接助手回复中正确渲染。对于标准对话回复,除非已知运行时路径支持 HTML 解析模式,否则优先使用 Telegram 安全的结构化文本。
优先使用的安全标签子集:
规则:
- - 保持简单、浅层 HTML
- 当 <、> 和 & 作为纯文本时进行转义
- 不要依赖奇特标签或深层嵌套
- 避免在同一渲染输出中混合 Markdown 语法和 HTML
- 如果内容高度动态或标签安全性不确定,回退为 Telegram 安全的结构化文本
- 对于普通助手聊天回复,结构化纯 Telegram 文本仍是安全默认
仅当发送路径兼容时,尤其是通过 message 工具,才将 HTML 作为 Telegram 的首选富文本模式。
格式选择启发式
根据内容形态选择呈现风格,而非个人习惯。
风格 1:等宽伪表格
在以下条件基本满足时使用:
- - 内容具有强烈对比性
- 行数较少
- 每个单元格较短
- 对齐比对话语气更重要
- 读者在阅读状态/配置/参数数据
适合场景:
- - 配置快照
- 模型参数对比
- 简短状态矩阵
- 版本/状态/值网格
避免场景:
- - 某一列包含句子长度的解释
- 行数过多导致块变得高大沉重
- 中文文本宽度使对齐不可靠
风格 2:卡片块
在以下任一条件成立时使用:
- - 一个或多个字段为中等或较长
- 可读性比视觉对齐更重要
- 输出用于解释、报告或决策支持
- 移动端可读性是优先考虑
这是默认回退选项。
适合场景:
- - 日报
- 问题列表
- 带解释的选项对比
- 用户需要实际阅读而不仅仅是扫描的任何内容
风格 4:Emoji 分栏式
在以下条件全部或大部分成立时使用:
- - 内容简短且易于扫描
- 希望具有 Telegram 原生氛围
- 状态/优先级/健康提示很重要
- 输出更像仪表盘、快速摘要或进度面板
适合场景:
默认选择顺序
- 1. 如果严格对比重要且字段简短 → 风格 1
- 如果存在解释或文本为中等/较长 → 风格 2
- 如果内容简短、状态密集且扫描优先 → 风格 4
- 如果不确定 → 风格 2
富文本模式选择
当回复面向 Telegram 且富格式有帮助时,按此顺序优先选择:
- 1. HTML 模式用于 message 工具发送、标题、行内代码、链接和结构化报告
- 结构化纯 Telegram 文本用于普通助手回复,当解析模式兼容性不确定时
- 避免原始 MarkdownV2,除非有特定理由使用
实际应用中:
- - 通过 message 发送的报告/警报/仪表盘 → 通常使用 HTML 或风格 4
- 普通聊天回复中的解释块 → 风格 2
- 技术性简短对比 → 风格 1,若通过