Implement the HTML tag <ruby>
for Hexo using Tag Plugin feature. Provide auto pronounciation indication for Jyutping (Cantonese), Zhuyin (Taiwanese Mandarin), and Pinyin (Chinese Mandarin), and the default setting for general usage. Support Traditonal and Simplified Chinese characters.
Inspired by the hexo-ruby-character by jamespan.
Install
npm install hexo-zhruby --save
Use cases
Ruby (ルビ) is also known as Furigana (振り仮名). It contains two basic use cases:
- To clarify or indicate the pronunciation for readers
- Gikun, in which the characters have different pronunciations than they seem due to convention or for a specific context. For example, the pronunciation of 煙草 in Japanese is tabako (tobacco).
Usage
TLDR: Usage: {% tag rb|rt %}
; Tag options: ruby_def
, ruby_jy
, ruby_py
, ruby_zy
.
For the 1st use case (pronunciation indication):
ruby_def
allows any language, and the spacing in rp
will expand evenly with respect to the word length in rt
.
{% ruby_def 基本|きほん %}
→ 基本{% ruby_def 基本|기본 %}
→ 基本{% ruby_def 基本|fundamental %}
→ 基本{% ruby_def 基本|θεμελιώδες %}
→ 基本{% ruby_def 基本|базовый %}
→ 基本{% ruby_def 基本|základní %}
→ 基本{% ruby_def fundamental|基本 %}
→ fundamental
ruby_jy
, ruby_py
, ruby_zy
refers to Jyutping, Pinyin, Zhuyin respectively.
No need to enter the pronunciation manually in rt
; the value will automatically be returned.
{% ruby_zy 基本 %}
→ 基本{% ruby_py 基本 %}
→ 基本{% ruby_jy 基本 %}
→ 基本
For the 2nd use case (Gikun):
Same usage for ruby_def
.
{% ruby_def special|basic %}
→ special{% ruby_def 特別|基本 %}
→ 特別
In ruby_jy
, ruby_py
, ruby_zy
, you can also add |rt
just like ruby_def
.
{% ruby_zy 特別|special %}
→ 特別{% ruby_py 特別|special %}
→ 特別{% ruby_jy 特別|special %}
→ 特別{% ruby_zy 特別|基本 %}
→ 特別{% ruby_py 特別|基本 %}
→ 特別{% ruby_jy 特別|基本 %}
→ 特別
Notice that the rt
output depends on the pronunciation in rt,
but not rp.
This feature is only available when rt
is a Chinese Character in CJK Unified Ideographs (\U4E00-\U9FFF).
If the input of rt
is not in CJK Unified Ideographs, it is considered as ruby_def
.
Known issues
The Chinese language contains a lot of Homophones, which can be resolved by context most of the time. However, for long sentences (>= 15 characters), or very specific names and terms, the auto-generation from 1st use case may not be very sensitive.
Please use ruby_def
if it happens or contribute to this project by providing a more sensitive or advanced Chinese vocabulary library.
References
- CJK Unified Ideographs (Unicode block)
- Homophone
- Gikun (japanese only)
- Gikun (English version under the article Kanji)
- <ruby>: The Ruby Annotation element
- Unicode/Character reference
- Universal Character Set characters (Unicode)
Please cite the source for reprints, feel free to verify the sources cited in the article, and point out any errors or lack of clarity of expression. You can comment in the comments section below or email to GreenMeeple@yahoo.com