amroamroamro / prettify-matlab Goto Github PK
View Code? Open in Web Editor NEWMATLAB syntax highlighting for google-code-prettify
License: MIT License
MATLAB syntax highlighting for google-code-prettify
License: MIT License
This issue concerns the formatting of double-quoted strings, added in R2016b.
This sort of formatting works on GitHub, but not in e.g. SO:
chr = 'this is a char array';
str = "this is a string";
vs.
[EDIT]
Based on the existing example, this code should do the trick (credit: @crisluengo[1]):
// single- or double-quoted strings: allow for escaping with '', no multilines
[PR.PR_STRING, /^('(?:[^']|'')*')|("(?:[^"]|"")*")/, null]
or perhaps this:
// single-quoted strings: allow for escaping with '', no multilines
[PR.PR_STRING, /^'(?:[^']|'')*'/, null],
// double-quoted strings
[PR.PR_STRING, /^("(?:[^"]|"")*")/, null],
IE (at least up to IE 8) fails if there's a comma after the last item in a list. eg.
var list = [1,2,3,];
These occur on lines 129, 149, and 163 of the output lang-matlab.js; removing them fixes everything for IE.
When using quote as transpose method, it is believed to be a string.
As in your own example:
M = rand(3,3)';
N = rand(5,5)';
https://jsfiddle.net/cpede/xj8o8qan/
-cpede
Sorry to write again, but I'm trying to see if prettify can be used for anything useful.
Is it correct that the lang=matlab
needs to be set as parameter torun_prettify.js
since MATLAB is not part of the default supported languages in prettify ?
If using e.g. c++ I do not need to specifylang=cpp
since this is a default language ?
If using pretttify.js
instead of run_pretttify.js
, I need to link each of the non-default language js files, e.g. lang-matlab.js
?
But if calling just pretttify.js
I also need to call the function prettyPrint();
on my page to get it started ?
Why would you then ever call pretttify.js
and not run_pretttify.js
?
Looking at the sample below, why is vb and c++ rendered differently ?
https://jsfiddle.net/cpede/1gkc7fjw/
Thanks for helping me.
-cpede
It is a common problem in syntax highlight for Matlab/Octave.
If you try this code
x = linspace (0,1,100).';
y = rand (1,100);
plot(x,y);
You see that everything after the apostrophe symbol is interepted as string. One solution is to do apostrophe matching and if there is no match assume it is the transpose operator.
When display
ing 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):
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.