rubyann – for people too lazy to write Ruby

At last, I’ve written my own jQuery plugin.

My plugin tries to help lazy people (a noble cause) to write Ruby. It’s called rubyann which is short for ruby annotation.

But you have to understand something about Ruby… hardly anyone knows about it – it’s quite obscure.

Ruby is part of XHTML 1.1 – and now part of HTML 5. Ruby characters are small reading aids that are placed on top of characters. They can be useful for any language, but my interest comes from Japanese furigana – here’s what Ruby looks like:

The 1st example uses Ruby to explain a translation and the 2nd uses furigana
ruby example
And yes, that really is a translation – the word “kill” is not needed to say “kill 2 birds with 1 stone” – it’s obvious!

 

To get this seemingly simple annotation you must type XML into your HTML:


<ruby>

<rp>(</rp>
<rt>1</rt>
<rp>)</rp>
</ruby>

And that’s just for the 1st character! Multiply that XML by the number of ruby characters you want… and you’d better have an automated HTML ruby generator or rubyann

rubyann inserts the required ruby XML where it finds markup (I invented), so this:

With rubyann eg: $('.textWithFurigana').rubyann(); becomes this: I’ve written the jQuery plugin in coffeescript and it’s on GitHub – rubyann

Here’s what it looks like in my editor, RubyMine, with the coffeescript plugin

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: