# MD089 - CJK spacing
Aliases: `cjk-spacing`
**Disabled by default.** This rule is opt-in: enable it explicitly with `extend-enable`.
## What this rule does
Reports a Chinese, Japanese or Korean letter that touches a Latin letter or a
digit, and inserts one space between them: `日本語english` becomes
`日本語 english`, `花了5000元` becomes `花了 5000 元`, `한글english` becomes
`한글 english`.
Latin text means ASCII letters and digits. Full-width letters and digits
(`123`, `Test`), letters of other scripts and all punctuation are left
alone: `中文。english` and `iPhone,好` are correct as written.
The rule reads every line of prose, including headings, list items, table
cells and blockquotes. It never changes:
- fenced and indented code blocks, and the inside of inline code, inline math,
links, wikilinks and bare URLs; these are spaced from the outside, so a CJK
letter touching a code span or a link is separated from it and the span
itself is left untouched
- images, HTML tags, HTML comments, `#tags` and footnote markers (`[^1]`),
on either side; a link whose text is one image (`[](target)`)
is a badge and counts as an image
- front matter, math blocks, HTML blocks and link reference definitions
- Pandoc and kramdown attribute metadata: `` `code`{.class} ``, `[text]{.class}`,
a block IAL line (`{:.class}`) and the body of a kramdown extension block; a
bracketed span carrying attributes is left alone as a whole, so the space
before it is not reported either
Emphasis markers are looked through, and the space lands outside them:
`**中文**english` becomes `**中文** english`.
Strikethrough is not looked through: `~` is neither an emphasis marker nor a
configured symbol, so a CJK letter touching a strikethrough run
(`中文~~english~~`) is left alone.
A configured symbol counts as part of the Latin text next to it, so
`角度為90°的角` becomes `角度為 90° 的角` and `價格$5` becomes `價格 $5`. A symbol
between two CJK words (`你好-世界`, `注意:这是`) is not touched.
A gap whose space would complete a list marker is not reported: `1)中文` is an
enumeration label inside a paragraph, and spacing it would turn the line into
an ordered list item.
## Why this matters
Chinese, Japanese and Korean copywriting guidelines call for a space between
CJK text and Latin words or numbers because the two scripts have no word
boundary of their own; the space keeps mixed text readable. Japanese technical
writing largely prefers no space, which is why the rule is opt-in.
## Examples
### Incorrect
```markdown
日本語englishひらがな
今天出去買菜花了5000元。
한글english한글
角度為90°的角
```
### Correct
```markdown
日本語 english ひらがな
今天出去買菜花了 5000 元。
한글 english 한글
角度為 90° 的角
```
## Configuration
```toml
[MD089]
# The rule is opt-in, so a configuration section alone does not turn it on
enabled = true
# Symbols that lead a Latin run and take a space after a CJK letter: 價格$5 -> 價格 $5
symbols-after-cjk = "-+'\"([¥$"
# Symbols that trail a Latin run and take a space before a CJK letter: 90°的 -> 90° 的
symbols-before-cjk = "-+;:'\"°%$)]"
```
Each option is one string of characters; whitespace in it is ignored. Set an
option to `""` to stop every symbol on that side from attaching.
## Automatic fixes
The fix inserts one space at each reported position. Existing spaces are never
changed; a run of several spaces is MD064's concern.
## Related rules
- [MD064](md064.md) - No multiple consecutive spaces
- [MD088](md088.md) - Normalize to ASCII quotes and dashes