fix pitch accent color for words with punctuation (#20)
and also for nouns that end in な
This commit is contained in:
parent
e0a80a0fe3
commit
977b5a28d5
|
@ -31,6 +31,7 @@ Fri Jul 7 06:33:50 PM UTC 2023
|
||||||
</div> <!-- /wrap -->
|
</div> <!-- /wrap -->
|
||||||
|
|
||||||
<div style="display:none;">
|
<div style="display:none;">
|
||||||
|
<div id="vocab_kanji">{{VocabKanji}}</div>
|
||||||
<div id="pitchnum_hidden">{{VocabPitchNum}}</div>
|
<div id="pitchnum_hidden">{{VocabPitchNum}}</div>
|
||||||
<div id="kanaword_hidden">{{kana:VocabFurigana}}</div>
|
<div id="kanaword_hidden">{{kana:VocabFurigana}}</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -85,8 +86,21 @@ Fri Jul 7 06:33:50 PM UTC 2023
|
||||||
if (vocab_kana === null) {
|
if (vocab_kana === null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// small っ is one mora; ゃゅょ are parts of single mora
|
let moras = vocab_kana.innerHTML
|
||||||
const n_moras = vocab_kana.innerHTML.replace(/[ャュョゃゅょ]/g, "").length;
|
.replace(/[((<].*[>))]/, "") // remove (お), (する), <する>, <な>, etc
|
||||||
|
.replace(/[ャュョゃゅょ]/g, "") // small っ is one mora; ゃゅょ are parts of single mora
|
||||||
|
.trim();
|
||||||
|
|
||||||
|
let n_moras;
|
||||||
|
// first determine if な is part of pronunciation or な-adjective (e.g. 女)
|
||||||
|
const vocab_kanji = document.getElementById("vocab_kanji").innerHTML.trim();
|
||||||
|
if (/な$/.test(vocab_kanji)) {
|
||||||
|
// な-adjectives don't change pitch
|
||||||
|
n_moras = moras.replace(/な$/, "").length;
|
||||||
|
} else {
|
||||||
|
n_moras = moras.length;
|
||||||
|
}
|
||||||
|
|
||||||
if (n_moras == pitch_num) {
|
if (n_moras == pitch_num) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue