Line breaks in strapi

Im using strapi for my backend and nextjs for my front end with react-markdown. How do you use linebreaks in the strapi backend? For example this is a blog post I have made - https://www.thejuniorwebdev.com/guides/mern/making-requests-to-mongodb which should really have a line break before what is clubsman and after what is clubsman.

Thanks,
Dan

In markdown, typically you need a double return but it also depends if your frontend is directly reading markdown or if you are using a library to convert markdown to another format. Especially in markdown to html, there are a handful of extremely poor libraries that don’t handle it well.

So the current rich text editor cannot register line breaks?

And clients that use it as a cms for their website need to learn markdown to edit a simple article?

Strapi is getting more disappointing… (also because of the lack of user role editing)

On the frontend, try converting your markdown before giving it to your markdown library:

(`1\n2...\n\n3!`).replace(/\n/gi, "  \n")

And use this css:

.line-break {
  white-space: pre-wrap;
}

So if you’re using ReactMarkdown library for example:

<ReactMarkdown className="line-break" children={yourContent.replace(/\n/gi, "&nbsp; \n")} />
3 Likes

text = text.replace(/\n/gi, “
\n”);
this worked for me