CJK Friendly
Improves bold and italic parsing adjacent to CJK (Chinese, Japanese, Korean) characters.
Core feature — always active, no configuration required.
What it does
CJK Friendly governs two post-parse fixups that adapt CommonMark/GFM rules to CJK text:
Emphasis/strong flanking. CommonMark's emphasis-flanking rules treat CJK ideographs and kana as neither whitespace nor punctuation. As a result,
**bold**or_italic_markers placed immediately next to Chinese, Japanese, or Korean characters are parsed as literal asterisks and underscores rather than formatting delimiters. This fixup post-processes the markdown AST and re-tokenizes emphasis rules to account for CJK content, so bold and italic work correctly around ideographs and kana.Bare-URL autolink boundary. GFM's autolink-literal grammar terminates a bare URL only on ASCII whitespace, so a URL flush against CJK text (
詳細はhttps:) swallows the trailing CJK run into the/ / example. com参照 href. This fixup terminates the link at the first CJK character instead. It only applies whengfm.autolinkLiteralis also enabled — which it is by default, since zfb 2.5.0 includes autolink literals in the conservative GFM default.
Example
The following renders correctly with emphasis markers adjacent to Japanese text:
これは **重要な** テキストです。
_イタリック_ も正しく機能します。A bare URL flush against CJK text also terminates at the right boundary (with gfm.autolinkLiteral enabled):
詳細はhttps://example.com参照してください。Without this fixup, the trailing 参照してください。 would be swallowed into the link's href.
Disabling
In rare cases where strict CommonMark compliance is required, you can turn the feature off in zfb.config.ts:
export default defineConfig({
markdown: {
cjkFriendly: false,
},
});Omitting cjkFriendly (the default) keeps the feature on.
Notes
GFM strikethrough (
~~text~~) is handled independently by markdown-rs and is unaffected by this setting.The feature operates as an AST post-processor; it does not modify the base parser.