(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.
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.
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:
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>'
rubyann is written in TypeScript; has a Mocha test suite and a Demo HTML Page that can be run locally.
If you want to clone and build RubyAnn yourself you'll need:
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