V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
websong188
V2EX  ›  分享创造

烦了很久的 cursor markdown 代码块转义混乱问题 ! 写 prompt 解决了

  •  1
     
  •   websong188 · 10 天前 · 1301 次点击

    cursor 生成 markdown 会出现代码块转义混乱问题

    使用 cursor 生成带有代码片段的 markdown 文件时,包含代码和 json 的地方,它会自动分割成块

    只能局部应用到 cursor,无法全部应用到 md 文件

    甚至有时候还会出现断开的混乱渲染情况

    提问如果没特别要求,每次输出的情况都可能不一样

    参考 cursor 社区和网上的方法,整合了个常用的 prompt,使用起来挺稳定的

    解决 cursor markdown 格式渲染和代码缩进问题的 prompt

    Format your response in markdown according to the following requirements:
    
    - When proposing an edit to a markdown file, first evaluate whether the content will contain code snippets
    - If the content contains no code snippets, enclose the entire response in backticks with 'markdown' as the language identifier
    - If the content includes code snippets, ensure all code blocks are indented with exactly 2 spaces and specify the correct language for proper rendering
    - Only 2-space indentation is allowed for code blocks - level 0 and 4 space indentations are not permitted
    - Automatically correct any code block indentation that doesn't follow the 2-space rule
    
    

    需要 cursor 输出 markdown 内容时,复制上面提示词贴入 cursor 聊天框即可

    具体示例和效果可看博客文章: 解决 Cursor Markdown 格式代码块转义、缩进问题

    有普通 markdown 结果 和使用 prompt 的结果对比

    3 条回复    2025-02-14 09:40:31 +08:00
    linqiu919
        1
    linqiu919  
       9 天前 via iPhone
    可以,解决一大难题。
    wryyyyyyyyyyyy
        2
    wryyyyyyyyyyyy  
       8 天前
    每次复制好麻烦,为什么不放在 .cursorrules 中呢?
    websong188
        3
    websong188  
    OP
       8 天前
    @wryyyyyyyyyyyy 当然可以!
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2837 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 13:48 · PVG 21:48 · LAX 05:48 · JFK 08:48
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.