简单的 prettyprint 程序不工作

Simple prettyprint program not working

我正在尝试使用 prettyprint 来格式化我代码的 UI,但我没有完成任何格式化。

HTML:

<html>
<head>
<link href="https://cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.css" rel="stylesheet">
<script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js"></script>
</head>
<body onload="prettyPrint()">   
<pre class="prettyprint">   
  &lt;div&gt; This is a div &lt;/div&gt;   
  &lt;a href="http://www.google.com"&gt;Bollywood &lt;/a &gt;   
</pre>  
</body>
</html>

参考文献:

  1. https://github.com/google/code-prettify
  2. https://github.com/google/code-prettify/blob/master/docs/getting_started.md
  3. https://rawgit.com/google/code-prettify/master/styles/index.html

有人可以帮帮我吗?

I want the default layout in the 3rd link provided. 

试试这个:

<html>
<head>
  <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.css">
  <style type="text/css"></style><link rel="stylesheet" type="text/css" href="https://cdn.rawgit.com/google/code-prettify/master/loader/prettify.css">
</head>
<body>

  <pre class="prettyprint linenums">
    &lt;div&gt; This is a div &lt;/div&gt;   
    &lt;a href="http://www.google.com"&gt;Bollywood &lt;/a &gt;   
  </pre>

</body>
</html>

在线演示可用here

所需的主题必须包含在 css 文件中(例如,this css file)。

您的link代码无效。

https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js 使用这个:

https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js