Repository navigation
🐛 fix(latex): keep digit-led inline formulas out of the currency escape - #10
Open
alaasumrain wants to merge 1 commit into
Open
alaasumrain wants to merge 1 commit into
alaasumrain wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
escapeCurrencyDollarsreads any$followed by a digit as a price, unless the whole span is a bare integer ($1$) or a comma list ($1,2,3$). So inline formulas that happen to start with a digit lose their opening$and render as raw text, and the leftover$then pairs with the next one in the line:so $2n$ is evenso \$2n$ is eventhen $3x+1$ growsthen \$3x+1$ growshalf is $0.5$ herehalf is \$0.5$ herestep $10 + 7 = 17$ donestep \$10 + 7 = 17$ doneThis is common in worked maths answers (coefficients, decimals, arithmetic steps).
Fix
One more protection pass before the currency escape. A
$…$span whose body starts with a digit is kept as math when:$, sopay $5 and $10still reads as two prices, and\ ^ _ { }), is a decimal, puts an operator between two numbers, or lists numbers.Plain amounts (
$20,$1,000,$19.99,$20-$50) are escaped exactly as before.Tests
Two cases in
src/latex.test.ts: digit-led formulas stay math, and two prices in one line are still escaped. The latex tests pass (145), and the new case fails without the change.🤖 Generated with Claude Code