I'm using blogger.com to host some texts on programming, and I'd like to use prettify (same as stackoverflow) to nicely colour the code samples.
How do I install the prettify scripts into the blog domain?
Would it be better (if indeed its possible) to link to a shared copy somewhere?
I have webspace on a different domain. Would that help?
Many thanks.
cdnjs providing the library "SyntaxHighlighter"
got to blogger >> template >> edit template add below code just before ending of the body tag and save template.
I have given Example for python.
you can link the other language script files from cdnjs. syntax highlight code
for other languages go and copy script: https://cdnjs.com/libraries/SyntaxHighlighter
Not a direct answer to your question, but worth consider GitHub. You can get a free account and get syntax colored "gists" which you can share and host on your web page.
The downside is that the copy is hosted on Github's site and if that's down, then it's down for you too.
Have a look at SyntaxHightlighter at http://alexgorbatchev.com/wiki/SyntaxHighlighter On that site you can also find instructions on how to use it at blogger.com and the site offers a hosted version of the required scripts so you don't need to host files somewhere yourself.
Go to blogger theme section and click on edit HTML.. Then add the Google Prettify CDN to the head tag of the HTML.
https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js'/>
Then include a theme for code snippet below this script..I included Desert theme.
For more themes, visit here.. Prettify themes
When you create a post, change the edit mode from visual to HTML and go to the place where you are going to add the code snippet. Then include the code like this.
You can change the code style by selecting relevant languages html, css, php, javascript... Here I used a html code snippet.
Nowadays, Google-Code-Prettify has an Auto-Loader script. You can load the JavaScript and CSS for prettify via one URL.
Add the script to the
<head>
section of your Blogger template and it will work on all your posts:More detail here: http://code.google.com/p/google-code-prettify/wiki/GettingStarted
Another solution is to use the syntaxhighlighter 2.0 java script library. I've used it on my blog and it seems to work quite well.
Here's a post about it:
http://www.craftyfella.com/2010/01/syntax-highlighting-with-blogger-engine.htmllink text
Cheers.