Skip to content

Commit

Permalink
Fix combineJamo bug
Browse files Browse the repository at this point in the history
  • Loading branch information
annedrewhu committed Feb 6, 2023
1 parent 73d8c73 commit 2efe5d0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions rules/kor/kor-rr.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
result = input.replace(regex, replacement);

// This regex matches jamo that form a syllable so they can be combined
var jamoRegex = /([-])([-])([-])?([-]|[\- '])$/;
var jamoRegex = /([-])([-])([-])?([-]|[\- '])(.*)$/;
if (jamoRegex.test(result)) {
return { noop: false, output: result.replace(jamoRegex, combineJamo) };
} else {
Expand All @@ -156,7 +156,7 @@
// Conjoining jamo behavior is defined by this Unicode standard
// https://www.unicode.org/versions/Unicode13.0.0/ch03.pdf#G24646
// parameter `final` is optional
function combineJamo(substring, initial, vowel, final, justTyped) {
function combineJamo(substring, initial, vowel, final, nextSyllableInitial, otherChars) {
// Get the UTF code for each character
var initialNo = initial.charCodeAt(0);
var vowelNo = vowel.charCodeAt(0);
Expand All @@ -176,10 +176,12 @@
var syllable = String.fromCharCode(syllableNo);

const disambig = /[\- ']/;
if (justTyped.match(disambig)) {
if (nextSyllableInitial.match(disambig)) {
return syllable;
} else if (otherChars.match(disambig)) {
return syllable + nextSyllableInitial;
}
return syllable + justTyped + otherChars;
return syllable + nextSyllableInitial + otherChars;
}
$.ime.register( koreanRR );
}( jQuery ) );

0 comments on commit 2efe5d0

Please sign in to comment.