Markdown in Chinese
CommonMark was written for languages that put a space between words. Chinese does not, and models writing Chinese break its rules in a few fixed ways, so the marks show as text. Every renderer adds the same extensions to marked (lib/markdown/prose.ts); each takes only what the stock rules leave as text.
| Written | Stock CommonMark | Shown |
|---|---|---|
这是**重点。**下一句 | Asterisks as text | Bold, closed after the full stop |
这是*斜体。*后面, ~~原价,~~, __粗体__ | Marks as text | Italic, struck, bold |
访问 https://a.com/x。下一句 | The link takes 。下一句 | The link ends before 。 |
[文档](https://a.com) | Brackets as text | A link |
[deck](/Users/me/ICDM 2026/deck.pptx) | Text: a space ends the target | A file link |
##标题, 1.第一项, -第一项 | Markers as text | A heading, a list |
价格 $5,折后 $3 | One formula from $5 to $ | Text |
Rules
| Part | Rule |
|---|---|
| Emphasis | *, **, ***, ~~: taken when punctuation touches the inside of a mark, a non-space its outside, and CJK is on one side. _, __: taken when CJK touches the outside and the text inside has CJK, so snake_case stays (cjk-emphasis.ts) |
| Bare addresses | End at the first full-width punctuation mark, and at CJK still in the host name. CJK in a path stays: zh.wikipedia.org/wiki/中文 (cjk-links.ts) |
| Link targets | Full-width parentheses count when the target is an address or a local path. A root, home, file:// or drive path may have spaces (spaced-path-links.ts) |
| Markers | A line starting with #–######, 1., 1), - or + directly followed by CJK is read with the space put back. Block tokens, so code is never touched (cjk-blocks.ts) |
| Formulas | Lexer tokens that render as .md-math holding their source; KaTeX draws only those and never scans text. $ opens before a non-space; the closing $ follows a non-space and is not followed by a digit, as in Pandoc. \(…\), \[…\], $$…$$ always count (math.ts) |
Left as written
| Written | Why |
|---|---|
#话题#今天 | A hashtag: one # closed by another |
1.5倍 | A digit follows the dot |
1、, (1), • | Plain text that already reads as numbering |
*强调* at a line start | Emphasis, not a bullet |
Tables with | | Rare, and a full-width bar is also ordinary text |
| Web addresses with spaces | A space ends them, as everywhere |
The user's own messages and A2UI text get the same extensions without formulas: what a person types stays literal.
Code
apps/web/lib/markdown/prose.ts,cjk-emphasis.ts,cjk-links.ts,cjk-blocks.ts,spaced-path-links.ts,math.tsapps/web/lib/runtime-bridge/dom/markdown-render.ts(renderMd,typesetMath)apps/web/components/chat/messages/bubbles/markdown.ts,apps/web/lib/format-utils/markdown.tsx,document-markdown.tsapps/web/tests/chat/markdown/chinese-prose.test.mjs
Last updated · 2026-11-25