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

Closing parenthesis is not recognised in math formula in context block #4433

Open
1 task done
Robotechnic opened this issue Jun 22, 2024 · 3 comments
Open
1 task done
Labels
bug Something isn't working introspection Related to introspection. math Related to math syntax, layout, etc.

Comments

@Robotechnic
Copy link

Description

When a closing parenthesis is in a context block, it isn't detected by lr and appears small when it should be sized.
The bug is simple to reproduce:

#let rule(body) = {body}

#show ")" :rule

$
	(1/2)
$

Gives:
image
as expected but

#let rule(body) = context{body}

#show ")" :rule

$
	(1/2)
$

Gives:
image

And I thing it's a bug because:

#let rule(body) = context{body}

#show "(" :rule

$
	(1/2)
$

Gives:
image

Reproduction URL

No response

Operating system

Linux

Typst version

  • I am using the latest version of Typst
@Robotechnic Robotechnic added the bug Something isn't working label Jun 22, 2024
@Coekjan
Copy link
Contributor

Coekjan commented Jun 23, 2024

I can reproduce this issue on Typst v0.11.x, but cannot reproduce it on main branch. Using git bisect, I found #4212 fixed this issue.

@MDLC01
Copy link
Contributor

MDLC01 commented Jun 23, 2024

I'm still able to reproduce the issue on main, only it happens with the left parenthesis instead of the right one:

#{
  show "(": it => context it
  $ (1 / 2) $
}
#{
  show ")": it => context it
  $ (1 / 2) $
}
#{
  show "(": it => context it
  show ")": it => context it
  $ (1 / 2) $
}

Left parentheses are sized improperly on the first and third equations.
(sorry for the low quality, I think the problem is visible anyway).

For comparison, I get the following result in 0.11.1:
Right parentheses are sized improperly on the second and third equations.

Note that using context without a show rule breaks both parentheses (on both main and 0.11.1):

$ #context "("1 / 2#context ")" $

Both parentheses are scaled improperly.

@Enivex Enivex added math Related to math syntax, layout, etc. introspection Related to introspection. labels Jun 23, 2024
@bluebear94
Copy link
Contributor

Debugging (on main e90c309) indicates that in the cases where ( is replaced with context("("), there is an extra MathFragment::Frame at the start of the lr element’s body containing a tag for the context.

This issue is similar to #3727 in that it’s related to ignorant or invisible elements affecting math layout. It still occurs on #4348, but it should provide the machinery to implement a similar fix for lr elems.

bluebear94 added a commit to bluebear94/typst that referenced this issue Jul 11, 2024
@laurmaedje laurmaedje changed the title closing parenthesis is not recognised in math formula in context block Closing parenthesis is not recognised in math formula in context block Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working introspection Related to introspection. math Related to math syntax, layout, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants