Problems formatting open ai streaming response

My open ai output previously (before streaming) showed up just fine on weweb. 

However, when I try to stream the same data to weweb, joining the chunks in weweb, streaming causes the output to be formatted incorrectly. Specifically, All the paragraphing / line breaks available in the open ai output is now gone. 

I have already tried replacing \n with <br> but that messes the formatting even more because now my h2 tags (## ) just show up as hashtags and the sub headers don’t show.

hope this makes sense…

Why is that so am how can I get the format to stay the same? 

2 replies