That isn't a problem with MongoDB, but you found out how HTML works :)
When you submit a textarea, all newlines are simply newline characters sent to the server (
or
). They are stored in the database as is.
However, in HTML newlines are ignored and considered like spaces, when representing text (unless you wrap that in a <pre></pre>
block).
The solution is to replace all
with <br />
tags. If you're familiar with PHP, it would be using the nl2br
function, which has been ported to JavaScript here: http://phpjs.org/functions/nl2br/
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…