Answer the question
In order to leave comments, you need to log in
How to properly pull text from MongoDB while preserving spaces and indents?
Faced a problem. Saving a huge piece of text in MongoDB removes spaces and indents where they should be. When I render them in html, there is no indentation. How can I save them? I use NodeJS, MongoDB and Handlebars. I would like to read articles about this and I will be very grateful if you throw off a couple of good articles on this topic.
Answer the question
In order to leave comments, you need to log in
Is it Mongo's fault? The key phrase in the question is "output them in html". And by default, when displaying html, any sequences of whitespace characters (tabs, spaces, newlines, etc.) are displayed as a single space.
To display the text as it is - with all whitespace characters - you must use either https://webref.ru/html/pre or https://webref.ru/css/white-space .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question