code blocks in markdown files break AI
Hi everyone, cursor is great, thank you very much :)
I'd like to use cursor for helping me to write better docs for my modules, but unfortunately both the chat and the inline-AI break when markdown files have code blocks in it:
Chat screenshot:
Inline screenshot:
Here is my markdown code to reproduce:
# This is a demo
```php
$foo = 'foo';
```
## Some more text
```php
$bar = 'bar';
```
+1 I really need the ability to edit markdown formated docs. As of the last update markdown breaks randomly even without code blocks
An workaround I found until this is fixed is to prompt it to return it in an escaped string format. Then copy the code generated code and unescape it manually using something like this
Thx @Shakerrry you can actually do the same directly in cursor by first prompting "return escaped markdown" and then when its done prompt "now return markdown" and the final result will be ready to copy:
Then click on the final copy icon and paste it into your .md file
+1
Same issue here!
Same issue here, I've just asked it to not use code blocks in the meantime. That works in the meantime.
+1
Seems to be fixed in 0.42 !
A workaround on 0.41 is to prompt the model to use ~~~ to denote markdown codeblocks in replies. (or quadruple backticks)
Yeah! Thx!
Unfortunately I have to reopen this as it still does not work properly
same problem!
Same issue
same issue
+1
This is plaguing my development at the moment. Really useful feature to write documentation, but it is constantly failing to format things properly
+1
On v0.43.5 - still not fixed. If you ask it to generate a README for a repo, it breaks when trying to create a codeblock in Markdown.
Still not fixed - v0.43.6.
This is the workaround I am using until this gets fixed - https://github.com/getcursor/cursor/issues/1705#issuecomment-2332709201
Here is another workaround using .cursorrules https://forum.cursor.com/t/how-to-correctly-create-markdown-files-containing-code-blocks/16650/6
Markdown recipe:
1. Use triple backticks to start and end the outer markdown code block and specify markdown beside your triple backticks. (Use this to start your ____ markup)
2. For the inner code block (for any code examples within your ____ section)
a. drop a line after any heading and before starting your code block
b. Indent the code block with 4 spaces.
c. Use triple backticks to start and end the inner code block.
d. Specify the language next to your triple backticks (e.g., javascript) for syntax highlighting. plan markup.)
It is essential that you follow this guidence if I am to be able to use your output.
or the shorter version:
- 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.
Yeah, I have the problem the markdown seemingly escapes the 'apply' boxes and leaks into the chat/composer, then breaks all the other boxes.