diff options
| author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-07-17 12:20:11 -0400 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-17 12:20:11 -0400 | 
| commit | a933cfdc0780f618bb1ae60930a82a2af954e3cd (patch) | |
| tree | 4886676976e6664349b48bb855659a74deb127ae /ext/js/display | |
| parent | 4a2b824371e7e2c0f576805631f3ccf29d2c0ad3 (diff) | |
Pronunciation nasal improvement (#1834)
* Organize
* Add utility to get diacritic information about a character
* Show mora without diacritic
* Add a hidden handakuten for copy-paste purposes
Diffstat (limited to 'ext/js/display')
| -rw-r--r-- | ext/js/display/pronunciation-generator.js | 25 | 
1 files changed, 18 insertions, 7 deletions
| diff --git a/ext/js/display/pronunciation-generator.js b/ext/js/display/pronunciation-generator.js index eb5eb035..13e3db3e 100644 --- a/ext/js/display/pronunciation-generator.js +++ b/ext/js/display/pronunciation-generator.js @@ -35,16 +35,14 @@ class PronunciationGenerator {              const n1 = document.createElement('span');              n1.className = 'pitch-accent-character'; - -            const n2 = document.createElement('span'); -            n2.className = 'pitch-accent-character-inner'; - -            n1.appendChild(n2); -              n1.dataset.position = `${i}`;              n1.dataset.pitch = highPitch ? 'high' : 'low';              n1.dataset.pitchNext = highPitchNext ? 'high' : 'low'; + +            const n2 = document.createElement('span'); +            n2.className = 'pitch-accent-character-inner';              n2.textContent = mora; +            n1.appendChild(n2);              if (devoice) {                  n1.dataset.devoice = 'true'; @@ -54,7 +52,13 @@ class PronunciationGenerator {              }              if (nasal) {                  n1.dataset.nasal = 'true'; -                const n3 = document.createElement('span'); +                n1.dataset.originalText = mora; +                n2.textContent = this._getPlainMora(mora); +                let n3 = document.createElement('span'); +                n3.className = 'pitch-accent-character-nasal-diacritic'; +                n3.textContent = '\u309a'; // Combining handakuten +                n1.appendChild(n3); +                n3 = document.createElement('span');                  n3.className = 'pitch-accent-character-nasal-indicator';                  n1.appendChild(n3);              } @@ -142,4 +146,11 @@ class PronunciationGenerator {          node.setAttribute('r', radius);          return node;      } + +    _getPlainMora(mora) { +        const first = mora[0]; +        const info = this._japaneseUtil.getKanaDiacriticInfo(first); +        if (info === null) { return mora; } +        return `${info.character}${mora.substring(1)}`; +    }  } |