Japanese Text
Special handling for Japanese (CJK) text formatting
The problem with general formatters
Most markdown formatters apply Western typographic rules that do not work well with Japanese (CJK) text. Common issues include:
Line reflow — Formatters reflow paragraphs to fit a line width. Since Japanese does not use spaces between words, the formatter cannot determine where to break lines, resulting in inappropriate joins or splits.
Unwanted backslashes — Some formatters insert
\at line ends to preserve hard line breaks, cluttering Japanese text with unnecessary escape characters.Space insertion — Formatters may add spaces around emphasis markers (
**bold**), punctuation (。、), or between Japanese and ASCII characters where none should exist.HTML entity encoding — Characters like
をcan get encoded toを, making the source unreadable.
These issues make general-purpose formatters difficult to use in projects that contain Japanese markdown content.
How mdx-formatter handles Japanese text
Japanese text is preserved as-is by the formatter. The formatter does not insert or remove spaces around Japanese punctuation. This works through the formatter's text-preservation approach -- the hybrid line-based formatter preserves original text for content it does not specifically transform.
Japanese punctuation spacing is preserved
No extra spaces are inserted around Japanese characters
Bold/emphasis markers work correctly with Japanese text
URLs and parenthetical expressions in Japanese text are preserved
Line breaks within Japanese paragraphs are not altered
Examples
Japanese headings and content
Before:
# 日本語の見出し
内容です。After:
# 日本語の見出し
内容です。Bold text with Japanese
Japanese bold text is preserved without unwanted space changes:
Before:
この値を **×2** しますAfter (unchanged):
この値を **×2** しますImage alt text with Japanese and colons
Before:
After (unchanged — colons and Japanese in alt text preserved):
URLs in parenthetical expressions
Before:
詳細は (https://example.com) をご覧くださいAfter (unchanged — parentheses around URL preserved):
詳細は (https://example.com) をご覧くださいMulti-line Japanese paragraphs
Line breaks within Japanese paragraphs are preserved as-is:
Before:
こんにちは、Takazudo Modularです。
Takazudo Modular Highlightsなどというメルマガの名前にしてみました。
そんな年中送るかは分かりませんが……。After (unchanged):
こんにちは、Takazudo Modularです。
Takazudo Modular Highlightsなどというメルマガの名前にしてみました。
そんな年中送るかは分かりませんが……。