#GPT just can't output nested ```code blocks``` (triple backtick fences)

1 messages · Page 1 of 1 (latest)

gentle bridgeBOT
#

Reported by @marsh bridge

Bug Report: GPT just can't output nested ```code blocks``` (triple backtick fences)
`Steps to Reproduce`

I have documentation for how to write documentation (eg: Sphinx, Markdown, RST). I need to nest code blocks within code blocks to show how... to write code blocks.

Eg (copy the outer backtick fence for repro):

```rst
```md
## This is a markdown h2

No matter how instructed to chatgpt, the output is *always* incorrect. **ChatGPT needs to be able to evaluate how the end-result appears to the user** - I think it's just auto-parsed without any AI consideration.
`Expected Result`

The output should be 1 big code block; it should never pop out of code block and show as rich text.

`Actual Result`

It shows partial code block, then awkwardly pops out half way and turns into rich text

`Environment`

win11, latest chrome

#
Additional Information

Please provide relevant details to help resolve the issue, such as:

  • ChatGPT Shared Link (if applicable).
  • Screenshots or videos demonstrating the problem.

-# ➜ Need to contact support? Visit the OpenAI Help Center.

marsh bridge
#

This is still an issue all this time later. For the most common scenario ever:

Make a README.md with code block examples

ChatGPT will fail hard because it still can't wrap code blocks (eg, cs) within parent code blocks (eg, md).

The answer is to actually use quadruple+ backticks on the outside, if nested. It will never know this unless you explicitly instruct it.

This should be built within to the core instructions. Making code blocks within code blocks (again, the README.md example) is very, very common.

#

Issue example (very easy to repro):