-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Mistetected Octave/Matlab code snippet #1747
Comments
We don't tend to score comments higher than other things, so assuming they are counted (they seem to be) then %% just gets equal points to %. The problem is the rest of this code doesn't look that different than many other languages...
Because Not sure there is anything to be done here unless we wanted to boost the relevancy of %% a bit, but that isn't going to help in larger samples of code there the ratio of %% to code is small and the code still looks pretty generic. |
@MayeulC Ruby's ERB also uses %%. What are the rules for %% in matlab? Does it alway have to start on a newline? |
@yyyc514 There aren't that many. Basically, in Matlab, those serve as section delimiters. I would like to take a bit of what I said. Although it is encountered quite often in Matlab code, it is not necessarily a giveaway. And I do get your point, as the ratio of Matlab has a lot of builtins, since everything is imported in the scope by default, and you can shadow functions. Here,
I had a further look at the matching script. Would it help to know the generic function syntax for matlab? It's (< > denotes optional parts), I saw that the script doesn't try to find
this is what the xdg mime database uses for detection (of course, the rules there are very simple). GNU Octave can be considered a dialect, with a few modifications, among which:
|
Not sure you answered this. This would be one easy way to perhaps increase the relevancy of Matlab a bit over other things as this would be a rather unusual thing I think. Auto-detection is something I'm very curious about and a tough problem. Especially given that many of our parsers are intended to be "simple" rather than complete. Allowing us to detect/color a LOT of languages without having a huge size.
Not sure this helps that much... From 10 miles high it looks a lot like expressions in other languages with < ( identifiers, etc... |
Long-term I'd like to see us get to a place (with tools, metrics, tests) where someone interested in this (improving detection for Matlab say) could get involved and play around and see if anything "sticks" and if they can improve the detection in "meaningful ways"... Right now it's kind of hard/tricky to do that... |
@MayeulC If you'd like to submit a PR that bumps the relevancy of %% when it starts a new line by just a little and that doesn't break the brittle balance fo auto-detect that might be useful here. But first you might want to start by seeing how far apart you currently even are between matching Matlab and whatever else it's matching. You have loaded the matlab grammar JS file - or bundled it, yes? I realize your initial message says "code doesn't appear to have syntax highlighting" rather than that it was highlighted incorrectly. Otherwise not sure how we can improve this much. Your code sample is just hard to identify without more context. (as all small code samples often are) |
Closing as resolved/answered. |
Hi,
This code doesn't appear to have syntax highlighting, as far as I know (as it appears on my gitea install with v9.11.0, at least), yet it is a valid Octave script:
The leading
%%
should give it away (Though TeX might be a contender). The end/endFunction is optional, and omitted here. It also appears that functions that do not have leading comments are more easily misdetected.The text was updated successfully, but these errors were encountered: