gighen976 / google-code-prettify

Automatically exported from code.google.com/p/google-code-prettify
Apache License 2.0
0 stars 0 forks source link

Issue with matlab code not distinguishing between single quoted strings and matrix transpose operation #346

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Run the following code
<!DOCTYPE html>

<html lang="en">
<head>
   <meta charset="utf&mdash;8">
   <title>untitled</title>
   <link rel="stylesheet" href="prettify.css" />
</head>
<body>

<pre class="prettyprint linenums">
A = [1; 0; 0]
B = [1 0 0]
C = B' + A
</pre>

<script src="prettify.js"></script>
<script>prettyPrint();</script>
</body>
</html>
(Please include HTML, not just your source code)

What is the expected output?  What do you see instead?
' +A; is highlighted in green. I take it that it is assuming this whole part as 
a string cause of the single quoted literal

What version are you using?  On what browser?

The latest prettify on the latest chrome
Please provide any additional information below.

Original issue reported on code.google.com by ganeshad...@gmail.com on 28 Jun 2014 at 12:28

GoogleCodeExporter commented 8 years ago
I think that when the single quote (') is right next to a variable, prettify 
shouldn't recognize it as a opening string quote.

Original comment by ganeshad...@gmail.com on 28 Jun 2014 at 12:36

GoogleCodeExporter commented 8 years ago
See this attachment below

Original comment by ganeshad...@gmail.com on 28 Jun 2014 at 4:38

Attachments:

GoogleCodeExporter commented 8 years ago
Two things:

- first, you need to specify a language hint for MATLAB in the PRE tag:

  <pre class="prettyprint lang-matlab">...</pre>

- second, you need to include the corresponding javascript file to get the 
special MATLAB language handler:

  <script src="prettify.js"></script>
  <script src="lang-matlab.js"></script>

Once you fix those, single quotes are correctly recognized according to the 
context (either matrix transpose or a quoted string)

Original comment by amroamro...@gmail.com on 8 Jul 2014 at 9:07

GoogleCodeExporter commented 8 years ago
Shouldn't the project be detecting the language automatically ?

Original comment by ganeshad...@gmail.com on 8 Jul 2014 at 7:45

GoogleCodeExporter commented 8 years ago
I am only having issues with matlab and for this I have to manually include 
lang-matlab.js other languages are doing fine. 

Original comment by ganeshad...@gmail.com on 8 Jul 2014 at 7:49

GoogleCodeExporter commented 8 years ago
Only for languages included in the core script. Additional languages (like 
MATLAB) are supported as extensions, and must be explicitly enabled.

http://google-code-prettify.googlecode.com/svn/trunk/README.html#langs

Original comment by amroamro...@gmail.com on 8 Jul 2014 at 8:09

GoogleCodeExporter commented 8 years ago
I can spend a couple of weekends on this. Is there someway I can help make 
Matlab a standard supported language for you guys ? I can help with VB CSS too 
if I get enough time.

Original comment by ganeshad...@gmail.com on 8 Jul 2014 at 9:06

GoogleCodeExporter commented 8 years ago
I'm sure contributions are always appreciated, but I'm not the project owner. I 
just contributed lang-matlab.js (as an extension), and help maintain it when 
needed :)

Original comment by amroamro...@gmail.com on 9 Jul 2014 at 6:44

GoogleCodeExporter commented 8 years ago
I will put a email to the guy who owns it, "soon" see if he would like an extra 
helping hand.

BTW, great extension man, now that I figured it out how to use it !

Original comment by ganeshad...@gmail.com on 9 Jul 2014 at 9:26