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 🙏

© 2024 – Pkg Stats / Ryan Hefner

tcy

v1.0.0

Published

A JavaScript library for processing Japanese vertical text, handling Tate-Chu-Yoko and text orientation adjustments

Downloads

66

Readme

TCY

TCY is a JavaScript library for processing Japanese vertical text. It adds special classes to HTML elements for handling Tate-Chu-Yoko (vertical-in-horizontal text) and text orientation adjustments.

Features

  • Displays number sequences and exclamation marks in Tate-Chu-Yoko style
  • Adjusts orientation for specific characters (kanji and symbols)
  • Processes only HTML text nodes (preserves tags)
  • Excludes email addresses, URLs, and character references from conversion
  • Flexible configuration options

Installation

npm install tcy

Usage

import TCY from 'tcy';

// Basic usage
const result = TCY.transformText('令和25年度の調査では、約78%の回答者が賛成しました。');
// => 令和<span class="tcy">25</span>年度の調査では、約<span class="tcy">78</span>%の回答者が賛成しました。

// With options
const result2 = TCY.transformText('第123回目の検証実験で、約456件のデータを収集。', { tcyDigit: 3 });
// => 第<span class="tcy">123</span>回目の検証実験で、約<span class="tcy">456</span>件のデータを収集。

Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | tcyDigit | number | 2 | Maximum number of digits for Tate-Chu-Yoko. Set to 0 to disable number conversion. | | autoTextOrientation | boolean | true | Enable/disable automatic text orientation adjustment. |

Conversion Rules

Tate-Chu-Yoko

  • Number sequences (2+ digits) → <span class="tcy">12</span>
  • Exclamation/question mark sequences → <span class="tcy">!!</span>

Text Orientation

  • Special symbols (÷∴≠≦≧etc.) → <span class="sideways">÷</span>
  • Greek/Cyrillic characters → <span class="upright">α</span>

Excluded Elements

  • Email addresses
  • URLs
  • HTML character references
  • Specific tags (code, pre, math, svg)
  • Elements with specific classes (tcy, upright, sideways)

Debug Mode

Set NODE_ENV=development during development to enable detailed debug output:

NODE_ENV=development node your-script.js

Error Handling

When invalid HTML is input, the library returns the original text and outputs an error message.

Examples

Number Processing

// Default behavior (tcyDigit: 2)
TCY.transformText('新宿駅の1日の利用者数は約35万人です。');
// => 新宿駅の1日の利用者数は約<span class="tcy">35</span>万人です。

// With tcyDigit: 0 (disable number conversion)
TCY.transformText('新宿駅の1日の利用者数は約35万人です。', { tcyDigit: 0 });
// => 新宿駅の1日の利用者数は約35万人です。

Text Orientation

// Automatic text orientation
TCY.transformText('÷∴≠α');
// => <span class="sideways">÷</span><span class="sideways">∴</span><span class="sideways">≠</span><span class="upright">α</span>

// Disable text orientation
TCY.transformText('÷∴≠α', { autoTextOrientation: false });
// => ÷∴≠α

License

MIT