npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@peaceroad/markdown-it-cjk-breaks-mod

v0.1.11

Published

Suppress linebreaks between east asian (Especially Japanese) characters

Downloads

174

Readme

@peaceroad/markdown-it-cjk-breaks-mod

@peaceroad/markdown-it-cjk-breaks-mod is a markdown-it plugin that suppresses line breaks between CJK text and optionally injects spacing after configured punctuation when a break is removed. It is designed for mixed Japanese/CJK + ASCII documents where default newline handling often produces unwanted spaces or breaks.

This package is a fork lineage of markdown-it-cjk-breaks and @sup39/markdown-it-cjk-breaks. It keeps the original CJK break suppression behavior, adds the either mode introduced by @sup39, and extends it with punctuation-spacing controls and softbreak normalization for plugin-heavy markdown-it pipelines.

Install

npm i @peaceroad/markdown-it-cjk-breaks-mod

Quick Start

import MarkdownIt from 'markdown-it';
import cjkBreaks from '@peaceroad/markdown-it-cjk-breaks-mod';

const md = MarkdownIt({ html: true }).use(cjkBreaks);

md.render('あおえ\nうい');
// <p>あおえうい</p>

Options

  • either
    Type: boolean
    Default: false
    Remove a break when either side (instead of both sides) is CJK-width (F/W/H), still excluding Hangul.
    Origin: inherited from @sup39/markdown-it-cjk-breaks.

The options below are extensions added by this project:

  • normalizeSoftBreaks
    Type: boolean
    Default: false
    Split newline-containing text tokens into explicit softbreak tokens before processing. Useful with plugins that rewrite inline tokens.
  • spaceAfterPunctuation
    Type: 'half' | 'full' | string
    Default: disabled
    Insert spacing only when this plugin removes a break after a target sequence. 'half' => ' ', 'full' => \u3000.
  • spaceAfterPunctuationTargets
    Type: string | string[] | [] | null | false
    Default: ['!', '?', '⁉', '!?', '?!', '!?', '?!', '.', ':']
    Replace the target sequence set. [], null, or false explicitly disable target matching.
  • spaceAfterPunctuationTargetsAdd
    Type: string | string[]
    Default: unset
    Append target sequences after base resolution.
  • spaceAfterPunctuationTargetsRemove
    Type: string | string[]
    Default: unset
    Remove sequences from the resolved target list.

Punctuation Spacing Examples

import MarkdownIt from 'markdown-it';
import cjkBreaks from '@peaceroad/markdown-it-cjk-breaks-mod';

const mdHalf = MarkdownIt({ html: true }).use(cjkBreaks, {
  either: true,
  spaceAfterPunctuation: 'half'
});

mdHalf.render('こんにちは!\nWorld');
// <p>こんにちは! World</p>

const mdFull = MarkdownIt({ html: true }).use(cjkBreaks, {
  either: true,
  spaceAfterPunctuation: 'full'
});

mdFull.render('こんにちは!\nWorld');
// <p>こんにちは! World</p>

const mdCustom = MarkdownIt({ html: true }).use(cjkBreaks, {
  either: true,
  spaceAfterPunctuation: 'half',
  spaceAfterPunctuationTargets: ['??']
});

mdCustom.render('Hello??\nWorld');
// <p>Hello?? World</p>

Softbreak Normalization Example

import MarkdownIt from 'markdown-it';
import cjkBreaks from '@peaceroad/markdown-it-cjk-breaks-mod';

const md = MarkdownIt({ html: true }).use(cjkBreaks, {
  either: true,
  normalizeSoftBreaks: true
});

md.render('**漢**\nb');
// <p><strong>漢</strong>b</p>

Behavior Notes

  • Break suppression follows CSS Text Level 3 style rules used by upstream: ZWSP-adjacent breaks are removed first; otherwise width-class checks are applied with Hangul exclusion.
  • Punctuation spacing is never global formatting. It only runs when this plugin actually removes the break.
  • The second punctuation pass handles inline markup boundaries (inline code, links/autolinks, images, inline HTML) when a raw newline boundary is verifiably present.
  • Matching is fail-closed: if raw boundary reconstruction cannot be proven, no space is inserted.
  • If a softbreak is still active between candidate tokens, spacing insertion is skipped.

Compatibility

  • Module format: ESM ("type": "module").
  • Runtime: works in Node.js ESM environments and browser/VSCode bundling setups that support ESM dependencies.
  • Runtime plugin code uses no Node-only APIs (fs, path, etc.); those are confined to tests.
  • Plugin installation is first-install-wins: repeated .use(cjkBreaks, newOptions) on the same MarkdownIt instance is ignored. Recreate the instance to change options.
  • For plugin chains that rewrite inline text (for example @peaceroad/markdown-it-strong-ja), prefer normalizeSoftBreaks: true for stable behavior.

Upstream And Credits

License

  • markdown-it/markdown-it-cjk-breaks: MIT
  • @sup39/markdown-it-cjk-breaks: MIT
  • @peaceroad/markdown-it-cjk-breaks-mod: MIT