Skip to content
This repository has been archived by the owner on Sep 20, 2022. It is now read-only.

jbhannah/agate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gem Version Build Status Dependency Status Code Climate Coverage Status Issues Gitter

Format ruby characters (currently only furigana) in text for display. Requires Ruby 1.9 or later (or compatible engine).

Formatters

Usage

Install the gem with

gem install agate

or add it to your Gemfile:

gem "agate", "~> 0.6.0"

To markup a simple string with delimited furigana:

require "rubygems"
require "agate"

options = {
  # can be any single character or pair of characters which surround ruby characters in text to parse
  :delimiters => "【】" # default delimiters
  # markup formatter to use (options: :plain (default), :html, :strip)
  :formatter => :html
}

a = Agate::Parser.new(options) # call without arguments to use defaults
a.parse("勉【べん】強【きょう】します")

results in

<ruby><rp></rp><rt>べん</rt><rp></rp></ruby><ruby><rp></rp><rt>きょう</rt><rp></rp></ruby>します

which (in your browser) looks like

べんきょうします

It's highly recommended to read the W3C's documentation on the HTML5 ruby element to understand the usage of this element. There is a CSS workaround available that enables the display of ruby characters in all modern browsers, but it's up to you to test all cases where you intend to use the ruby element.

About

Format ruby characters (currently only furigana) in text for display

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages