Skip to content

rubyann is a javascript library that converts a custom syntax to ruby annotations eg furigana (returns XHTML text or writes directly into the HTML)

License

Notifications You must be signed in to change notification settings

PandaWood/rubyann

Repository files navigation

RubyAnn

(see also the original jQuery version jquery.rubyann)

I've written this non-jquery version to basically become the main library for rubyann... it has no dependencies; is more flexible and is written in TypeScript.

NPM

rubyann is a small library for writing ruby annotations using a simplified syntax. Basically, to avoid writing the tedious XML required. This is most often used for Japanese furigana.

For most users, this will simply mean - a convenient way of adding Furigana to their Kanji in a web page.

Example

It works by using the custom syntax below:

{日,に}{本,ほん}{語,ご}

ie {kanji,furigana} any text here

rubyann will parse this and can replace the HTML with ruby annotations that looks like this:

RubyAnn result

This is done by using rubyann in javascript like this:

  let ann = new RubyAnn()
  ann.elements('.furigana-text')

It's also possible to pass your own delimiters - incase there's a conflict. eg new RubyAnn('[]') - the function/constructor takes a string of 2 characters (start/end).

Another use of the library is to get the raw XML/XHTML, without writing to the DOM, to use however you need.

  let ann = new RubyAnn()
  ann.getXml('{鳥,とり}')   // returns '<ruby><rb>鳥</rb><rp>(</rp><rt>とり</rt><rp>)</rp></ruby>'

Source Code

rubyann is written in TypeScript; has a Mocha test suite and a Demo HTML Page that can be run locally.

Build

Requirements

If you want to clone and build RubyAnn yourself you'll need:

NodeJS

Tasks

npm install or yarn - installs the (NPM) dependencies (yarn is highly recommended)

npm run release or yarn release - transpiles the TypeScript source and minifies the javascript to 'dist' directory

npm run test or yarn test - transpiles and runs the test suite

About

rubyann is a javascript library that converts a custom syntax to ruby annotations eg furigana (returns XHTML text or writes directly into the HTML)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages