thorium-reader icon indicating copy to clipboard operation
thorium-reader copied to clipboard

Annotation does not work properly (japanese)

Open Lapse176 opened this issue 1 year ago • 2 comments

Image When I highlight, I can copy the kanji text. However, in annotate section, kanji and furigana get mixed up

Lapse176 avatar Mar 27 '25 12:03 Lapse176

Thank you for pointing this out. Thorium uses the standard Web API to obtain the text inside the DOM selection (element.textContent). This is plain text, no HTML markup. So, it looks like we need to suppress the Ruby, just like cliboard copy/paste?

danielweck avatar Mar 27 '25 13:03 danielweck

With me, I just need annotate kanji text. In epub, furigana use the <ruby> element. Example 1: <ruby>空<rt>そら</rt></ruby> With 1 word (Example 1) , we can obtain kanji with element.firstChild.textContent But with 2 words or more, there are 2 situation. Example 2: <ruby>季節<rt>きせつ</rt></ruby> Example 3: <ruby>季<rt>き</rt>節<rt>せつ</rt></ruby> Example 2 use element.firstChild.textContent like Example 1. In Example 3, I think should use Regex to remove all <rt> tag and text in it. element.innerHTML.replace(/<rt>.*?<\/rt>/g, '')

Lapse176 avatar Mar 28 '25 09:03 Lapse176