From 13c95cbbd0e827a00c921c2443e2fdc518133d7e Mon Sep 17 00:00:00 2001 From: Ren Tatsumoto Date: Sun, 5 Mar 2023 03:48:00 +0300 Subject: [PATCH] update japanese sentences --- .../Japanese sentences/Recognition/front.html | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/templates/Japanese sentences/Recognition/front.html b/templates/Japanese sentences/Recognition/front.html index 29ac950..b5228f9 100644 --- a/templates/Japanese sentences/Recognition/front.html +++ b/templates/Japanese sentences/Recognition/front.html @@ -116,7 +116,6 @@ Sun Mar 5 12:08:06 AM UTC 2023 } function formatNewRuby(kanji, readings) { - console.log(kanji, readings) if (readings.length > 1) { return `${formatNewRuby(kanji, readings.slice(0, -1))}${readings.slice(-1)}` } else { @@ -125,15 +124,19 @@ Sun Mar 5 12:08:06 AM UTC 2023 } function reformatMultiFurigana() { - const separators = /[\s,.、・。]+/iu; + const separators = /[\s;,.、・。]+/iu; document.querySelectorAll("ruby").forEach(ruby => { - const kanji = ruby.querySelector("rb").textContent - const readings = ruby.querySelector("rt") - .textContent.split(separators) - .map(str => str.trim()) - .filter(str => str.length) - if (readings.length > 1) { - ruby.innerHTML = formatNewRuby(kanji, readings) + try { + const kanji = (ruby.querySelector("rb") || ruby.firstChild).textContent.trim() + const readings = ruby.querySelector("rt").textContent + .split(separators) + .map(str => str.trim()) + .filter(str => str.length) + if (readings.length > 1) { + ruby.innerHTML = formatNewRuby(kanji, readings) + } + } catch (error) { + console.error(error); } }) }