你可以把换行符显示为中断< br />? [英] Can you make newline characters \n display as breaks <br />?
问题描述
不正确显示。我宁愿不把它们转换成中断<因为如果用户想要回复那封电子邮件,那么现在就用HTML而不是纯文本。有没有可能是一个JavaScript函数,可以显示为一个换行符而不改变代码? 解决方案
如果将文本放在< pre>
标记中,则会显示所有换行符。或者,您可以通过将CSS样式 white-space:pre 应用于任何元素来达到相同的效果。
不要忘记HTML编码( 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? How about HTML/CSS? If you put your text inside a Don't forget to HTMLencode it still ( 这篇关于你可以把换行符显示为中断< br />?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!< / code>到
& lt;
等),否则它将全部在第一个角度支架分开。 <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.<
to <
etc.), otherwise it will all break apart at the first angle bracket.