Fix LaTeX dollars — ChatGPT & Claude.ai prompt: escape $ in Markdown
This prompt sorts every $ in Markdown into currency, math or shell code and escapes only the currency ones. Useful when your build throws warnings.
Open on GitHubWhat Fix LaTeX dollars does
The prompt splits every $ into three classes. Currency — $1, $2 billion, R$ 549 — is what triggers the warnings, so those get escaped. Real math such as $\rightarrow$ and $O(1)\text{ streaming}$ stays untouched. Shell code like $(curl…), ${ZSH_CUSTOM} and $HOME sits inside code blocks and is left alone too.
It runs in four steps. First the agent greps the content, classifies each $ and reports counts before changing anything. Then it checks the tree is clean, writes and runs a tested Python script that is aware of code fences, inline code, frontmatter and math spans; a (?<!\\) lookbehind makes it idempotent, so re-running never double-escapes. Step three is the safety net: greps for real math and shell variables must print nothing, and if anything legitimate was touched the prompt tells you to run git checkout -- . and stop. Finally it prints the build-verify and commit commands for you to run.
That last part matters. The prompt deliberately does not run builds, commits or pushes on its own, so the final move is yours.
What it helps with
- clear build warnings caused by currency $ in Markdown
- escape currency without touching LaTeX formulas
- keep shell variables inside code blocks intact
- re-run the script without double-escaping
- roll back when a legitimate $ gets hit
Example prompts for the agent
- Investigate every $ in docs/ and report counts per class without changing anything
- Escape the currency $ in README.md and show me the diff
- Run the verification: grep real math and shell vars, and roll back if anything was touched
How to install Fix LaTeX dollars
How to use
Paste the text at the start of a chat or into project instructions
Manually: put the files in place
.claude/commands/prompts.csv.mdQuestions about Fix LaTeX dollars
How do I install Fix LaTeX dollars in Claude?
There is no install command: paste the prompt into the chat and describe your files.
What does Fix LaTeX dollars do?
It classifies every $ in Markdown as currency, math or shell code, escapes only the currency ones, and verifies the diff for touched formulas and variables.
Does the prompt commit and push by itself?
No. It prints the build and commit commands, and you run them.
Source text
prompts.csv · CC0-1.0
Investigate and fix the actual $ usages in Markdown content.
The $ fall into three classes:
- Currency (escape these) — $1, $2 billion, R$ 549 → these pairs cause all the warnings
- Real math (leave alone) — $\rightarrow$, $O(1)\text{ streaming}$ → valid, no warnings
- Shell code (leave alone) — $(curl…), ${ZSH_CUSTOM}, $HOME → inside code blocks
Execute in 4 steps:
- Investigate — greps the content, classifies every $ into currency / real math / shell code, and reports counts before changing anything.
- Apply — checks the tree is clean, then writes and runs the exact tested Python script (code-fence-, inline-code-, frontmatter-, and math-span-aware; idempotent via the (?<!\\) lookbehind so re-running never double-escapes).
- Verify the diff — the safety net: greps that must print nothing for real math ($\rightarrow$, \text) and shell vars ($HOME, $(…), ${VAR}). If anything legit was touched, it tells you to git checkout -- . and stops.
- Print instructions — outputs the build-verify and commit/push commands for user to run.
Do not autonomously run any build, commit, or push.
© [email protected] · CC0-1.0 · f/prompts.chat