From 3a01fa356b01fc1ba908798cf7a0192936da1d96 Mon Sep 17 00:00:00 2001 From: Ren Tatsumoto Date: Tue, 7 Mar 2023 05:16:21 +0300 Subject: [PATCH] fix for missing pitch info when added by yomichan --- .../Japanese sentences/Recognition/back.html | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/templates/Japanese sentences/Recognition/back.html b/templates/Japanese sentences/Recognition/back.html index 49c95a1..3500934 100644 --- a/templates/Japanese sentences/Recognition/back.html +++ b/templates/Japanese sentences/Recognition/back.html @@ -13,7 +13,7 @@
{{VocabAudio}}{{SentAudio}} -
{{VocabPitchPattern}}{{^VocabPitchPattern}}{{text:kana:VocabFurigana}}{{/VocabPitchPattern}}
+
{{VocabPitchPattern}}{{^VocabPitchPattern}}{{text:kana:VocabFurigana}}{{/VocabPitchPattern}}
{{#VocabPitchNum}}{{text:VocabPitchNum}}{{/VocabPitchNum}} {{#VocabKanji}}
{{text:kanji:VocabKanji}}
{{/VocabKanji}}
@@ -62,7 +62,21 @@ tags.innerHTML = tags.innerHTML.replace(/[\[\]]/g, ""); } } + + function removeNoPitchAccentDataText() { + const has_no_data = (tag) => tag.innerText.toLowerCase().includes("no pitch accent"); + const pitch_num = document.getElementById("pitchnum"); + const pitch_pattern = document.getElementById("pitchpattern"); + if (pitch_num && has_no_data(pitch_num)) { + pitch_num.remove(); + } + if (pitch_pattern && has_no_data(pitch_pattern)) { + pitch_pattern.innerHTML = `{{text:kana:VocabFurigana}}`; + } + } + markPitch(); removePitchBrackets(); tweak_reveal_text(); + removeNoPitchAccentDataText();