Copy-Paste Template: Complete Prompt Solution
Here is the ultimate prompt template designed to prevent layout collapse. Copy and paste this directly when asking AI to output code, markdown, or meta-prompts.
Please generate text according to the instructions and format specified below.
[STRICT OUTPUT RULES]
- Output the ENTIRE response inside an indented code block by adding 4 spaces at the beginning of every line.
- NEVER use backtick characters (“`) for code blocks anywhere in the output.
- Express all internal structural blocks or code snippets using 4-space indentation (or additional nesting) instead of backticks.
- To maintain a single contiguous block, ensure that even blank lines contain 4 leading spaces.
[OUTPUT FORMAT]
(Insert your requested format or instructions here)
Why Do LLM Code Block Outputs Break?
When instructing AI to output programming code or another raw prompt, you may notice the formatting breaks halfway through or leaks outside the container box.
The root cause of this issue is backtick (`) collision when nesting Markdown code blocks.
1. Common Failure Scenario
By default, AI wraps code or text using three backticks (“`):
Markdown
Your code goes here
However, if the output content itself contains code blocks or Markdown instructions, a nested structure occurs:
Markdown
Outer Block (```)
└ Inner Code Block (```)
└ Inner Block End (```) ← The parser mistakenly assumes the entire block ended here!
Outer Block End (```) ← Overflowing raw text breaks the page layout
Because the inner and outer backticks conflict, the Markdown renderer (and the AI model itself) fails to determine where the container truly starts and ends.
2. Understanding Backticks (`)
A backtick is a character used in Markdown syntax. Single backticks create inline code, while triple backticks create a code block. While powerful, they inherently struggle with nested representations.
The Solution: 4-Space Indentation Blocks
To completely bypass backtick collision, leverage Markdown’s alternative syntax: Indented Code Blocks.
Under Markdown specifications, adding 4 spaces (or 1 tab) at the start of a line automatically formats that line as a code block without needing any backticks.
Key Benefits of Indented Code Blocks
- Zero Syntax Collision: No matter how many backticks exist inside your code or prompts, they will never break the outer container.
- Ideal for Meta-Prompts: Perfect for generating structured prompts or templates that users need to copy cleanly.
Crucial Prompting Tips
When requesting indented code blocks from an AI, always enforce two key rules:
- Strictly Ban Backticks: Explicitly command the model not to use triple backticks anywhere in the generation.
- Handle Blank Lines: Models often drop leading spaces on empty lines, splitting the block into pieces. Always specify: “Ensure that even blank lines contain 4 leading spaces.”
Apply this technique to ensure rock-solid formatting across all your AI workflows!
![[SOLVED] How to Fix Nested Code Block Glitches in LLM Outputs](https://koyukaisa.work/wp-content/uploads/kuzuretyattaaikaitoublock-1200x670.png)
