Triple Backticks: Code & Raw Text Isolation

The '```' delimiter is ideal for clearly marking code blocks or literal text segments, instructing the LLM to treat the enclosed content as programming syntax or raw data, improving accuracy in code generation and text processing tasks.

The top 3

  1. Triple Backticks: Markdown's Modern Code Block Standard: Originating in GitHub Flavored Markdown around 2011, triple backticks (fenced code blocks) largely replaced the older four-space indentation method, offering superior readability, syntax highlighting, and cleaner handling of multi-line code and nested structures.
  2. LLM Prompt Security: Triple Backticks vs. Other Delimiters: For Large Language Models, triple backticks are a robust delimiter for isolating user input, code, or data from instructions, significantly reducing prompt injection risks compared to less explicit methods like single quotes, dashes, or simple text delimiters.
  3. Advanced Use: Triple Backticks for Syntax & Nested Content: Effective use involves adding language identifiers (e.g., ```python) for syntax highlighting and, critically, using a greater number of backticks for the fence if the enclosed content itself contains three or more consecutive backticks to prevent parsing errors.

Sources

Open the full topic