两种模式
| chat 对话 | document 文档 | |
|---|---|---|
| 用在 | 助理回答、聊天气泡 | 知识库文档、文章、说明书、协议 |
| 标题 | 全部降成与正文同大的粗体行(h1/h2 700,h3–h6 600) | 完整字阶:h1 26/32 · h2 19/26 带上分隔线 · h3 15/22 |
| 正文 | 14 / 22(现场端 17 / 27) | 同左,行长 ≤ 40 汉字(640px) |
| 段间距 | 8 | 12 |
| 表格 | 横向滚动 | 横向滚动 |
| 图片 | 宽度 100%、radius-md |
同左 |
元素对照
| 元素 | 样式 | token |
|---|---|---|
| 链接 | 主色、淡下划线、hover 实下划线;外链新窗口 | primary |
| 加粗 | 600 | — |
| 斜体 | 不倾斜,改 500 字重(中文没有斜体) | — |
| 行内代码 | mono 12.5、浅底、3px 圆角 | muted |
| 代码块 | CodeBlock:两级灰、顶部语言名、> 10 行显示行号、横向滚动 | muted / foreground / muted-foreground |
| 列表 | 缩进 20,项间距 2 | — |
| 任务列表 | Checkbox 样式方块,不用原生 | primary |
| 引用 | 浅底 + 左侧 2px 灰线,文字 muted-foreground |
muted / border |
| 表格 | 表头 11 号大写字距、subtle;行间 1px border;数字等宽 |
th 样式 |
| 分隔线 | 1px border,上下 16 |
border |
| 原始 HTML | 不渲染 | — |
Web
import { Markdown, StreamingMarkdown } from "@wutong/ui";
<Markdown mode="chat" onOpenLink={(url) => electron.openExternal(url)}>{answer}</Markdown>
<Markdown mode="document">{doc}</Markdown>
<StreamingMarkdown done={finished}>{partial}</StreamingMarkdown> // 末尾带光标
替换点:客户端 ClawChatPanel / FilePreview / MaterialMarkdownModal、后台 admin/docs / insights / AgreementPanel、官网 insights / docs / messages / earnings——各自的 components 覆盖全部删掉。
iOS(SwiftUI)
现有 MarkdownBlock + MarkdownText 的分块方案保留(行内格式交给 AttributedString),只调样式:
| 块 | 现在 | 改成 |
|---|---|---|
| 段落 | Theme.Font.body |
WT.Font.body(17 / 27) |
| 标题(chat) | headline / callout | 与正文同大,.bold(h1/h2)/ .semibold(h3+),上距 12 |
| 标题(document) | 同上 | h1 28 / h2 21 / h3 17 semibold |
| 行内代码 | — | .monospaced 15,底 WT.Color.muted,圆角 3 |
| 代码块 | — | 底 muted、圆角 8、内距 12、横向滚动、不高亮 |
| 表格 | — | Grid,表头 f-meta 13.5 subtle,行间 border 线 |
| 引用 | — | 底 muted,左 2pt border |
| 链接 | — | WT.Color.primary,SFSafariViewController 打开 |
| 斜体 | 系统斜体 | 去掉倾斜,改 .medium |
Android(Compose)
用 Markwon 或 compose-markdown,主题按同一张表:headingBreakHeight = 0、codeBackgroundColor = muted、linkColor = primary、blockQuoteColor = border、bulletWidth = 4dp、listItemColor = foreground、表格用 TablePlugin 且 tableBorderColor = border、tableHeaderRowBackgroundColor = muted。em 改为 FontWeight.Medium 不倾斜。
小程序
用 towxml 或 wemark,样式表照 theme.wxss 的变量改一遍:正文 34rpx / 54rpx,代码块 muted 底,链接 primary。