D
D
Daniil Yakovlev2021-01-20 14:56:38
MongoDB
Daniil Yakovlev, 2021-01-20 14:56:38

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

1 answer(s)
A
Andrey Ezhgurov, 2021-01-20
@Kamiya_Nya

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 question

Ask a Question

731 491 924 answers to any question