Skip to main content
The @streamdown/cjk package corrects Markdown parsing in Chinese, Japanese, and Korean (CJK) text. Without this plugin, certain CJK punctuation and character boundaries can confuse the GFM parser, producing garbled emphasis markers or URLs that swallow trailing punctuation. It integrates with the plugins.cjk field on <Streamdown>.

Installation

npm install @streamdown/cjk

Quick start

import { createCjkPlugin } from "@streamdown/cjk";
import { Streamdown } from "streamdown";

const plugins = {
  cjk: createCjkPlugin(),
};

<Streamdown plugins={plugins}>
  {markdown}
</Streamdown>

createCjkPlugin()

Creates a CjkPlugin instance. No configuration options are required or accepted.
function createCjkPlugin(): CjkPlugin
A pre-configured instance is also exported:
import { cjk } from "@streamdown/cjk";

CjkPlugin interface

type
cjk
required
Discriminant for the plugin union type. Always "cjk".
name
cjk
required
Plugin identifier. Always "cjk".
remarkPluginsBefore
Pluggable[]
required
Remark plugins that must run before remark-gfm. Contains remark-cjk-friendly, which modifies emphasis parsing so that CJK characters adjacent to * and _ markers are handled correctly.
remarkPluginsAfter
Pluggable[]
required
Remark plugins that must run after remark-gfm. Contains:
  • An internal remarkCjkAutolinkBoundary plugin that splits GFM autolinks at CJK punctuation boundaries (e.g. , , ), preventing trailing punctuation from being absorbed into URLs.
  • remark-cjk-friendly-gfm-strikethrough, which corrects strikethrough detection adjacent to CJK characters.
remarkPlugins
Pluggable[]
deprecated
All remark plugins in a flat array ([...remarkPluginsBefore, ...remarkPluginsAfter]). Provided for backwards compatibility. Prefer remarkPluginsBefore and remarkPluginsAfter when building custom pipeline integrations, as the order relative to remark-gfm is significant.

Plugin ordering

Streamdown automatically inserts the CJK plugins in the correct positions:
remarkPluginsBefore  →  remark-gfm  →  remarkPluginsAfter  →  remark-math (if present)
You do not need to manage plugin ordering yourself when using the plugins.cjk field. The following CJK punctuation characters are treated as URL boundaries:
CharacterDescription
Full stop
Comma / enumeration comma
Question mark
Exclamation mark
Colon
Semicolon
)Parentheses
Lenticular brackets
Corner brackets
White corner brackets
Angle brackets
Double angle brackets
When a GFM autolink ends with any of these characters, the plugin splits the URL at the boundary and emits the trailing characters as a plain text node.

Build docs developers (and LLMs) love