Line Break for East Asian People


Keywords
typography, breakline, east asian width, CSS, CSS3, HTML, Markdown, Japanese, Chinese, Korean, Mongolian
License
MIT
Install
npm install asianbreak@1.2.3

Documentation

AsianBreak

Line Break for East Asian People

npm status

Build Status Coverage Status Dependency Status npm version LICENSE Greenkeeper badge

const asianbreak = require('asianbreak');

asianbreak(`

     そのとき汽車はだんだん川からはなれて崖の上を通るようになりました。
    向う岸もまた黒いいろの崖が川の岸を下流に下るにしたがってだんだん高くなって行くのでした。
    そしてちらっと大きなとうもろこしの木を見ました。
    その葉はぐるぐるに縮れ葉の下にはもう美しい緑いろの大きな苞が赤い毛を吐いて
    真珠のような実もちらっと見えたのでした。

`);

API

This module exposes single asianbreak(texts[, options]) function.

texts

  • Type: String[] | String

An array of string which supporse to constitute Inline Formatting Context of CSS2.1.

For this example:

<p>
    日本語は、
    <ruby><rb>漢</rb><rb>字</rb><rp>(</rp><rt>かん</rt><rt>じ</rt><rp>)</rp></ruby>
    を使用する。
</p>

only <p> creates inline formatting context and <rp> and <rt> is supporsed to be removed from inline context tree (in modern browsers), and texts should be:

const texts = ['\n    日本語は、\n    ', '', '', '', '', '', '', '\n    を使用する。\n'];

then you'll get:

const result = asianbreak(texts);
console.log(result); // ['\n    日本語は、', '', '漢', '', '字', '', '', 'を使用する。\n'];

If you restored it to original HTML, it should be:

<p>
    日本語は、<ruby><rb>漢</rb><rb>字</rb><rp>(</rp><rt>かん</rt><rt>じ</rt><rp>)</rp></ruby>を使用する。
</p>

How great deed is this!

If a string is supplied, it assume that context is constituted by single segment, and returns transformed segment as string.

options

  • Type: Object

Unimplemented