mad-ent-java-s22 / indie-project

0 stars 2 forks source link

Create paragraph breaks in generated posts #18

Closed davidtcalabrese closed 2 years ago

davidtcalabrese commented 2 years ago

Text from OpenAI API comes back with paragraphs separated by "\n"s. Currently these don't appear in tiny editor as paragraphs.

The plan is to search the response text for newline characters and replace them with <p> tags.

davidtcalabrese commented 2 years ago

Doesn't seem to be working. I wonder if the p tags are getting escaped somewhere in the process? Probably within the JSP.

davidtcalabrese commented 2 years ago

Fixed it. The problem was I had too many escape characters in the text of the target argument to replace().

Changed this:

String postTextWithParagraphBreaks = postText.replace("\\n\\n", "<p>");

to this:

String postTextWithParagraphBreaks = postText.replace("\n\n", "<p>");

and now its working.