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

Escape underscores #208

Merged
merged 5 commits into from
Feb 13, 2025
Merged

Escape underscores #208

merged 5 commits into from
Feb 13, 2025

Conversation

bjude
Copy link
Contributor

@bjude bjude commented May 13, 2024

Overview

Add the option to not escape underscores in IdentifierConverter

Details

This allows for generating symbols with subscripts (possibly multiple layers), e.g. x_2_i becomes x_{2_{i}}. This is done by splitting the identifier on underscores, converting each 'sub-identifier' as normal, then concatenating the converted identifiers back together, separated by underscores. There is some simple logic in the concatenation to wrap the subscripts in braces to accommodate multiple layers of subscripts.

This option also creates the possibility of generating invalid latex if the identifier starts or ends with an underscore, or has a double underscore in it. In these cases we now raise a ValueError. Tests have been added exercising the new functionality, including the error path.

bjude added 2 commits May 13, 2024 09:36
This allows for generating symbols with subscripts (possibly multiple layers), e.g. `x_2_i` becomes `x_{2_{i}}`. This option also creates the possibility of generating invalid latex if the identifier starts or ends with an underscore, or has a double underscore in it. In these cases we now raise a ValueError.
@bjude bjude requested a review from odashi as a code owner May 13, 2024 01:39
@subsurfaceiodev
Copy link

This feature would be awesome

Previously generated latex was incorrect for multi-character subscripts.
Tests updated to reflect new (correct) behaviour.
@bjude bjude force-pushed the escape_underscores branch from 6604d2f to 625444f Compare February 5, 2025 01:40
@bjude bjude requested a review from odashi February 6, 2025 02:16
Copy link
Collaborator

@odashi odashi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@odashi
Copy link
Collaborator

odashi commented Feb 10, 2025

@bjude I would merge this PR after all CIs passed.

@odashi odashi merged commit 54dc869 into google:main Feb 13, 2025
10 checks passed
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.

3 participants