V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
爱意满满的作品展示区。
websong188

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

  •  1
     
  •   websong188 · Feb 11, 2025 · 2705 views
    This topic created in 448 days ago, the information mentioned may be changed or developed.

    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 replies    2025-02-14 09:40:31 +08:00
    linqiu919
        1
    linqiu919  
       Feb 13, 2025 via iPhone
    可以,解决一大难题。
    wryyyyyyyyyyyy
        2
    wryyyyyyyyyyyy  
       Feb 14, 2025
    每次复制好麻烦,为什么不放在 .cursorrules 中呢?
    websong188
        3
    websong188  
    OP
       Feb 14, 2025
    @wryyyyyyyyyyyy 当然可以!
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3326 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 11:33 · PVG 19:33 · LAX 04:33 · JFK 07:33
    ♥ Do have faith in what you're doing.