DEV Community

Discussion on: Advice Needed ➡️ Rails+React/Next.js: how to store code blocks so formatting persists?

Collapse
prosenjit98 profile image
prosenjit98

You can store it as sting in back-end data base.. and use "white-space: pre-wrap" html property show as it is.

Collapse
bigfishh profile image
Annie Zheng Author

oh, that's fascinating! I'll give it a try, thanks!

Collapse
sylwiavargas profile image
Sylwia Vargas

Oh, interesting! Do you think that this would preserve the new lines as well?

And how would you go about making sure that ‘,’, and ” don’t mess up the db entry?

(Just curious what’s possible!)

Collapse
prosenjit98 profile image
prosenjit98

Just one correction use "Text" type instead of "String" type

Collapse
prosenjit98 profile image
prosenjit98

answer of first question, yes it will preserve everything.
and for second one my answer is also positive, believe me nothing will mess up just try it once.