Skip to content
Suppress linebreaks between east asian characters
JavaScript Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
test Fix crash due to incorrect softbreak handling Nov 27, 2018
.eslintignore
.eslintrc.yml Initial commit Feb 22, 2018
.gitignore Initial commit Feb 22, 2018
.travis.yml Initial commit Feb 22, 2018
CHANGELOG.md 1.1.3 released Feb 1, 2019
LICENSE Initial commit Feb 22, 2018
Makefile Change browser module's name Jan 31, 2019
README.md Switch to algorithm recommended for browsers in css-text-3 Feb 26, 2018
index.js Fix crash due to incorrect softbreak handling Nov 27, 2018
package.json 1.1.3 released Feb 1, 2019

README.md

markdown-it-cjk-breaks

Build Status NPM version Coverage Status

Plugin for markdown-it that suppresses linebreaks between east asian characters.

Normally newlines in a markdown text get rendered as newlines in output html text. Then browsers will usually render those newlines as whitespace (more smart behavior is included in w3c drafts, but not actually implemented by vendors).

This plugin finds and removes newlines that cannot be converted to space, algorithm matches CSS Text Module Level 3:

  • If the character immediately before or immediately after the segment break is the zero-width space character (U+200B), then the break is removed, leaving behind the zero-width space.
  • Otherwise, if the East Asian Width property [UAX11] of both the character before and after the segment break is F, W, or H (not A), and neither side is Hangul, then the segment break is removed.
  • Otherwise, the segment break is converted to a space (U+0020).

Install

yarn add markdown-it-cjk-breaks

Usage

var md = require('markdown-it')();
var cjk_breaks = require('markdown-it-cjk-breaks');

md.use(cjk_breaks);

md.render(`
あおえ
うい
aoe
ui
`);

// returns:
//
//<p>あおえうい
//aoe
//ui</p>

License

MIT

You can’t perform that action at this time.