From 3fda848967157876be94a640a887be7eb029d84c Mon Sep 17 00:00:00 2001 From: MarvNC Date: Fri, 19 Jan 2024 23:19:25 -0800 Subject: [PATCH] Finish convertGlossToSC --- src/util/yomitan/convertGlossToSC.js | 56 ++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/src/util/yomitan/convertGlossToSC.js b/src/util/yomitan/convertGlossToSC.js index 28b6230..fd3721d 100644 --- a/src/util/yomitan/convertGlossToSC.js +++ b/src/util/yomitan/convertGlossToSC.js @@ -1,8 +1,8 @@ import { languages } from '../../constants'; import { isStringSentence } from '../textHandling/textUtils'; -const examplePhrase = '配詞 / 用法'; -const exampleSentence = '例句'; +const examplePhraseText = '配詞 / 用法'; +const exampleSentenceText = '例句'; const examplePhraseEmoji = '💬'; const exampleSentenceEmoji = '📝'; @@ -50,20 +50,46 @@ function convertGlossToSC(gloss) { { tag: 'div', data: { - wordshk: 'phrase', + wordshk: 'examples', }, - content: phrases.map((phrase) => { - return convertLanguageDataToUlSC(phrase, true); - }), - }, - { - tag: 'div', - data: { - wordshk: 'sentence', - }, - content: sentences.map((sentence) => { - return convertLanguageDataToUlSC(sentence, false); - }), + content: [ + { + tag: 'div', + data: { + wordshk: 'phrase', + }, + content: [ + { + tag: 'span', + content: examplePhraseText, + style: { + listStyleType: `"${examplePhraseEmoji}"`, + }, + }, + ...phrases.map((phrase) => { + return convertLanguageDataToUlSC(phrase, true); + }), + ], + }, + { + tag: 'div', + data: { + wordshk: 'sentence', + }, + content: [ + { + tag: 'span', + content: exampleSentenceText, + style: { + listStyleType: `"${exampleSentenceEmoji}"`, + }, + }, + ...sentences.map((sentence) => { + return convertLanguageDataToUlSC(sentence, false); + }), + ], + }, + ], }, ], };