Skip to content

Treat function-looking code in attachment as function#985

Merged
laurmaedje merged 1 commit intotypst:mainfrom
SUPERCILEX:_func
Jun 9, 2023
Merged

Treat function-looking code in attachment as function#985
laurmaedje merged 1 commit intotypst:mainfrom
SUPERCILEX:_func

Conversation

@SUPERCILEX
Copy link
Contributor

Fixes #828

@laurmaedje
Copy link
Member

I think I intentionally didn't do this specifically because of things like a^zeta(x). It's not all all clear to me which should have higher precedence. For fractions it's different because there is no sensible other interpretation.

@SUPERCILEX
Copy link
Contributor Author

Yeah, I considered that too. Here was my rationale:

  • It's how latex works: a^\abs{b}_\sqrt{c}
  • For non-idents (e.g. log_2(x)), we can tell you're not making a function call with certainty, so we should just let your write that.
  • For cases like a^abs(b)_sqrt(c), it is very obvious that the user wanted to call the function, so we should treat it like that.
  • For cases like a^zeta(x), it's unclear what should happen. Thus, my thinking was that we cater towards the obvious cases and let those determine the behavior of this ill defined case. So it will be treated as a function which can easily be circumvented by adding a space if that's not what you meant.

@SUPERCILEX SUPERCILEX marked this pull request as draft May 5, 2023 00:47
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
@SUPERCILEX SUPERCILEX marked this pull request as ready for review June 9, 2023 00:33
@SUPERCILEX
Copy link
Contributor Author

You were right, all it required was changing the math_op precedence!

@laurmaedje laurmaedje merged commit 635ef03 into typst:main Jun 9, 2023
@laurmaedje
Copy link
Member

Thanks!

@user202729
Copy link
Contributor

user202729 commented Jun 9, 2023

Side note but a_\sqrt{b} is an "implementation artifact that happens to work", it's not a supported LaTeX syntax at all, and "tiny unrelated changes" might break it. In fact the only supported syntax is a^{2} instead of a^2, but on trivial detail like this one people are more likely to accept it...

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.

Parsing 2^round(3) as 2^(round(3)) instead of 2^(round)(3)?

3 participants