Output the multi line input with line breaks in HTML element

Hey fellow Bubblers - question.

I want to be able to take a multi-line input (or rich text editor etc) have the visitor write a number of lines of text on separate lines (line breaks) and then use this output in an HTML element and keep the formating - each line on a separate line

What is currently happening is I get one long line as the output with no line breaks… So I will assume that all the html is stipped along the way.

Is there a way to get around this?

  • One way I could do this (thinking as I type) would be to create a repeating group and construct the line breaks with html and output that… but that seem link overkill.

To give a little more context i am creating a scrolling script based of this: https://codepen.io/cferdinandi/pen/xxYpapK

Where the user can change up the script in-between the tags…

Give the users a special “line-break” key.

For example
\n
or
~b

and do a find/replace for those characters and replace with:
<br>

Unfortunately I’m not sure if the bubble’s multi-line input will recognize a new line normally. I could be wrong, but to be honest I haven’t spent too much time playing with multi-line input.

1 Like

Thanks for that it will be a good workaround in the interim… I did try output as json and that almost worked as it ads a /n to the output but I couldn’t find and replace it for some reason.

Actually, I have managed to do it… in case anyone else comes across this.

  • there are probably a few ways to do this but this is the one I’ve currently chosen.

Create a custom state to hold the data from the multi-line input upon clicking a save button
In the HTML Ensure the value is formatted as Safe JSON. see image:
image

Now in the HTML element you would like this rendered:

image
Add the custom state from above and then run two find and replace one after the other:
first to remove double quotes:
image

Second to remove \n and replace with

image

Works at my current stage of testing (documented for my own reuse if necessary).

4 Likes

Amazing! Thank you so much!

1 Like