Looks like the cursor has a problem when editing markdown content

Very easy to reproduce in deepseek R1

It happens when the resulting markdown contains a code block. The code block kind of make the composer switch form “file content” to “output content”. The result is that the target markdown file only contains the changes prior to the code block and the composer output contains the rest.

1 Like

Hey, does this happen with any model specifically, or all of them?


I was able to reproduce it with this prompt (test.md being an empty file):
“In test.md file, give me an explanation in markdown format for a command line to commit to git with a usage example in a powershell code block.”

As you can see in the screenshot, after the title “## Basic syntax”, composer outputs a bash code block that gets “out” of the test.md file to land in the composer output with the rest of the changes.

It is the same behaviour on claude sonnet, gtp-4o and cursor-small

Hey, we have this case fixed internally, and will hopefully get this out to you in 0.46! No ETA right now yet, still testing :slight_smile:

3 Likes

Also experiencing this bug whenever models generate code blocks inside markdown.

Looking forward to the fix in 0.46.

finally!! thank u for your great efforts

Still happening with me. I am using Cursor 0.45.14 with claude-3.7-sonnet
Cursor should instruct the LLM to use XML to delimit files

1 Like

Edit

Have tried 0.46.11 and the following solution is not needed anymore :sweat_smile:. It just works, without any rules!


I can easily fix this problem by adding the following to the “Rules for AI” setting:

While generating Markdown code, if the Markdown code contains code blocks, remember to enclose the outermost Markdown code block with at least 4 backticks, instead of only 3.

You can see the rendering was problematic before I added the rule:

But the problem is fixed after adding the rule:

The reason is that the Markdown spec (CommonMark) allows more than 3 backticks and requires that the closing code fence must be at least as long as the opening fence.

This way, the model can safely use the backticks in Markdown. You’ll get the code blocks as expected in the generated Markdown files/snippets without turning them into plain text.

If it doesn’t work, maybe you can try a more detailed prompt. Hope this helps.

Cursor version: 0.45.14.
Model: Claude 3.5 Sonnet