Chat Stream alternating code /code fields from 3 backticks (HTML Javascript css)

Hello

Anyone maybe knows a working example
Chat Stream alternating code /code fields from 3 backticks

struggling with innerText and innerHTML
i can replace tripple backticks alternating
but have problems with linebreaks and br

for example if i
ask: javascript for loop examples

the response is text and code between 3 backticks

i would like them to be in a code field
so that it can be pasted at cursor position in ace editor / html previewer

if any one maybe knows an example in python
also ok

greet luberth

ChatGPT uses a standard markdown to HTML library.

Why do I need to know the word markdown?

It is a standard text formatting that allows one to type an entire post into a forum with a keyboard, and have it displayed in the manner desired.

  • This Discourse-based forum uses a markdown renderer;
  • ChatGPT uses a markdown renderer

Code blocks in markdown

Single and triple backticks are markdown to represent preformatted text and a code block, and text within such a container format is rendered as monospace text.

Like the forum, you will need to use a library that understands the rules of markdown, and what sequences will break out of the containers.

this for example is a code block.

Using a code block, I can 
display `backticks` without 
breaking the container.

Triple-backticks (```) only represent 
a code block on their own line.
If you don't like the code block being interpreted 
and rendered incorrectly, you can specify the 
programming language by starting the code block as:

``` text 

then you get un-colored text. Also that ``` didn't break
out of the code block, you notice.

Because of the strict standardized rules, a library rather than your intuition is required. This will help you render the text produced by the AI that has similar understanding.

Conclusion

Big text comes from # and a space on a new line, rendered as an HTML <H1>Conclusion</H1>. It does not need to be closed. Typing <h1> however needs to be escaped as \<h1>, and showing someone that requires \\\<h1> be typed out, and so on.

Understand what ChatGPT is doing, and you’ll have success.

1 Like

Ok thank you for your explanation
github uses readme.md

now i understand the idea a bit better

thanks
luberth

trying to figure out how the response json works
by printing things to the console

ok maybe
i will search
for a small
md to html javascript that will convert the string for me

thanks

a mechanic that screw things, proud to say ( with your help eye :wink: )
ok md to html
after chat stream is recieved

ask javascript for loop examples