-
Notifications
You must be signed in to change notification settings - Fork 791
Improve Objective-C vs Mathematica lexer disambiguation #2103
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
Improve Objective-C vs Mathematica lexer disambiguation #2103
Conversation
fix: improve Objective-C vs Mathematica disambiguation for .m files The previous logic would incorrectly identify Objective-C code as Mathematica when encountering pointer dereference syntax like `if (*foo == 0)`, since it looked similar to Mathematica's comment syntax `(* comment *)`. This change improves the disambiguation by: 1. Only matching Mathematica comments that start at beginning of line 2. Adding an additional Objective-C identifier for braces at end of line
|
LGTM! Thanks for the fix! Disambiguation is always a bit of an approximate science - it's nice to see it tuned up a bit. |
|
@jneen Hello! Following up on this PR - are there any other changes needed? thanks! |
|
@tancnle Hello! Apologies for the ping; I noticed you were most active on this repo as of recent. May I ask for some eyes on this PR? It resolves a long-standing issue with Objective-C code that affects highlighting on GitLab.com. Relevant GitLab ticket: https://gitlab.com/gitlab-org/gitlab/-/issues/292672 I believe it's ready to go in current state, but i'm happy to address any feedback you have. Thank you! |
|
Thanks @EthanArbuckle. The change LGTM. |
) * fix: improve Objective-C vs Mathematica disambiguation for .m files fix: improve Objective-C vs Mathematica disambiguation for .m files The previous logic would incorrectly identify Objective-C code as Mathematica when encountering pointer dereference syntax like `if (*foo == 0)`, since it looked similar to Mathematica's comment syntax `(* comment *)`. This change improves the disambiguation by: 1. Only matching Mathematica comments that start at beginning of line 2. Adding an additional Objective-C identifier for braces at end of line * resolve disambiguation conflict, add more test cases
This PR fixes an issue where Rouge would incorrectly identify Objective-C code as Mathematica when encountering pointer dereference syntax in .m files.
Problem
The current lexer disambiguation logic for .m files checks for
(*to identify Mathematica files. However, this pattern also appears in valid Objective-C code when using pointer dereference syntax, like:This causes Rouge to incorrectly identify such files as Mathematica, leading to incorrect syntax highlighting.
Solution
The fix improves the disambiguation logic by:
Related Issues