Syntax highlighting on twitter bootstrap

Gandalf picture Gandalf · Jun 2, 2012 · Viewed 28.9k times · Source

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

Answer

baptme picture baptme · Jun 2, 2012

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>