'Copy Named Range cell values with line breaks into html/email body [duplicate]

I am trying to copy the named range cell messageHeader into a HTML template to send an email.

The cell looks like this in Google Sheets:

Google Sheets view

The console also displays it correctly:

enter image description here

However, as soon as the HTML template processes this named range value, it flattens all line breakers in cell into a single line, and the email arrives like this.

enter image description here

The code:

const messageHeader = wsS.getRange("messageHeader").getValue()

HTML template code:

<div class="main"><?= messageHeader ?></div>

How can I copy line breaks into HTML teamplate that will show up correctly in the email?
HTML has <br> for line breaks, but I have no idea how to implement this.
Adding <br> in the cell still goes out as plain text in the email instead of new line.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source