4

I was looking to see how to make this work and what I came up with is This question and answer.

So I included the css and js and I put the onload in the body tag as the answer states, I then created the pre tage and in the end created this:

<pre class="prettyprint linenums languague-css">        
    function(){
        echo "test"
    }
</pre>

So then I went to the browser to see my out put, it partially worked.

Image of out put

There are NO console errors, both the css and the js scripts ARE loaded properly, that is I can go into the source, click on the link and NOT get a "I can't find you" error.

So with that information...

What's going on?

Community
  • 1
  • 1
TheWebs
  • 12,470
  • 30
  • 107
  • 211
  • 1
    Well, `language` is misspelled as `languague` — that might be it. – couzzi Mar 29 '13 at 02:44
  • It is misspelled, but that is not causing this. Not sure what is, though; I can't get the linenumbers to show either with bootstrap 2.3 - http://jsfiddle.net/serra/tyRkZ/4/. The code is formatted nicely, only the line numbers do not show. – Marijn Mar 29 '13 at 14:55
  • In that JSFiddle, the line numbers aren't showing because the 'Normalize CSS' option is checked, which sets the `list-style` property for `ol` and `ul` elements to 'none'. If you disable 'Normalize CSS' (under Fiddle Options) or add `.container ol { list-style-type: decimal; }` to your CSS, then the line numbers show up as expected. – cmptrgeekken Mar 29 '13 at 15:26

2 Answers2

3

This happens when you include the prettify stylesheet, but forget to include the prettify Javascript code. Or if the Javascript code doesn't run.

Try running the prettify code in the document ready, instead of the onload:

! function ($) {
    $(function () {
        window.prettyPrint && prettyPrint()
    })
}(window.jQuery)

That worked for me, see here.

Marijn
  • 10,367
  • 5
  • 59
  • 80
  • Thank you so much! My Google Pretty Print stopped working after I used a theme from Bootswatch. Putting your code in the top of my desired file made it work again, perfectly! Before I had relied on This clearly did NOT work, and I've deleted onLoad. – Raymond Gan Dec 05 '13 at 11:55
0

It was a caching issue that caused the javascript to not work.

TheWebs
  • 12,470
  • 30
  • 107
  • 211