google-code-prettify对matlab代码不起作用

时间:2013-04-15 21:20:48

标签: matlab google-code-prettify

我正在使用google-code-prettify软件包突出显示我的matlab代码,但突出显示不像matlab风格的着色。我最小的工作范例:

<!DOCTYPE html>
<html>
<head>
   <link href="prettify/prettify.css" type="text/css" rel="stylesheet" />
   <script src="prettify/prettify.js" type="text/javascript"></script>
   <script src="prettify/run_prettify.js" type="text/javascript"></script>
</head>
<body>
      <pre class="prettyprint lang-matlab">
      <code>
      i=1;
      if i==2
         i=1;
      end
      while(1)
         a=5;
      end
      %test comment
      </code>
      </pre>
</body>
</html>

在上面的示例中,例如,%test comment未以绿色突出显示,但有些行会突出显示,例如while循环。我做错了吗?

2 个答案:

答案 0 :(得分:1)

使用prettify.js时,您不需要prettify.cssrun_prettify.js。只需将?lang=matlab添加到run_prettify.js网址,它就会加载您需要的所有JS和CSS。

http://code.google.com/p/google-code-prettify/wiki/GettingStarted

  

你可以加载JavaScript吗?和CSS通过一个URL进行美化

     

...

     

例如

<script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js?lang=css&skin=sunburst"></script>
     

指定lang参数以加载CSS语言扩展名和skin参数以加载 sunburst 皮肤。

所以你的<head>应该是

<head>
   <script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js?lang=matlab" type="text/javascript"></script>
</head>

答案 1 :(得分:0)

您需要包含matlab语言处理程序:

<script src="https://google-code-prettify.googlecode.com/svn/trunk/src/lang-matlab.js"></script>
相关问题