我使用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-loop。我做错了什么吗?
发布于 2013-04-17 10:05:03
在使用run_prettify.js时,您不需要同时使用prettify.js或prettify.css。只需将?lang=matlab添加到CSS,它将加载您需要的所有JS和run_prettify.js。
http://code.google.com/p/google-code-prettify/wiki/GettingStarted说
你可以加载JavaScript吗?和CSS,通过一个URL进行美化
..。
例如,指定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>发布于 2013-04-16 05:26:26
您需要包含matlab语言处理程序:
<script src="https://google-code-prettify.googlecode.com/svn/trunk/src/lang-matlab.js"></script>https://stackoverflow.com/questions/16024890
复制相似问题