Skip to content

Fix incorrect removal of braces in template macros #1278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 20, 2025
Merged

Conversation

dpvc
Copy link
Member

@dpvc dpvc commented Jun 18, 2025

This PR fixes a problem with parsing the arguments of a macro with template where braces could be removed incorrectly. For example, with \def\text#1\stop{#1}, if used with \text{a}{b}\stop, you currently will get an error about missing open braces. That is because the parameter #1 will end up containing a}{b rather than {a}{b} as expected.

The solution is to set hasBraces to false when a second braced argument is used. I also changed hasBraces to a boolean rather than a number.

Two new tests are added to check for this issue. There should probably be some more tests for when hasBraces gets unset, for completeness.

@dpvc dpvc requested a review from zorkow June 18, 2025 15:23
@dpvc dpvc added this to the v4.0 milestone Jun 18, 2025
Copy link

codecov bot commented Jun 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.68%. Comparing base (351698e) to head (37d7c41).
Report is 4 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1278      +/-   ##
===========================================
- Coverage    86.68%   86.68%   -0.01%     
===========================================
  Files          337      337              
  Lines        84105    84102       -3     
  Branches      4750     3125    -1625     
===========================================
- Hits         72909    72906       -3     
- Misses       11173    11196      +23     
+ Partials        23        0      -23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@zorkow zorkow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.

@dpvc dpvc merged commit 131b5cf into develop Jun 20, 2025
3 checks passed
@dpvc dpvc deleted the fix/template-macros branch June 20, 2025 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants