cursor icon indicating copy to clipboard operation
cursor copied to clipboard

code blocks in markdown files break AI

Open BernhardBaumrock opened this issue 1 year ago • 6 comments

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:

image

Inline screenshot:

image

Here is my markdown code to reproduce:

  # This is a demo
  
  ```php
  $foo = 'foo';
  ```
  
  ## Some more text
  
  ```php
  $bar = 'bar';
  ```

BernhardBaumrock avatar Aug 26 '24 17:08 BernhardBaumrock

+1 I really need the ability to edit markdown formated docs. As of the last update markdown breaks randomly even without code blocks

strueman avatar Sep 02 '24 13:09 strueman

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

Shakerrry avatar Sep 05 '24 17:09 Shakerrry

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:

image

Then click on the final copy icon and paste it into your .md file

BernhardBaumrock avatar Sep 05 '24 22:09 BernhardBaumrock

+1

oliviermills avatar Sep 08 '24 06:09 oliviermills

Same issue here!

bakaburg1 avatar Sep 12 '24 15:09 bakaburg1

Same issue here, I've just asked it to not use code blocks in the meantime. That works in the meantime.

johnnyhuy avatar Sep 14 '24 07:09 johnnyhuy

+1

oliviaBahr avatar Sep 20 '24 23:09 oliviaBahr

Seems to be fixed in 0.42 !

image

A workaround on 0.41 is to prompt the model to use ~~~ to denote markdown codeblocks in replies. (or quadruple backticks)

lyallh avatar Oct 11 '24 20:10 lyallh

Yeah! Thx!

BernhardBaumrock avatar Oct 11 '24 21:10 BernhardBaumrock

Unfortunately I have to reopen this as it still does not work properly

BernhardBaumrock avatar Oct 21 '24 15:10 BernhardBaumrock

same problem!

BestLemoon avatar Oct 27 '24 02:10 BestLemoon

Same issue

abhirupghosh avatar Nov 08 '24 21:11 abhirupghosh

same issue

CyrusTC avatar Nov 10 '24 15:11 CyrusTC

+1

abh1nav avatar Nov 15 '24 03:11 abh1nav

This is plaguing my development at the moment. Really useful feature to write documentation, but it is constantly failing to format things properly

flatherskevin avatar Nov 21 '24 18:11 flatherskevin

+1

moneyhubcolin avatar Nov 28 '24 11:11 moneyhubcolin

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.

abh1nav avatar Nov 28 '24 17:11 abh1nav

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

payapula avatar Dec 15 '24 07:12 payapula

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.

ukituki avatar Dec 15 '24 23:12 ukituki

Yeah, I have the problem the markdown seemingly escapes the 'apply' boxes and leaks into the chat/composer, then breaks all the other boxes.

djoyce-ts avatar Mar 05 '25 05:03 djoyce-ts