melink14 / rikaikun

rikaikun is a Chrome extension that helps you to read Japanese web pages by showing the reading and English definition of Japanese words when you hover over them.
https://chrome.google.com/webstore/detail/rikaikun/jipdnfibhldikgcjhfnomkfpcebammhp
GNU General Public License v3.0
409 stars 80 forks source link

Doesn't include hiragana after kanji when hovering tofugu ruby spans #198

Open melink14 opened 3 years ago

melink14 commented 3 years ago

From https://www.tofugu.com/japanese/wa-and-ga/

If you take this block and hover the 食べたい then it only detects the kanji without the rest of the word.

The hiragana are a couple levels up from the kanji so it might be tricky.

<li>
  <i></i>
  <ruby>
    <span lang="ja">絶対</span><rp><span lang="ja">(</span></rp><rt><span lang="ja">ぜったい</span></rt><rp><span lang="ja">)</span></rp>
  </ruby>
  <span lang="ja">ダメダメ。でも</span><i></i>
  <ruby>
    <span lang="ja">利沙</span><rp><span lang="ja">(</span></rp><rt><span lang="ja">りさ</span></rt><rp><span lang="ja">)</span></rp>
  </ruby>
  <span lang="ja">ちゃん</span><strong><span lang="ja">が</span></strong><span lang="ja">、うどん</span><i></i>
  <ruby>
    <span lang="ja">食</span><rp><span lang="ja">(</span></rp><rt><span lang="ja">た</span></rt><rp><span lang="ja">)</span></rp>
  </ruby>
  <span lang="ja">べたいって言ってたから</span>…
</li>
melink14 commented 3 years ago

Nevermind, it works when I tested it again just now.

What doesn't work is if there is hiragana after the rubied kanji then the full word isn't read. That's more common since the text nodes are in different elements.

(edited first post and title to match this)