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

Inconsistent colors for array size printout #3

Open
Dev-iL opened this issue May 2, 2016 · 1 comment
Open

Inconsistent colors for array size printout #3

Dev-iL opened this issue May 2, 2016 · 1 comment
Labels

Comments

@Dev-iL
Copy link

Dev-iL commented May 2, 2016

When displaying a struct containing non-scalar arrays, something like the following is printed out:

ans = 

      form: 'pp'
    breaks: [1x40 double]
     coefs: [39x4 double]
    pieces: 39
     order: 4
       dim: 1

This gets highlighted as follows (example in SO):
Highlighting example
Note the x40 and x4. I would either expect everything to be black, or all numbers to be brown and x's to be black.

@amroamroamro
Copy link
Owner

amroamroamro commented May 3, 2016

Actually I think the highlighted output is not wrong here!

You see prettify-matlab is expected to highlight valid MATLAB code, but the snippet you showed is not correct code in itself, rather an output of some function (disp in this case).

Obviously if you attempt to run it in MATLAB prompt you get an error as you'd expect:

>> [1x40 double]
 [1x40 double]
   |
Error: Unexpected MATLAB expression.

Even GitHub highlighting is indicating a syntax error with red (variable names must start with a letter).

So when it sees the expression [1x40 double] it's making a best effort at parsing it as valid code:

<span class="tag">[</span>
<span class="lit">1</span>
<span class="ident">x40</span>
<span class="pln"> </span>
<span class="typ">double</span>
<span class="tag">]</span>

i.e there's a number 1 followed by a token/variable called x40, whitespace and then the double type, all contained in an array definition [..]. I don't see how else the expression could be parsed...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants