It's because ChatGPT is wrapping the whole Markdown code into a codeblocks using ```
, so the closing ```
in the code close the outer codeblock. To prevent this, you can ask ChatGPT to wrap the Markdown code into ~~~
instead, this will make a codeblock, but since it starts with a different "tag" than those in it, it won't break the rendering.