Monday, January 9, 2012

How to use the syntax highlighting

I've edited the template for this blog so you can now use syntax highlighting/formating.
When you want to post your code, go to Edit HTML, and paste this before your code:
<pre class="alias" name="code">
 where "alias" is the name of the programming language you're highlighting.
For example, if you were posting python, you would put
<pre class="python" name="code">
If you have really long code you can attach ":collapse" to the alias and the code will only show up if the viewer clicks "Expand Source"
A collapsed C++ would look like this:
<pre class="cpp:collapse" name="code">
Here's a list of the languages and aliases:
http://code.google.com/p/syntaxhighlighter/wiki/Languages

Of course, remember to close your html tags with </pre> at the end of your code.

1 comment:

  1. Your collapse/expand code doesn't seem to work. Using Chrome Browser.

    ReplyDelete