Chinese Markdown style
When to use
Any time you edit, review, or generate Chinese documentation — READMEs,
design docs, tutorials. Especially relevant when the repo has mixed
Chinese + English + code.
Problem
Chinese Markdown drifts in predictable ways:
- No space between CJK characters and adjacent ASCII letters / digits
(
使用Python3 instead of 使用 Python 3).
- Half-width punctuation after a Han character (
你好,世界 instead of
你好,世界).
- English proper nouns lowercased or re-cased (
github, Macos,
scons).
- Unnecessary full-width or double spaces around inline code and links.
These accumulate quietly and make diffs noisy later.
Solution
Follow chen3feng/cn-doc-style-guide
and lean on its tooling. The checker / previewer / formatter now ship as a
stdlib-only Python package cndocstyle (src-layout under src/), so invoke
them with python3 -m cndocstyle.<module>:
# 1. Clone the guide as a sibling of your doc repo
git clone https://github.com/chen3feng/cn-doc-style-guide.git
# 2. Make the package importable (src-layout). Pick ONE:
export PYTHONPATH=../cn-doc-style-guide/src # for this shell, or
cd ../cn-doc-style-guide && pip install -e . # editable install
# 3. Check — reports every violation, exits non-zero if any
python3 -m cndocstyle.check path/to/docs
# 4. Preview what an auto-fix would change (dry-run diff)
python3 -m cndocstyle.preview path/to/docs
# 5. Dry-run the formatter (default) — lists files that would change
python3 -m cndocstyle.formatter path/to/docs
# 6. Apply the safe subset of fixes
python3 -m cndocstyle.formatter --apply path/to/docs
The old tools/check.py / tools/preview.py / tools/format.py scripts
have been removed — use the module form above.
Core rules you should apply even without the tool:
- One half-width space between CJK and ASCII (letters, digits),
except around Chinese punctuation.
- Use full-width punctuation in Chinese prose:
,。:;?!、""'' ()《》 and …… for ellipsis.
- Keep English proper nouns in their canonical casing: GitHub,
macOS, Python, JSON, Scons.
- Units follow English convention with a space:
10 MB, 3.6+.
- Code, filenames, commands, paths go in backticks and are not
translated.
Example
Wrong: 使用Python3运行blade build,依赖scons.
Right: 使用 Python 3 运行 `blade build`,依赖 Scons。
Pitfalls
- The auto-fixer deliberately leaves some things alone: half-width
quotes (often URLs / code), half-width periods (version numbers,
domains), and
C++ next to a Han character. Don't "finish the job"
by hand without checking — see
safe-markdown-auto-fix.
- Never insert spaces inside code spans or fenced code blocks, even
when they contain Chinese characters.
- Don't add spaces on either side of Chinese punctuation — that's
what the guide explicitly forbids.
See also
1---2name: chinese-markdown-style3description: House style for Chinese Markdown docs, and how to enforce it with the cndocstyle package from cn-doc-style-guide.4---56# Chinese Markdown style78## When to use910Any time you edit, review, or generate Chinese documentation — READMEs,11design docs, tutorials. Especially relevant when the repo has mixed12Chinese + English + code.1314## Problem1516Chinese Markdown drifts in predictable ways:1718- No space between CJK characters and adjacent ASCII letters / digits19 (`使用Python3` instead of `使用 Python 3`).20- Half-width punctuation after a Han character (`你好,世界` instead of21 `你好,世界`).22- English proper nouns lowercased or re-cased (`github`, `Macos`,23 `scons`).24- Unnecessary full-width or double spaces around inline code and links.2526These accumulate quietly and make diffs noisy later.2728## Solution2930Follow [chen3feng/cn-doc-style-guide](https://github.com/chen3feng/cn-doc-style-guide)31and lean on its tooling. The checker / previewer / formatter now ship as a32stdlib-only Python package `cndocstyle` (src-layout under `src/`), so invoke33them with `python3 -m cndocstyle.<module>`:3435```bash36# 1. Clone the guide as a sibling of your doc repo37git clone https://github.com/chen3feng/cn-doc-style-guide.git3839# 2. Make the package importable (src-layout). Pick ONE:40export PYTHONPATH=../cn-doc-style-guide/src # for this shell, or41cd ../cn-doc-style-guide && pip install -e . # editable install4243# 3. Check — reports every violation, exits non-zero if any44python3 -m cndocstyle.check path/to/docs4546# 4. Preview what an auto-fix would change (dry-run diff)47python3 -m cndocstyle.preview path/to/docs4849# 5. Dry-run the formatter (default) — lists files that would change50python3 -m cndocstyle.formatter path/to/docs5152# 6. Apply the safe subset of fixes53python3 -m cndocstyle.formatter --apply path/to/docs54```5556> The old `tools/check.py` / `tools/preview.py` / `tools/format.py` scripts57> have been removed — use the module form above.5859Core rules you should apply even without the tool:60611. One half-width space between CJK and ASCII (letters, digits),62 **except** around Chinese punctuation.632. Use full-width punctuation in Chinese prose: `,。:;?!、""''64 ()《》` and `……` for ellipsis.653. Keep English proper nouns in their canonical casing: GitHub,66 macOS, Python, JSON, Scons.674. Units follow English convention with a space: `10 MB`, `3.6+`.685. Code, filenames, commands, paths go in backticks and are not69 translated.7071## Example7273```text74Wrong: 使用Python3运行blade build,依赖scons.75Right: 使用 Python 3 运行 `blade build`,依赖 Scons。76```7778## Pitfalls7980- The auto-fixer deliberately leaves some things alone: half-width81 quotes (often URLs / code), half-width periods (version numbers,82 domains), and `C++` next to a Han character. Don't "finish the job"83 by hand without checking — see84 [safe-markdown-auto-fix](../safe-markdown-auto-fix/SKILL.md).85- Never insert spaces *inside* code spans or fenced code blocks, even86 when they contain Chinese characters.87- Don't add spaces on either side of Chinese punctuation — that's88 what the guide explicitly forbids.8990## See also9192- [safe-markdown-auto-fix](../safe-markdown-auto-fix/SKILL.md)93- [doc-code-consistency-check](../doc-code-consistency-check/SKILL.md)94- Upstream guide: <https://github.com/chen3feng/cn-doc-style-guide>