It's hard to generate a markdown document

In the “Chat” tab, even if I tell the LLM to wrap the content in a plain text code block, but Cursor cannot regard the code blocks in the markdown content as an inner content of the outer plain text block, I cannot copy the generated content in an easier way, the only thing I can do is to copy the whole message, which is painful and I cannot use the composer with the document generation.

And in the documentation file, if I use “Ctrl+K” to generate the document content, it will stop at a start of the code block.

2 Likes

I had a similar issue with composer. It generated some code in multiple files for me and gave the explanation and code snippets in the composer window. Then I asked it to generate documentation in somefile.md with explanations and code samples. It generated the first two headings with paragraphs and then stopped.

Hi @backrunner

As a temporary solution, here’s a tip:

Unfortunately, this error has still not been rectified, which severely restricts my work.
I regularly have the AI create documentation in .md format which of course must contain code snippets.
This is simply not possible under Cursor. There is always a faulty output as soon as there is only one single code snipplet within the generated .md file.
With Cursors largest competitor from codeium this is possible without any problems (.md documentation can be created and edited)
For me this bug is extremely annoying and unfortunately a reason to stop using Cursor if it is not fixed soon.

I use the codeium product and Cursor and would actually prefer Cursor because it copes better with the given context.

This technique works for me about 95% of the time …

Create a file in your codebase (I put it in directory called .prompts/) and name it something like md_format.md with the following:

Format your reponse in markdown with these strict formatting rules: 
- Provide your response as a markdown file
- Wrap the beginning and end of your answer in backticks and markdown as the language.
- NEVER EVER UNDER ANY CIRCUMSTANCES ADD ANY BACKTICKS INSIDE THE MARKDOWN.
- If there are code snippets, you will be tempted to add backticks around the code but DO NOT DO THIS. Instead you can indent the code with 4 spaces. This applies to any output you might normally wrap in backticks, including but not limited to:
0. JSON
1. Programming code in any language
2. Command line instructions
3. Configuration files
4. Raw data formats like JSON
5. File paths or system output
6. Stack traces or error messages
7. Markup languages (HTML, XML, etc.)
- Check your output before providing it to me and ensure it complies with ALL these rules WITHOUT EXCEPTION.

Anytime you want the model to return it’s response in 100% markdown, reference the file at the end of your prompt.

For example:

Provide documentation for the frontend developer for the API endpoints you just added in @md_format.md

This should cue the model to return its next response entirely in markdown format and displayed in codeview so it can be easily copied.

2 Likes