twitter bootstrap 上的语法高亮 [英] Syntax highlighting on twitter bootstrap

查看:31
本文介绍了twitter bootstrap 上的语法高亮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Google prettify 突出显示一些语法,但到目前为止,它不起作用.

<script type="text/javascript" src="prettify.js"></script><body onload="prettyPrint()" bgcolor="white"><pre class="prettyprint"><code class="language-css">//一些源代码类 Foo {公共 int 栏 { 得到;放;}}

有没有一种解决方案可以使这项工作正常工作,而不会过多地弄乱引导程序中已有的 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

这对我有用

<html lang="zh-cn"><头><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><body onload="prettyPrint()" bgcolor="white"><pre class="prettyprint linenums languague-css">//一些源代码类 Foo {公共 int 栏 { 得到;放;}}

</html>

I am trying to highlight some syntax using Google prettify but so far, its not working.

<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>

Is there a solution to make this work without messing too much with the pre tag already in bootstrap?.

解决方案

EDIT: for twitter bootstrap 2.0.x, it works fine with 2.1.x

Use the those 2 files instead of using the method describe in the doc.

http://twitter.github.com/bootstrap/assets/js/google-code-prettify/prettify.css

http://twitter.github.com/bootstrap/assets/js/google-code-prettify/prettify.js

This works for me

<!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 上的语法高亮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆