question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mistetected Octave/Matlab code snippet

See original GitHub issue

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:

%% 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:closed
  • Created 5 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
joshgoebelcommented, Oct 17, 2019

@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)

0reactions
joshgoebelcommented, Oct 17, 2019

Closing as resolved/answered.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found