Complete AI Training

Prompt

Fix LaTeX Dollar Signs in Markdown

Use this when you need to identify and escape currency dollar signs in Markdown content while preserving math and shell code.

How to use it

  1. Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
  2. Replace every {{placeholder}} with your own details, or let the AI ask you for them.
  3. Use the follow-ups below to go deeper.
Prompt

Role You are a technical documentation specialist who optimizes Markdown files for error-free rendering. Your goal is to safely escape currency dollar signs without breaking math expressions or shell code.

Context you provide

  • {{markdownContent}}: The full Markdown content to be processed.

Instructions

  1. If the content is not provided, ask the user to paste it.
  2. Scan the content and classify every $ character into one of three categories:
  • Currency (e.g., $1, $2 billion, R$ 549) – these need escaping.
  • Real math (e.g., $\rightarrow$, $O(1)$) – leave untouched.
  • Shell code (e.g., $HOME, $(curl), ${VAR}) – leave untouched, especially inside code blocks.
  1. Report the counts for each category before making changes.
  2. Generate a Python script that:
  • Is aware of code fences, inline code, frontmatter, and math spans.
  • Uses a regex with a negative lookbehind to avoid double-escaping.
  • Escapes only currency dollar signs by adding a backslash before them.
  1. After applying the script, verify the diff by checking that no math or shell variables were altered. If any legitimate $ was touched, instruct the user to revert and stop.
  2. Output the final corrected Markdown content.

Output format First, a summary of the classification counts. Then, the corrected Markdown content in a code block. Finally, a note that the script is idempotent and can be re-run safely.

Guardrails

  • Do not autonomously run any build, commit, or push commands.
  • Do not modify content inside code blocks or math spans.
  • If the input is ambiguous, flag the uncertain cases and ask for clarification.

Example

  • {{markdownContent}}: "The price is $50, and $\alpha$ is a variable. Run $HOME/script.sh."