aboutsummaryrefslogtreecommitdiff
path: root/api/japanese.ts
diff options
context:
space:
mode:
Diffstat (limited to 'api/japanese.ts')
-rw-r--r--api/japanese.ts8
1 files changed, 5 insertions, 3 deletions
diff --git a/api/japanese.ts b/api/japanese.ts
index add897a..4f176a9 100644
--- a/api/japanese.ts
+++ b/api/japanese.ts
@@ -107,7 +107,7 @@ export default class Japanese {
possibilities.push(path);
return;
}
- // skip until next 'anchor' token
+ // skip until next 'anchor' token (token with no-kanji characters only)
if (tokens[tokenIndex].normalized.length == 0) return match(tokenIndex + 1, searchStart, path);
// try all positions where current (anchor) token fits in this.reading
@@ -120,14 +120,16 @@ export default class Japanese {
// create index slices from possibilities
var slices = possibilities
.map(match => { // convert start index of anchor to start and stop index (based on anchor length)
- var out = [0];
+ var out = [];
let matchIndex = 0;
+ if (tokens[0].ruby) out.push(0);
for (let tokenIndex = 0; tokenIndex < tokens.length; tokenIndex++) {
if (tokens[tokenIndex].normalized.length == 0) continue;
out.push(match[matchIndex], match[matchIndex] + tokens[tokenIndex].writing.length);
matchIndex++;
}
- if (out.peek() != this.reading.length) out.push(this.reading.length);
+ if (tokens.peek().ruby) out.push(this.reading.length);
+ // if (out.peek() != this.reading.length) out.push(this.reading.length);
return out;
})
.filter(slice => slice.length == tokens.length + 1)