2012-09-20 84 views
2

我似乎無法找到什麼是錯的。我有這個HTML文件用於谷歌美化。無論prettify.css和prettify.js都在同一目錄中的HTML文件谷歌美化不顯示顏色

<html> 
<head> 
<script src="prettify.js"></script> 
<link rel=StyleSheet href="prettify.css" type="text/css"> 
</head> 

<body> 
<pre class="prettyprint"> 
//Some sample text 
for(int i = 0; i<10; i++){ 
    //Do something 
} 
</pre> 
</body> 
</html> 

而這正是它看起來像

screenshot

我缺少的是有顯示的顏色?

感謝

回答

4

添加onload="prettyPrint()"到您的文檔的body標籤。

<body onload="prettyPrint()"> 
0

下面的代碼,將做適當的語法高亮

<html> 
<head> 
<!--<script src="prettify.js"></script>I commented out your links--> 
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script> 
<!--<link rel=StyleSheet href="prettify.css" type="text/css"> I commented out your links--> 
</head> 

<body> 
<pre class="prettyprint"> 
    //Some sample text 
    for(int i = 0; i<10; i++){ 
    //Do something 
    } 
</pre> 
</body> 
</html> 

See the code live here