Mistetected Octave/Matlab code snippet
See original GitHub issueHi,
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:
%% function cellarray = removeregexp(cellaray, expression_array)
% Removes matching expressions from cell array strings.
% If a string in the cell array is or becomes empty, it is removed from the cell
% array.
function cellarray = removeregexp(cellarray, expression_array)
cellarray = regexprep(cellarray, expression_array, '');
cellarray(cellfun(@isempty, cellarray)) = [];
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.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
How to determine if my matlab code is running in ... - MathWorks
Look at the title bar I'd guess. Or check the "About" box. What did you click to even run either one? Don't you...
Read more >Generate octave spectrum - MATLAB poctave - MathWorks
This MATLAB function returns the octave spectrum of a signal x sampled at a rate fs. ... If x is a matrix, then...
Read more >MATLAB Snippets - File Exchange - MathWorks
Download and share free MATLAB code, including functions, models, apps, support packages and toolboxes.
Read more >Indent a block of code - MATLAB Answers
How do you indent a block of code? For example if you enclose a block of code in an if statement, and want...
Read more >How to efficiently turn octave code to matlab. - MathWorks
Hi there I'new first time matlab just buy it. But I have lots of octave codes. Pls help me with tips as per...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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.