Expanding Rich Text Areas

Hi, i used all the info i got to create a text field with a show more or show less button. Later i found out, that with plain text im not able to do line breaks, so i start using rich text instead.
Now i got the problem, that the text contains the html format elements and show them when reduced at the wrong place.
is there any convenient way to do so?

Hi,
Please share your code so we can inspect.