summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/js/language/japanese-util.js4
-rw-r--r--test/test-japanese.js13
2 files changed, 16 insertions, 1 deletions
diff --git a/ext/js/language/japanese-util.js b/ext/js/language/japanese-util.js
index aa1e3f00..cade393b 100644
--- a/ext/js/language/japanese-util.js
+++ b/ext/js/language/japanese-util.js
@@ -475,13 +475,15 @@ const JapaneseUtil = (() => {
// Check if source is derived from the reading instead of the expression
const readingStemLength = this._getStemLength(readingNormalized, sourceNormalized);
- if (readingStemLength > stemLength) {
+ if (readingStemLength > 0 && readingStemLength >= stemLength) {
mainText = reading;
stemLength = readingStemLength;
+ reading = `${source.substring(0, stemLength)}${reading.substring(stemLength)}`;
}
const segments = [];
if (stemLength > 0) {
+ mainText = `${source.substring(0, stemLength)}${mainText.substring(stemLength)}`;
const segments2 = this.distributeFurigana(mainText, reading);
let consumed = 0;
for (const segment of segments2) {
diff --git a/test/test-japanese.js b/test/test-japanese.js
index 8e8078d1..978f4b9c 100644
--- a/test/test-japanese.js
+++ b/test/test-japanese.js
@@ -750,6 +750,19 @@ function testDistributeFuriganaInflected() {
[
{text: 'おこなわなかった', furigana: ''}
]
+ ],
+ [
+ ['いい', 'いい', 'イイ'],
+ [
+ {text: 'イイ', furigana: ''}
+ ]
+ ],
+ [
+ ['否か', 'いなか', '否カ'],
+ [
+ {text: '否', furigana: 'いな'},
+ {text: 'カ', furigana: 'か'}
+ ]
]
];