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

mikanjs-v2

v2.0.0

Published

Japanese Line Break Organizer

Readme

mikanjs-v2

日本語テキストを適切な位置で改行可能にする JavaScript ライブラリです。

デモ

https://trkbt10.github.io/mikanjs-v2/ でライブデモを試すことができます。

インストール

npm install mikanjs-v2

使い方

基本的な使い方

import { tokenize, toHTML } from 'mikanjs-v2';

// テキストをトークンに分割
const tokens = tokenize("常に最新、最高のモバイル。Androidを開発した同じチームから。");
console.log(tokens);
// => ["常に", "最新、", "最高の", "モバイル。", "Androidを", "開発した", "同じ", "チームから。"]

// HTMLとして出力
const html = toHTML("常に最新、最高のモバイル。Androidを開発した同じチームから。");
console.log(html);
// => <span style="display:inline-block" role="presentation">常に</span><span style="display:inline-block" role="presentation">最新、</span>...

オプション設定

const html = toHTML("私は好きにした。君たちも好きにしろ。", {
  className: "wbr",           // CSSクラス名
  style: "font-weight:bold",  // 追加のスタイル
  aria: false                 // aria属性の有無(デフォルト: true)
});

React での使用例

import React from 'react';
import { toHTML } from 'mikanjs-v2';

function MyComponent() {
  const text = "やりたいことのそばにいる";
  const html = toHTML(text, { className: "japanese-text" });
  
  return (
    <div dangerouslySetInnerHTML={{ __html: html }} />
  );
}

HTML での使用例

<!DOCTYPE html>
<html>
<head>
  <script type="module">
    import { toHTML } from 'https://unpkg.com/[email protected]/dist/index.es.js';
    
    document.addEventListener('DOMContentLoaded', () => {
      const text = "桜の花の落ちるスピード。秒速5センチメートル";
      const html = toHTML(text);
      document.getElementById('japanese-text').innerHTML = html;
    });
  </script>
</head>
<body>
  <div id="japanese-text"></div>
</body>
</html>

API

tokenize(text: string): string[]

日本語テキストを適切な改行位置でトークンに分割します。

  • text: 分割するテキスト
  • 戻り値: 分割されたトークンの配列

toHTML(text: string, options?: SegmentOptions): string

テキストを改行可能な HTML に変換します。

  • text: 変換するテキスト
  • options: オプション設定
    • className?: string - 各spanに適用するCSSクラス名
    • style?: string - 追加のCSSスタイル
    • aria?: boolean - aria属性の有無(デフォルト: true)
  • 戻り値: HTML文字列

機能

  • 助詞、動詞活用、数値と単位の組み合わせを考慮した自然な分割
  • 括弧内テキストの適切な処理
  • 数値、単位、記号の正確な処理
  • 絵文字や多言語テキストの保持
  • 高速な処理のための事前生成された助詞データ

ライセンス

UNLICENSED