Skip to main content

Nested Markdown Support

When AI answers a markdown within ```markdown ```, and there is a code in it, e.g. ```sql ``` formatting breaks.

It seems that ``` ends ```markdown instead of ```sql

Status: Completed12 comments

Log in to comment and vote

Comments12

  • Indigo Stew

    This is also a problem with latex that it sometimes puts within code fences.

  • Sapphire Honey

    I have to encapsulate all my code in ``` to “fix” this issue. Not a HUGE deal, but is annoying.

  • Yellow Toaster

    Good luck with this fix.
    I believe an easy way to prompt the system to escape nested code blockers is to use (\` or \~).

    This is a specific case for Markdown fenced code block; perhaps the Markdown fenced code block can be handled differently where the codefence fence can be tracked somehow. ¯\_(ツ)_/¯

  • White Cucumber

    this is a really important feature for me as one of my main uses of LLMs is to generate documentation

    every time the code block end comes up it breaks formatting even when instructed to produce the output entirely in a single code block like this example

    I know other chat interfaces have the same issue, but some like Claude and Grok can output nested markdown no problem, and of course responses directly from the API are formatted properly

  • Gray Crater

    Another example:


    This was spit out by Gemini 2.5 Flash.

    • Mark Florkowski

      Team

      Would you mind providing the output of the “copy response” button at the end of the message?

      • Gray Crater

        Attaching a text file as pasting in here doesn’t appear correctly.

        raw_copied_message.txt

        4.9 KB• Text

        • Mark Florkowski

          Team

          OK, it seems like the model produced output we were not able to automatically fix. The outer block should have a language designator, but does not, so our parser is unable to correctly detect the nesting.

          Will have a think on how we may be able to address this effectively.

  • Gray Tomato

    would be elated if this gets fixed.

    its not a problem of t3.chat only, its an issue with chatgpt, gemini, etc most of the interfaces.

    on longer markdown files, randomly it starts rendering content and then the motive of using trying to get md output is lost