Skip to content
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

Allow recipes to set previous operation #292

Merged
merged 2 commits into from
Jun 10, 2024

Conversation

gustaphe
Copy link
Collaborator

@gustaphe gustaphe commented May 26, 2024

Previously, recipes had no way of affecting the previous operation. With this (somewhat ugly) change, a type that fundamentally represents for instance a multiplication or sum can tell latexify, so that things like parentheses work out right.

Part of fixing #280

TODO

  • Documentation
  • Maybe more tests

Copy link

codecov bot commented May 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.81%. Comparing base (6af2a54) to head (1577e93).
Report is 2 commits behind head on master.

Current head 1577e93 differs from pull request most recent head ce2cc6e

Please upload reports for the commit ce2cc6e to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #292      +/-   ##
==========================================
- Coverage   81.78%   77.81%   -3.97%     
==========================================
  Files          21       21              
  Lines         818      834      +16     
==========================================
- Hits          669      649      -20     
- Misses        149      185      +36     

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

@gustaphe
Copy link
Collaborator Author

Without this,

julia> struct SimpleLength
x
end

julia> @latexrecipe function f(x::SimpleLength)
return Expr(:latexifymerge, x.x, "\\;\\mathrm{m}")
end

julia> @latexify $(SimpleLength(3))^2
$$3\;\mathrm{m}^2$$

With this

julia> @latexrecipe function f(x::SimpleLength)
operation := :*
return Expr(:latexifymerge, x.x, "\\;\\mathrm{m}")
end

julia> @latexify $(SimpleLength(3))^2
$$\left( 3\;\mathrm{m} \right)^{2}$$

@gustaphe gustaphe merged commit edeebfb into korsbo:master Jun 10, 2024
9 checks passed
@gustaphe gustaphe deleted the operation_arg branch June 10, 2024 08:04
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.

1 participant