I am using cursor to generate MD files with code snippets. In the chat tab, when generating code snippets the formatting is incorrect. I suspect it’s because the chat panel renders markdown and the double code snippets cause the content to not be displayed correctly
I have also experienced this issue
I was really annoyed with this and found an ugly workaround. maybe you might want to try this out/enhance it. Basically I used rules for ai or a .cursorrules file to force the responses with codeblocks printed as free text.
You can not apply the output directly with the apply button all at once but at least it is readable. I hope cursor team fixes this issue and figures out a way to properly render markdown with codeblocks.
Let me know how it goes!
Sample Rules For AI file
- When proposing an edit to a markdown file, first decide if there will be code snippets in the markdown file.
- If there are no code snippets, wrap the beginning and end of your answer in backticks and markdown as the language.
- If there are code snippets, do not wrap the beginning and end of your answers inside backticks. Instead, output the markdown content as free text. You may use backticks for code snippets within the markdown content.
Cursor output without the rule
Output with the rule
I tried this on ChatGPT’s web interface. Initially, it outputs a result similar to what Cursor does. However, if you ask it to surround the entire markdown file with 5 backticks and use 3 backticks for the rest of the code blocks, it correctly outputs the full markdown file.
It seems that starting a code block with 5 backticks allows the block to close with just 3 backticks in cursor, which might explain why we are having this problem.
This happens to me as well.