I am experimenting with the following codepen.io trinket and trying to achieve multiline output with formatting for the JavaScript text that is returned in response to user-input.
For instance, if the user types “/engage” the following text is returned:
“Follow the white rabbit. I want this to be the second line”
The code is below. I would like the above text to:
a) be output on two separate lines with my being able to control the breaks between lines (like br in HTML)
b) allow some basic formatting – specifically to add bold formatting to the word “rabbit”.
c) allow for changing the font size of “follow” to a larger font/or different style etc.
I have tried various things but they all come up with errors.
RELEVANT CODE
submitForm.addEventListener("submit", function(e) {
e.preventDefault();
if (input.value === "/clear") {
clearCommand();
} else if (input.value === "/list" || input.value === "help") {
listAllCommands();
} else if (input.value === "/connect") {
goProgress();
} else if (input.value === "/engage") {
matrixEffect();
clearCommand();
textArea.value = "Follow the white rabbit. I want this to be the second line"
} else {
textArea.value +=
"nERROR: Unknown command! Type 'help' for list of commands.";
input.value = "";
}
textArea.scrollTop = textArea.scrollHeight;
});
CODEPEN ENTIRE SNIPPET