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

[BUG] Auto-fraction strips parentheses from product of parenthesized terms #206

Closed
glacialcascade opened this issue Oct 2, 2023 · 0 comments · Fixed by #220
Closed

[BUG] Auto-fraction strips parentheses from product of parenthesized terms #206

glacialcascade opened this issue Oct 2, 2023 · 0 comments · Fixed by #220
Labels
bug Something isn't working

Comments

@glacialcascade
Copy link

Description

Making a fraction with auto-fraction and a parenthesized product like (a)(b) in the numerator removes the ( ) on the outside.

To Reproduce

In a math environment, type (n+1)(n+2)/. The auto-fraction produces \frac{n+1)(n+2}{}.

Expected Behavior

It should not remove the parentheses from the outside, leaving \frac{(n+1)(n+2)}{}.

One possible solution would be to check if the regex described here https://stackoverflow.com/questions/546433/regular-expression-to-match-balanced-parentheses has more than one match (indicating that the numerator is a product and not just one term in parentheses). It seems that Obsidian regexes use the JS implementation though, so it might not be possible without scanning the entire string to count ( and ).

@glacialcascade glacialcascade added the bug Something isn't working label Oct 2, 2023
duanwilliam added a commit to duanwilliam/obsidian-latex-suite that referenced this issue Oct 25, 2023
previously, `(a)(b)/` would be erroneously transformed into `\frac{a)(b}{}`,
as algorithm would just check if first and last were open and closed parens.
now, only removes outer parentheses if they are matched.

fixes artisticat1#206
duanwilliam added a commit to duanwilliam/obsidian-latex-suite that referenced this issue Oct 25, 2023
previously, `(a)(b)/` would be erroneously transformed into `\frac{a)(b}{}`,
as algorithm would just check if first and last were open and closed parens.
now, only removes outer parentheses if they are matched.

fixes artisticat1#206
duanwilliam added a commit to duanwilliam/obsidian-latex-suite that referenced this issue Oct 30, 2023
previously, `(a)(b)/` would be erroneously transformed into `\frac{a)(b}{}`,
as algorithm would just check if first and last were open and closed parens.
now, only removes outer parentheses if they are matched.

fixes artisticat1#206
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant