Ok lets see if new highlighter works.
#! /bin/env python
def python_funct():
a = a + b
print "Hello Highlighted code"
class Foo(Bar):
pass
So how to do it?
Simply use googles own client side code highlighting library .
Its easy. Just include this two lines at top of your blogger template:
<link href="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js"> </script>
And change body tag in your template to include
onload="prettyPrint()"
:>
...
<body onload='prettyPrint()'>
...
And thats it. Now all you have to do when you want highlighted piece of code in your blog is to use.
EDIT: Urls to prettyfy.js and prettyfy.css were wrong. They are fixed now.
<pre class="prettyprint">
... # Your code goes here
</pre>
9 comments:
I followed your recipe on http://neopythonic.blogspot.com/, and I verified that all the elements are indeed in the page, but it doesn't work. What am I missing?
I somehow managed to included the wrong url's to the prettyfy.js and prettyfy.css files like Boris Bluntschli pointed out in his comment.
I have fixed the url's in the post.
I am sorry for waisting your time :(
No problem. It works now. Thanks for teaching me!
very cool ! thanks !
Thank you for the summary!
omg you thought Guido something.
Nice post !
i use this to do my Code highlighting...
its easy to implement on blogger has hosting and has multiple styles and lots of language support
i followed the steps, i now have code highlighting. thanks
How you past code and blogger`s parser correct understood it?
Post a Comment