Skip to content
This repository has been archived by the owner on Apr 22, 2020. It is now read-only.

matlab source code syntax highlighting #32

Closed
GoogleCodeExporter opened this issue Apr 22, 2015 · 27 comments
Closed

matlab source code syntax highlighting #32

GoogleCodeExporter opened this issue Apr 22, 2015 · 27 comments

Comments

@GoogleCodeExporter
Copy link

Quite important I think. And it is provided by sourceforge.net. Would you
consider adding it?

Original issue reported on code.google.com by Dennis84...@gmail.com on 13 Mar 2008 at 1:56

@GoogleCodeExporter
Copy link
Author

Do you know where I can find a matlab grammar?  A quick search doesn't turn one 
up,
and I don't know enough about it to track down a similar language's grammar 
either.

Original comment by mikesamuel@gmail.com on 23 Apr 2008 at 5:39

@GoogleCodeExporter
Copy link
Author

ViewVC supports matlab with the help from Highlight
(http://www.andre-simon.de/doku/highlight/en/highlight_langs.html). I attached 
the
definition file from Highlight project. Hope this helps.

Original comment by Dennis84...@gmail.com on 24 Apr 2008 at 5:13

Attachments:

@GoogleCodeExporter
Copy link
Author

An additional complication is that Matlab and Objective-C files share the same 
file 
extension (.m).

Original comment by jacobly@google.com on 2 May 2010 at 4:54

@GoogleCodeExporter
Copy link
Author

+1
note that octave uses the same syntax
http://www.gnu.org/software/octave/

some vim/emacs modes for matlab/octave:
http://www.vim.org/scripts/script.php?script_id=1591
http://sunsite.univie.ac.at/textbooks/octave/octave_34.html
http://www.mathworks.com/matlabcentral/fileexchange/104

Original comment by erik.fli...@gmail.com on 28 Jun 2010 at 5:37

@GoogleCodeExporter
Copy link
Author

It looks quite bad now:
http://code.google.com/p/psychtoolbox-test/source/browse/beta/Psychtoolbox/Psych
GLImageProcessing/BitsPlusPlus.m?spec=svn1789&r=1789

There are even more matlab supporting highlighters available. Geshi has one and 
WebSVN:
http://svn.berlios.de/wsvn/osxptb/beta/Psychtoolbox/PsychGLImageProcessing/BitsP
lusPlus.m?view=markup

There are other 

Original comment by towolf on 9 Sep 2010 at 7:07

@GoogleCodeExporter
Copy link
Author

Is anyone still working on this? Can I get involved and help develop this 
highlighting scheme?

Original comment by kolba...@gmail.com on 6 Jul 2011 at 6:12

@GoogleCodeExporter
Copy link
Author

I'm not working on matlab because I don't have a grammar to work on.  People 
keep pointing me at VIM modes and the like but unless those are public domain 
or use the same license as this project, I can't look at them.

Original comment by mikesamuel@gmail.com on 6 Jul 2011 at 7:10

@GoogleCodeExporter
Copy link
Author

Thanks. I'll try to compile a good document or some code for you.

Original comment by kolba...@gmail.com on 6 Jul 2011 at 7:18

@GoogleCodeExporter
Copy link
Author

Hi,

If I understand correctly, the BSD license is compatible with the Apache 
License.
If so, maybe Pygment (written in Python) might be of some use: BSD licensed 
(http://pygments.org/faq/#what-is-it), with a matlab lexer 
(https://bitbucket.org/birkenfeld/pygments-main/src/071002c113cb/pygments/lexers
/math.py#cl-95)

HTH

Original comment by david.a....@gmail.com on 6 Sep 2011 at 4:05

@GoogleCodeExporter
Copy link
Author

Now that Berlios is closing shop, it would be cool if we got Matlab 
highlighting on Google Code. 

I proposed to move over to GC, but this one niggle remains:
http://code.google.com/p/psychtoolbox-test/source/browse/beta/Psychtoolbox/Updat
ePsychtoolbox.m

Original comment by towolf on 4 Oct 2011 at 10:22

@GoogleCodeExporter
Copy link
Author

Sorry I've been unresponsive.  Can you expand on what is wrong with the 
formatting of UpdatePsychtoolbox.m ?  I don't know matlab syntax well enough.  
Is it that % comments aren't recognized as such?

Original comment by mikesamuel@gmail.com on 10 Oct 2011 at 9:39

@GoogleCodeExporter
Copy link
Author

It’s all wrong. I assume that is because Objective C is used (also .m).

I posted links further up to other services who highlight it up correctly.
Basically any highlighter you can find does Matlab/Octave.

Original comment by towolf on 10 Oct 2011 at 10:27

@GoogleCodeExporter
Copy link
Author

We have migrated now: http://psychtoolbox-3.googlecode.com

What kind of help do you need, Mike? Do you want a full patch, or do you want 
to do it yourself and just need hints?

Matlab syntax is not so complicated, it just needs the proper keywords and 
markers. I don't know how many keywords of the standard library you want to 
include.

Original comment by towolf on 2 Nov 2011 at 11:24

@GoogleCodeExporter
Copy link
Author

I am happy to accept a patch, or if you can point me to a lexical grammar I can 
do it.  I don't know quite what to do about file name collisions.  What google 
code chooses to load is up to them, but I can talk to them and maybe they can 
load the matlab version for projects that have a certain tag.

Original comment by mikesamuel@gmail.com on 4 Nov 2011 at 7:08

@GoogleCodeExporter
Copy link
Author

I’m not sure what consitutes a lexical grammar. Is that something you can 
glean from other syntax highlighters or is it a formal definition in a defined 
format?

If I would do it I would just proceed by eye.

Your tag idea is a very sensible one.

Original comment by towolf on 5 Nov 2011 at 1:31

@GoogleCodeExporter
Copy link
Author

here you go- flex and bison files from octave (GPL matlab clone)

http://hg.savannah.gnu.org/hgweb/octave/file/tip/src/lex.ll
http://hg.savannah.gnu.org/hgweb/octave/file/tip/src/oct-parse.yy


Original comment by erik.fli...@gmail.com on 21 Mar 2012 at 7:48

@GoogleCodeExporter
Copy link
Author

gtksourceview's highlighter, also GPL:
http://git.gnome.org/browse/gtksourceview/tree/data/language-specs/matlab.lang

mike, can you let us know if there is any issue as far as licensing or format 
for the examples we've provided?

Original comment by erik.fli...@gmail.com on 27 Mar 2012 at 1:12

@GoogleCodeExporter
Copy link
Author

Yes.  The GPL is incompatible with the Apache 2 license.  If I were to read GPL 
code, translate it into another language and put an Apache 2 license on it, I 
would be violating the license.

Original comment by mikesamuel@gmail.com on 7 Apr 2012 at 9:12

@GoogleCodeExporter
Copy link
Author

what about BSD?  github uses pygments...
starting at line 251:
https://bitbucket.org/birkenfeld/pygments-main/src/5cc94956e233/pygments/lexers/
math.py

Original comment by erik.fli...@gmail.com on 2 Jun 2012 at 9:10

@GoogleCodeExporter
Copy link
Author

IT APPAERS THAT THIS SINTEX, CODE THAT HE WAS WORKING ON NEEDED TO BE (MAPED BY 
CONTEX) first then apply simple equaison addressing as: (A- is  0000.1)-(B IS- 
0000.2) THEN (J becomes 1 up by a point of a fraction     ( ooo1.0 )  (T IS 
001.00 AND SO EACH TEN  THE POINT MOVES UP UNTILL THE BODY IS FINISHED WITH 26 
ALPHFABIT THIS BECOMS A SQ,ROOT OF000.2.6 THIS IS A (CODE SINEING TABEL I HAD 
LEARNED A LONG TIME AGO IN MY  M O S TRAINING AT SIG, CORE I TRAINED AS  A 
MICRO TEC. WE HAD THINGS EVEN THEN, THAT I WONT SPEAK OF TODAY,  THIS LOOKS 
LIKE TO SIMPLAFY JUST BUILD A EQUA, TO APPLY ITS COM, THREDS....DONALD J

Original comment by DONALD.J...@gmail.com on 29 Nov 2012 at 12:15

@GoogleCodeExporter
Copy link
Author

Here is my implementation of MATLAB syntax highlighting for 
google-code-prettify (released under MIT license):
https://github.com/amroamroamro/prettify-matlab

Specifically:
https://github.com/amroamroamro/prettify-matlab/blob/master/js/lang-matlab.js

Original comment by amroamro...@gmail.com on 4 Mar 2013 at 5:21

@GoogleCodeExporter
Copy link
Author

Sweet!!!

Original comment by kolba...@gmail.com on 4 Mar 2013 at 5:25

@GoogleCodeExporter
Copy link
Author

Great.  I see a testcase in 
https://github.com/amroamroamro/prettify-matlab/blob/master/demo/index.html .  
I'll integrate that patch.

Original comment by mikesamuel@gmail.com on 4 Mar 2013 at 6:47

@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

Yes, you can see its failing on some edge cases (nested comments)..

I had modified version in a separate branch that does not try to detect MATLAB 
functions:
https://github.com/amroamroamro/prettify-matlab/blob/no_functions/js/lang-matlab
.js

This is mainly to keep file size to a minimum, as there are more than 1000 
functions in core MATLAB alone:
http://www.mathworks.com/help/matlab/functionlist-alpha.html

Original comment by amroamro...@gmail.com on 4 Mar 2013 at 7:14

@GoogleCodeExporter
Copy link
Author

The version from earlier is now available in release branch 4-Mar-2013, the 
download list, and via the autoloader.  amro^3, would you like contributor 
access so you can maintain lang-matlab.js here?

Original comment by mikesamuel@gmail.com on 4 Mar 2013 at 8:21

  • Changed state: Fixed

@GoogleCodeExporter
Copy link
Author

Great. I'm happy to maintain lang-matlab.js

Original comment by amroamro...@gmail.com on 4 Mar 2013 at 8:34

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

No branches or pull requests

2 participants