twitter-bootstrap - twitter bootstrap 上的语法高亮显示

标签 twitter-bootstrap prettify

我正在尝试使用 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/

相关文章:

javascript - 如何在文本框中添加 "view:source"选项?

python - 在 Python 中生成漂亮的 diff html

c# - 给定内部网站上的 .SQL 文件,有哪些选项可以动态进行漂亮的格式化?

css - 用于在 tumblr 上显示代码片段的水平滚动区域

javascript - 弹出窗口 Bootstrap 中的工具提示

twitter-bootstrap - Bootstrap 弹出窗口,图像作为内容

javascript - 使用 Google Prettify 显示 HTML

jquery - Twitter Bootstrap 弹出内容中的要点

javascript - 如何用汉堡包按钮替换固定顶部导航?

css - xs 时居中 div,否则右对齐