After posting any source code, First we make sure that the code is correct and same as the original. For HTML or script source code, we require HTML Encoding so that blogger doesn't execute this code.The Source code format should be different from content and there should be option for copy code or print code so that user don't need to select entire code and press ctrl+c. I use "Syntaxhighligher" to display source code in blogger. It fullfills all requirement. First Layout is very pretty with line numbers and it provides "View Plain" (To display only source code in another window),"Copy to clipboard" and "Print?" options. We will see How can we use syntaxhighlighter in blogger without any hosting.
1.In the blogger,Click on Layout tab ->Edit HTML and put following things Before </head>
<link href='http://syntaxhighlighter.googlecode.com/svn/trunk/Styles/SyntaxHighlighter.css' rel='stylesheet' type='text/css'/>
<script language='javascript' src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shCore.js'/>
<script language='javascript' src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushCpp.js'/>
2. put following things Before </body>
<script language="javascript">
dp.SyntaxHighlighter.BloggerMode();
dp.SyntaxHighlighter.HighlightAll('code');
</script>
3. encode (HTML Encode) your source code. for this, you can use this.
OR
Copy your code in notepad and replace all < in < etc.
4. Put your updated code between:
<pre name="code" class="Cpp">
….My code here…
</pre>
Thanks a lot. There are thousand other blog entries explaining the same stuff. And I only understood yours.
ReplyDeleteThanks.
It never work with me in my blog.
ReplyDeleteCould you please explain it step by step?
Thanks for the comment on my blog .net. I'll be sure to try it out when I start publishing some source.
ReplyDeleteGreat post! If you want to escape all of the HTML characters in your code, you can use:
ReplyDeletehttp://www.accessify.com/tools-and-wizards/developer-tools/quick-escape/
For FireFox:
ReplyDelete1. Open following url:
http://syntaxhighlighter.googlecode.com/svn/trunk/Styles/SyntaxHighlighter.css
2. Copy it
3. paste with existing styles in Layout-> Edit HTML in blogger.
4. Remove following line
<link href='http://syntaxhighlighter.googlecode.com/svn/trunk/Styles/SyntaxHighlighter.css' rel='stylesheet' type='text/css'/>
can you tell me what am I doing wrong? I did everything like you said but it doesn't give same result.
ReplyDeletemy blog:
http://alisteroz.blogspot.com
Hi Alisteroz,
ReplyDeleteI see this is working on your blog.
Which browser are you using?
May be browser or firewall issue, I tested your blog on IE7 and Firefox. On both, It is working fine.
Marvellous.. thanks for this post! Now to try it.. :)
ReplyDeleteHmmm.. this didn't work for me. I went here instead and fixed up the broken link tag it works: http://morten.lyhr.dk/2007/12/how-to-get-syntax-highlighting-in.html
ReplyDeleteThanks a lot ! It's simple and works :) One question - I've seen project's homepage and there is version 1.5.1 and that one from the trunk is 1.5.2 - do you have somewhere some docs regarding changes/improvements you've introduced ?
ReplyDeleteAs for example of successful installation:
http://tech4web.blogspot.com/2008/12/simple-example-of-fish-eye-effect-in.html
Thanks for the post. I use a very simple method, without any installation required.
ReplyDeletehttp://blog.giladnaor.com/2009/02/source-code-highlighting-in-blogger.html
Could you lend a hand my way? I've been trying to get this to work for an hour and still no luck. I've tried a dozen variations and nothing works.
ReplyDeletehttp://magicscrollsofcode.blogspot.com/
and here is a copy of my html
http://www.megaupload.com/?d=8EK5M6D8
When I paste the code above blogger and click on save I get the message: Your HTML cannot be accepted. What am I doing wrong?
ReplyDeleteThis post was a precious help now that google pages are about to close!
ReplyDeleteYou rock!
Thanks a lot. It works great.....I tried with lots of blog posts but only this one helped.
ReplyDeletethanks a lot .great toturial
ReplyDeleteDo you have any result screen shoot of this methode?
ReplyDeleteIt is not working in FF the way you include scripts.
ReplyDeleteInstead of <script language='javascript' src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shCore.js'/>
it must be <script language='javascript' src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shCore.js'></script>
and so on for all scrpits includes...
Hope this helps
great
ReplyDeletewww.tsmguide.co.cc
Hi,
ReplyDeleteArticle is flawless with smooth flow and more above all the article is nicely explained.
Hi, this works fine for my blog: http://martin-thoma.blogspot.com/2011/01/how-to-post-code-on-bloggercom.html
ReplyDeleteIt would be cool if they had a bash-highligter.
visit on a nice blog, i like your post and keep posting,thanks friends
ReplyDeletedoes it work for java code also ? I tried but no success budy :(
ReplyDeleteJavin
Why String is immutable in Java
I didn't do the javascript bit but it seems to works fine for the source code on my blog
ReplyDelete....or is it? I checked by opened my blog on few different browser and it shows ok
Great info, thanks a lot.
ReplyDeletehttp://www.andolasoft.com/services/asp.net-application