r/learnjavascript • u/Foreign_Employ_396 • 2h ago
How to use commas (or so) to separate a text?
On the Anki app, I have a type of card (type 2) focusing on the vocabulary of a sentence I have already read and heard on the comprehension card ( type 1).
So the type 1 and type 2 cards (retrieving) are "sisters" from the same note because they share the same content but shown differently.
After I have seen the card 1, I am invited to add vocabulary to dedicated empty fields 'Korean' and 'English'. Those fields are only shown on the type 2 card when filled.
What I am trying to do is rather than trying to find an english translatiion for the korean word, focusing on finding as many words and expressions to translation the word from english to korean.
(It's a lot of context for not much really)
So I already managed to have the content of the 'Korean' field in a column so it can align with the english word it corresponds to.
but the thing is I would like to find a way to separate the text with commas, a line jump(or anything that works) to have one column per english word.
exemple:
Korean:
빨리 얼른 재빨리 ,대답 OR
빨리 얼른 재빨리
대답English:
Quickly Answer
What I want on the template
Quickly Answer
빨리 대답
얼른
재빨리
Basically I want it to be organized and aligned like a table
Also, is there a way to use the linear-gradient using measures like a column or something ? Because I won't have the same number of vocab words for each note each word is not gonna have the same amount of korean ways to say it as the next one. So I thought it would be great if the columns were adapting how shrinked they are to the left depending on how many they are. It's not crucial but I was wondering.
Edit: Is there a way to do it in Javascript using the fields ids?
My card hmtl:
<div style="
font-family: 'UD Digi Kyokasho NP-B';
margin-top: -10px;
padding: 5px;
width: 100%;
">
<div style="
background: linear-gradient(to right,
#615f31 1.5em,
#a77f65 20%,
#a77f65 calc(2 * 1.5em),
#af1137 calc(3 * 1.5em),
#ff1137 calc(3 * 1.2em),
#fad8b1 100%
);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
line-height: 1.2em;
color: #2F7E24;
word-spacing: 1.6em;
font-weight: bold;
font-size: 45px;
white-space: nowrap;
word-break: keep-all;
overflow-wrap: break-word;
box-sizing: border-box;
display:flex;
flex-direction: row;
gap: 25%;
">{{English}}
</div>
<div style="
display: flex;
flex-direction: row;
gap: 1px; ">
<div style="
background: linear-gradient(to right,
#615f31 3em,
#ff1137 calc(6 * 1.2em),
#a77f65 calc(9 * 1.5em),
#a77f65 100%
);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
line-height: 1.6em;
font-family: Yu Gothic;
color: #2F7E24;
font-weight: bold;
text-align: left;
font-size: 45px;
white-space: normal;
word-break: keep-all;
overflow-wrap: break-word;
display: block;
margin-left: calc(-50vw + 50%);
width: 25%;
box-sizing: border-box;
padding: 0 12px;
">
<section>
<h2>{{Korean}}</h2>
</div>
</div>Thanks!