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

@paulbarre/wc-furigana

v1.0.1

Published

Web component to display easily japanese with furigana

Downloads

29

Readme

Furigana

Built With Stencil

This Web Component is the easiest way to write japanese with furigana.

In HTML if you want to display (かん)() you need to write:

<ruby>漢
  <rp>(</rp>
  <rt>かん</rt>
  <rp>)</rp>
</ruby>
<ruby>字
  <rp>(</rp>
  <rt>じ</rt>
  <rp>)</rp>
</ruby>

Disclaimer Yes. rp tags are not a compulsory. 😀

With Furigana Web Component, things become easy:

<wc-furigana value="漢[かん]字[じ]" />

Check out how to use the component in details here: Furigana.

TL;DR

  1. Write furigana inside square brackets: 桜[さくら].
  2. Spaces will indicate which characters the furigana are above: 私[わたし]はフランス 人[じん]です。.
  3. Double spaces if you want to display a space character: 一 二 三.

Framework integrations

Note The following applies the support for IE11, see below if you don't care about it.

Vue

The following consider an application created with Vue CLI.

  1. Install the package
npm i @paulbarre/wc-furigana
  1. Modify the main file of your application to import the package:

main.js or main.ts if you are using TypeScript

import { applyPolyfills, defineCustomElements } from '@paulbarre/wc-furigana/loader'

// The following can be set into your `vue.config.js` file
Vue.config.ignoredElements = [/wc-furigana/]

applyPolyfills().then(() => {
  defineCustomElements(window)
})
  1. Add a wc-furigana to App.vue to see if the component is correctly loaded

If the above doesn't work, check out Stencil documentation about integration into a Vue app.

Vuepress

  1. Install the package
npm i @paulbarre/wc-furigana
  1. If you don't have it already, create a configuration file. From root folder add a .vuepress subfolder and create config.js.

  2. Add headers to this configuration file.

module.exports = {
    head: [
        ['script', {
            type: 'module',
            src: 'https://unpkg.com/@paulbarre/wc-furigana@latest/dist/furigana/furigana.esm.js'
        }],
        ['script', {
            nomodule: true,
            src: 'https://unpkg.com/@paulbarre/wc-furigana@latest/dist/furigana/furigana.js'
        }]
    ]
}

Example You can run the example in examples folder with npm run serve.

Angular

The following consider an application created with Angular CLI.

  1. Install the package
npm i @paulbarre/wc-furigana
  1. You first need to add CUSTOM_ELEMENTS_SCHEMA to your application:

app.module.ts

import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';

@NgModule({
  ...

  schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class AppModule { }
  1. Modify the main file to import the package:

main.ts

import { applyPolyfills, defineCustomElements } from '@paulbarre/wc-furigana/loader'

applyPolyfills().then(() => {
  defineCustomElements(window)
})
  1. Add a wc-furigana to app.component.html to see if the component is correctly loaded

If the above doesn't work, check out Stencil documentation about integration into an Angular app.

React

The following consider an application created with Create React App.

  1. Install the package
npm i @paulbarre/wc-furigana
  1. Import the package into index.js
import { applyPolyfills, defineCustomElements } from '@paulbarre/wc-furigana/loader'

applyPolyfills().then(() => {
  defineCustomElements(window)
})
  1. Add a wc-furigana to App.js to see if the component is correctly loaded

If the above doesn't work, check out Stencil documentation about integration into a React app.

I don't care about IE11

If you don't need to support IE11, no need to apply Polyfills:

import { defineCustomElements } from '@paulbarre/wc-furigana/loader'
defineCustomElements(window)

I don't use a framework

Adding the Web Component into a single file without any framework is also possible

<!DOCTYPE html>
<html lang="en">
<head>
  <script type="module" src="https://unpkg.com/@paulbarre/wc-furigana@latest/dist/furigana/furigana.esm.js"></script>
  <script nomodule src="https://unpkg.com/@paulbarre/wc-furigana@latest/dist/furigana/furigana.js"></script>
</head>
<body>
  <wc-furigana value="漢[かん]字[じ]" />
</body>
</html>

Examples

Check out the folder examples to see how to integrate the component.