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

@paulbarre/wc-furigana

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@paulbarre/wc-furigana

Web component to display easily japanese with furigana

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-16.67%
Maintainers
1
Weekly downloads
 
Created
Source

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.

Keywords

FAQs

Package last updated on 27 Mar 2020

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