Now extract the contents of the package and upload the Scripts and Styles folder to any host or website which can be linked from your blog.
To make it work, you will need to edit your blog's template and add the following code after the <!-- end outer-wrapper --> tag:
<link href='http://[YOUR HOST URL]/SyntaxHighlighter.css' rel='stylesheet' type='text/css'/>
<script language='javascript' src='http://[YOUR HOST URL]/shCore.js'/>
<script language='javascript'>
dp.SyntaxHighlighter.BloggerMode();
dp.SyntaxHighlighter.HighlightAll('code');
</script>
Now you just need to add support for the languages you want, I could just say, just put this bunch of code on your blog's template and it will work, but most people don't post code in several languages, also it's very important to understand what the hell you are doing.
To add syntax highlight support for python, after the shCore.js line you added before, add this line:
<script language='javascript' src='http://[YOUR HOST URL]/shBrushPython.js'/>
If you browse the Scripts folder of the syntaxhighlighter package, you will notice several shBrush*.js files, like shBrushPhp.js, these files are the highlight rules for especific languages, to support other languages, just change the shBrushPython in the above code to your language's specific file and add it to your template.
Syntaxhighlighter supports pre and textarea tags, but it will not work automagically, you need to specify that a pre or textarea tag is code and which language the code is.
To add some python code to your blog use:
<pre name="code" class="python">
The list of supported languages and their aliases can be found at the syntaxhighlighter wiki
35 comentários:
Awesome! Thanks :)
justo lo que buscaba :-P ..
Muy bueno, gracias por la información, pero no es necesario colgarlo en un servidor propio, pues ya está colgado por los autores del mismo:
<link href='http://syntaxhighlighter.googlecode.com/svn-history/r57/trunk/Styles/SyntaxHighlighter.css' rel='stylesheet' type='text/css'/>
<script language='javascript' src='http://syntaxhighlighter.googlecode.com/svn-history/r57/trunk/Scripts/shCore.js'/>
javascript:void(0)
<script language='javascript'>
dp.SyntaxHighlighter.BloggerMode();
dp.SyntaxHighlighter.HighlightAll('code');
</script>
<!--Support for python : -->
<script language='javascript' src='http://syntaxhighlighter.googlecode.com/svn-history/r57/trunk/Scripts/shBrushPython.js'/>
Nice one!, thanx for the tip, just a remark: Its not really needed to upload the code as its already hosted by google.code. This would make it:
<link href='http://syntaxhighlighter.googlecode.com/svn-history/r57/trunk/Styles/SyntaxHighlighter.css' rel='stylesheet' type='text/css'/>
<script language='javascript' src='http://syntaxhighlighter.googlecode.com/svn-history/r57/trunk/Scripts/shCore.js'/>
javascript:void(0)
<script language='javascript'>
dp.SyntaxHighlighter.BloggerMode();
dp.SyntaxHighlighter.HighlightAll('code');
</script>
<!--Support for python : -->
<script language='javascript' src='http://syntaxhighlighter.googlecode.com/svn-history/r57/trunk/Scripts/shBrushPython.js'/>
I followed all the steps but when I see my blog in Firefox it is not working as expected, but its working in Internet Explorer. Here is the link to my blog: http://deepaksakpal.blogspot.com/2008/09/narrowing-widening-conversion-gotcha.html
thanks , i always had problems with posting pretty code on blogger
Hi! I received this error message from Blogger service when I try to save the template: bX-m0ky5r.... So long!
Thanx for the tip man....
I hosted my files on mediafire. but with those links syntax highlighter doesn't work. then i pasted your links to the code and it worked. seems like mediafire is not serving the files. can you please host the other language files and post the links?
There is not <--- outer-wrapper---> tag on my blogger templates...what do i do?
we provide a power leveling and free wow gold wow power leveling
Thanks, I just applied this to my own blog ;)
Thanks, After browsing to everywhere, your guide is crystal clear. thanks
it is not working in my blog :(
Procurei bastante mas o seu post foi o mais simples de implementar. Parabéns pelo trabalho.
Rudy
Who knows where to download XRumer 5.0 Palladium?
Help, please. All recommend this program to effectively advertise on the Internet, this is the best program!
It dosen't work. I followed all steps but something is wrong.
here is a tool wich does it for you!
click
hi..thanks..
my blog is about VHDL coding.I want to use syntax highlighter for VHDL in my site.Is it available in google?
Here is a link to my site:
http://vhdlguru.blogspot.com/
nice post, thanks
Here's a guide on how to use syntax highlighter in your sie:
http://practician.blogspot.com/2010/07/color-my-world-syntax-highlighter.html#links
wow, nice trick :)
cool thanks,
http://youtrickz.blogspot.com
Thanks man :)
Thanks for giving us those tips to be able to add syntax highlight to Blogger.
I hate those codes because it is so difficult to me manage then when I'm working.
I'm having many problems with my computer and I try to fix it by myself following those steps and I save a lot of money because I don't have to pay for a technician.
Excellent..thanks
There is also a non javascript version of syntax highlighter for Blogger, like the one provided..
great simple tip, thanks!
no on in my template nor in 'classic' template. Which is your base template?
Are there any specific tags it need to fit in?
Thanks.
Can I add syntax for android?Here is the link of my blog http://www.androidcookers.co.cc/
thanks!
These blog is adorable able and it can calmly to affect the visitors , because its accepting able brawl . So you to beforehand the blog by appliance some Internet business activity and its calmly to adeptness the complete exchange place.
Funciona direitinho, eu hospedei os arquivos no dropbox, free.
O css voce coloca antes de fechar a tag head. Eu estava esquecendo de colocar rel = 'stylesheet', e os estilos
nao estavam sendo aplicados.
Os scripts voce pode colocar antes da tag body.
vlew!
Thanks for sharing information.wonderfull peice of code thanks.Keep posting.
Postar um comentário