htmlprettifygoogle-code-prettify

Syntax highlighting of code snippets in a web page "google-code-prettify" not working


I have following code,

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link href="../../../Styles/prettify.css" rel="stylesheet" type="text/css" />
    <script src="../../../Scripts/prettify.js" type="text/javascript"></script>
</head>
<body>

<p>And from code behind write following :</p>

<pre class="prettyprint">
    protected void Page_Load(object sender, EventArgs e)
        {
            lblLoading.Text = "Loading News...";
        }
</pre>
</body>
</html>

I am not able to see code syntax at the result. What have I missed?

The result is like this:

An online demo is here: http://jsfiddle.net/yKss3/


Solution

  • Change

    <body>
    

    to

    <body onload="prettyPrint()">
    

    Prettify's README file says:

    1. Download a distribution
    2. Include the script and stylesheets in your document (you will need to make sure the css and js file are on your server, and adjust the paths in the script and link tag) <link href="prettify.css" type="text/css" rel="stylesheet" /> <script type="text/javascript" src="prettify.js"></script>
    3. Add onload="prettyPrint()" to your document's body tag.
    4. Modify the stylesheet to get the coloring you prefer