I'm trying to display emails with IMAP. When the email is text though, the newlines \n don't display properly. I'd rather not convert them to breaks < br /> because if the user wanted to reply to that email, it would now be in HTML instead of plain text. Is there perhaps a javascript function that could display it as a line break without changing the code?
Newline (frequently called line ending, end of line (EOL), next line (NEL) or line break) is a control character or sequence of control characters in a character encoding specification (e.g., ASCII, EBCDIC) that is used to signify the end of a line of text and the start of a new one.
<br>: The Line Break element. The <br> HTML element produces a line break in text (carriage-return). It is useful for writing a poem or an address, where the division of lines is significant.
Use block-level elements to break the line without using <br> tag. There are many ways to break the line without using <br> tag. The used properties are listed below: white-space: pre; It is used to make elements acts like <pre> tag.
The <br> tag inserts a single line break. The <br> tag is useful for writing addresses or poems. The <br> tag is an empty tag which means that it has no end tag.
How about HTML/CSS? If you put your text inside a <pre>
tag, it will show all newlines exactly as they were. Alternatively, you can achieve the same effect by applying the CSS style white-space:pre
to any element.
Don't forget to HTMLencode it still (<
to <
etc.), otherwise it will all break apart at the first angle bracket.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With