@mdit/plugin-cjk-breaks
Plugin to remove line breaks between East Asian characters.
Usage
import { cjkBreaks } from "@mdit/plugin-cjk-breaks";
import MarkdownIt from "markdown-it";
const mdIt = new MarkdownIt().use(cjkBreaks);
mdIt.render(`\
あおえ
うい
aoe
ui
`);
// <p>あおえうい
// aoe
// ui</p>Syntax
The plugin suppresses soft line breaks that cannot be converted to spaces, following the segment break transformation rules of CSS Text Module Level 3:
- A line break adjacent to a zero-width space (U+200B) is removed.
- A line break is removed when both adjacent characters have an East Asian Width of
F,WorH, and neither of them is Hangul. - Other line breaks are kept.
Input
Remove linebreaks near ZWSP
foo
bar
baz
Remove linebreaks between hiragana (wide) characters
あおえ
いう
Keep linebreaks between hangul characters
ㅏㅗㅔ
ㅣㅜOutput
<p>Remove linebreaks near ZWSP</p>
<p>foobarbaz</p>
<p>Remove linebreaks between hiragana (wide) characters</p>
<p>あおえいう</p>
<p>Keep linebreaks between hangul characters</p>
<p>ㅏㅗㅔ ㅣㅜ</p>Demo
Input
あおえ
aoe
あおえOutput
<p>あおえ aoe あおえ</p>