我正在尝试使用 Google prettify 突出显示一些语法,但到目前为止,它不起作用。
<link href="prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="prettify.js"></script>
<body onload="prettyPrint()" bgcolor="white">
<pre class="prettyprint">
<code class="language-css">
// Some source code
class Foo {
public int Bar { get; set; }
}
</code>
</pre>
有没有一种解决方案可以使这项工作在不与 Bootstrap 中已经存在的 pre 标签混淆太多的情况下进行?
最佳答案
编辑:对于 twitter bootstrap 2.0.x,它适用于 2.1.x
使用这两个文件而不是使用文档中描述的方法。
http://twitter.github.com/bootstrap/assets/js/google-code-prettify/prettify.css
http://twitter.github.com/bootstrap/assets/js/google-code-prettify/prettify.js
这对我有用
<!DOCTYPE html>
<html lang="en">
<head>
<link href="css/bootstrap.css" type="text/css" rel="stylesheet" />
<link href="prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="prettify.js"></script>
</head>
<body onload="prettyPrint()" bgcolor="white">
<pre class="prettyprint linenums languague-css">
// Some source code
class Foo {
public int Bar { get; set; }
}
</pre>
</body>
</html>
关于twitter-bootstrap - twitter bootstrap 上的语法高亮显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10862021/