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

gem-furigana

v1.0.9

Published

Gem makes it simple to work with Japanese furigana on webpages. It uses a simple syntax to encode furigana information in Japanese text, which it can display as plain kanji, hiragana or furigana using the HTML ruby syntax.

Downloads

14

Readme

Gem is little library for working with Japanese furigana.

Japanese writing is made up of two phonetic scripts: hiragana for Japanese words and katakana for loan words. There is also a logographic script called kanji, where a single character represents an idea or a word. All three of these scripts are used in Japanese text.

Since kanji characters aren't phonetic, some Japanese texts show the pronunciation above the kanji characters. This is called furigana. It is often used for text aimed at children, but is very helpful for anyone learning the language. The furigana helpers are called gems.

The Gem library makes it easier to work with furigana text, particularly on web pages. You can:

  • Display the HTML required to view furigana in the browser using the HTML ruby syntax
  • Extract phonetic hiragana text from Japanese text written in the gem syntax
  • Extract the plain text without any furigana from Japanese text written in the gem syntax

The Gem Syntax

The Gem library uses a simple syntax to encode furigana information in Japanese text. The text to be displayed in the furigana gem is simply included in square brackets following the character or group of characters it relates to.

For example:

 新[あたら]しい

Using the library

Gem is an npm package, so you can install it into your project using the following command:

npm install gem-furigana

Then you can create furigana objects. Pass in the Japanese text with the extra furigana information encoded in Gem syntax. The Gem library supports UMD syntax.

//const Furigana = require("gem-furigana").Furigana;
import { Furigana } from "gem-furigana";
var furigana = new Furigana("新[あたら]しい");

ES6 imports are also supported.

import { Furigana } from "gem-furigana";
var furigana = new Furigana("新[あたら]しい");

Then it's possible to generate:

  • The reading - the Japanese text, with any gem information included in the Gem syntax (ie. 新[あたら]しい)
  • The expression - the Japanese text without any furigana gems (ie. 新しい)
  • Hiragana - the text with any Kanji converted to the phonetic hiragana (ie. あたらしい)
  • Ruby Html - HTML syntax required to display the expression with the hiragana gems in the browser (ie. あたらしい)
const Furigana = require("gem-furigana").Furigana;
var furigana = new Furigana("新[あたら]しい");

console.log(furigana.Reading);		// 新[あたら]しい
console.log(furigana.Expression);	// 新しい
console.log(furigana.Hiragana);		// あたらしい
console.log(furigana.ReadingHtml);	// <ruby><rb>新</rb><rt>あたら</rt></ruby>しい