Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ENH: add LaTeX math mode with parentheses #51903
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
ENH: add LaTeX math mode with parentheses #51903
Changes from 5 commits
ba72f26
0801f6a
2320fb3
c20e795
2e283a7
29e357c
849bf36
9be5c22
7b4b53a
25e6b1f
ed27582
3daf4d5
78dcdf8
c06695e
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this code.
You are replacing the string
\$
with a uuid string, first.Then, you are searching for a pattern (
r"\$.*?\$"
) that cannot exist, since it was replaced.Then in line 2490 you are replacing the same string
s
again with the same uuid, but this is unnecessary since it has already done this in line 2481.I think your tests pass and this does the correct thing but I think some of these lines are redundant and do nothing for the overall effect??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the comment.
It’s right, the replacement in line 2490 has a mistake. The right one would be the reverse replacement:
s.replace(r"rt8§=§7wz", r"\$")
I can explain what I am trying to do. When I checked the function
_escape_latex_math
I noticed that for a string like r"$&%#^$" which contains only one sign "$" and only one combination "\$" I got a wrong result, because the function processed this string in math mode. By doing the replacement in line 2481 I exclude from the consideration the string “\$” to avoid confusing it with “$”. Then I get the correct result and do the reverse replacement. If we don’t have a combination of one sign "$" and one sign "\$" we don’t need to do this check, but I prefer to leave it.I corrected my mistake a made a new commit. I also added an example for this case in the test.