Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tcy

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tcy

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

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

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

OptionTypeDefaultDescription
tcyDigitnumber2Maximum number of digits for Tate-Chu-Yoko. Set to 0 to disable number conversion.
autoTextOrientationbooleantrueEnable/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

Keywords

FAQs

Package last updated on 03 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc