That seems to be the best option. I tried using markdown instead of HTML and couldn’t get that working either. The marked.parse() is always adding
around each chunk. Even for markdown, I believe we need to keep a buffer before rendering it.One practical issue about this buffer is that, we need to parse the chunk character by character to see if there is an opening or closing tag since chunks can come in various forms. For example, we may have a chunk like “/>xx” or “xx</>yy”.
This is not an issue.
If you have a closing tag and then plain text afterwards it will show up as plain-text, similar to HTML.
The focus and idea here is that your HTML tags are properly closed before placing them to be rendered
In the case that you are sent a chunk with both a closing tag and a new opening tag you can simply slice the string to only push the closing tag out the buffer
I find it extremely challenging to get this working. For some reason, buffering breaks unexpectedly, and certain tags (eg:
) are always getting dropped.