How do I add line breaks in JSON / Algolia?

One of my searches is for scripts. I would like to get to the search results page and then have paragraphs of answers to one question (basically the answer broken up).

How do I accomplish this?

Hi @john2

You can put line breaks into json with the standard \nthat you’ll need to espace so \\n

They should be understandable then when you display your content.

Hope this helps :wink:

I tried that and it showed as “asdfas \nasdfasdfasd”

Does this help https://jsfiddle.net/drsmhwac/ or I’m missing something ?

1 Like

Do you happen to have a recent copy that I can look at?
asfasdfas
asdfasdfas

asdfasdfasdf
asfasd",

13 PM

Same result :frowning:

And if I do \n again

In general, the easiest way is to save HTML in Algolia and not escaoe the value when printed.
If you only need line breaks, you can save \n in the text and use something like nl2br when you print the value.

Pierre Aurele’s example works well, make sure \n is escaped.