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?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
white-space CSS works fine but for cross-browser compatibility
Your Html
MDN Source
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 stylewhite-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.Just add this
white-space
css style property to render Multiline texts :and then :
now newlines will render like br elements.