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

Matlab comment symbol "%" does not work when it's at the beginning of a line #340

Open
yalewoo opened this Issue Apr 2, 2016 · 5 comments

Comments

Projects
None yet
3 participants
@yalewoo

yalewoo commented Apr 2, 2016

Matlab comment symbol "%" does not work when it's at the beginning of a line
Here is the test page
It recognize the first "%" of the line as a TAG, and a blank line is added after that.

Matlab use single quotation marks to do the matrix transposition, but it is always recognized as string.

@tweh

This comment has been minimized.

Show comment
Hide comment
@tweh

tweh Apr 23, 2016

👍

Same for TeX

tweh commented Apr 23, 2016

👍

Same for TeX

@cminto

This comment has been minimized.

Show comment
Hide comment
@cminto

cminto May 22, 2016

Confirming the same issues as yalewoo on this page.

  1. % causes blank line to be added.
  2. ' recognized as string rather than transpose operator.

Line 31 has:
A = [-sum(k1) k2;k1(2:n+1)' -diag(k2)];
The single quote is the transpose operator and Crayon makes everything that follows green (comment) and reverts back to code after the next single quote several lines down the page.
I can see that the solution has to the correct regex in this line
STRING (?default)
in this file:
crayon-syntax-highlighter/langs/matlab/matlab.txt
Can anyone offer the correct regex for this rule:

A single quotation character is a tranpose operator if it follows:
right bracket ("]"),
right parenthesis (")"),
right brace ("}"),
letter,
digit,
underline ("_"),
punctuation mark ("."),
or another single quote character ("'").
If the single quotation character follows anything else then it starts a string.
Hope that helps.

cminto commented May 22, 2016

Confirming the same issues as yalewoo on this page.

  1. % causes blank line to be added.
  2. ' recognized as string rather than transpose operator.

Line 31 has:
A = [-sum(k1) k2;k1(2:n+1)' -diag(k2)];
The single quote is the transpose operator and Crayon makes everything that follows green (comment) and reverts back to code after the next single quote several lines down the page.
I can see that the solution has to the correct regex in this line
STRING (?default)
in this file:
crayon-syntax-highlighter/langs/matlab/matlab.txt
Can anyone offer the correct regex for this rule:

A single quotation character is a tranpose operator if it follows:
right bracket ("]"),
right parenthesis (")"),
right brace ("}"),
letter,
digit,
underline ("_"),
punctuation mark ("."),
or another single quote character ("'").
If the single quotation character follows anything else then it starts a string.
Hope that helps.

@cminto

This comment has been minimized.

Show comment
Hide comment
@cminto

cminto May 25, 2016

Jeff Mandel has changed line 31 of the page link given in the previous post from:
A = [-sum(k1) k2;k1(2:n+1)' -diag(k2)];
to:
A = [-sum(k1) k2;transpose(k1(2:n+1))-diag(k2)];
which is a simple work around - the regex works fine for transpose(x) but not for x' (where everything to the right of the x' gets treated as a string up until the next '

cminto commented May 25, 2016

Jeff Mandel has changed line 31 of the page link given in the previous post from:
A = [-sum(k1) k2;k1(2:n+1)' -diag(k2)];
to:
A = [-sum(k1) k2;transpose(k1(2:n+1))-diag(k2)];
which is a simple work around - the regex works fine for transpose(x) but not for x' (where everything to the right of the x' gets treated as a string up until the next '

@cminto

This comment has been minimized.

Show comment
Hide comment
@cminto

cminto May 25, 2016

The regex for comment in crayon-syntax-highlighter/langs/matlab/matlab.txt is:
COMMENT (%.*?$)
This should pick up comments with % at the beginning of the line as well as later in the line, but it doesn't (so far I'm unsuccessful in finding the reason)

cminto commented May 25, 2016

The regex for comment in crayon-syntax-highlighter/langs/matlab/matlab.txt is:
COMMENT (%.*?$)
This should pick up comments with % at the beginning of the line as well as later in the line, but it doesn't (so far I'm unsuccessful in finding the reason)

@cminto

This comment has been minimized.

Show comment
Hide comment
@cminto

cminto May 25, 2016

Point 1 was posted earlier here:
#145
The second point above can be worked around with the transpose( ) function.

cminto commented May 25, 2016

Point 1 was posted earlier here:
#145
The second point above can be worked around with the transpose( ) function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment