Tuesday, July 31, 2012

Posting code to your blogger blog

http://oneqonea.blogspot.com.au/2012/04/how-do-i-add-syntax-highlighting-to-my.html

^^ worked for me, had it up and running in a couple of mins
/*
  This Is Not space invaYders
  This example code is in the public domain, etc, have fun :)
 */
 
// pin assignments
int annodes0 = 2;int annodes1 = 3;int annodes2 = 4;int annodes3 = 5;int annodes4 = 6;
//pin 7 is spare
int cathodes0 = 8;int cathodes1 = 9;int cathodes2 = 10;int cathodes3 = 11;int cathodes4 = 12;
int IndicatorLED = 13;
etc.. Cool eh? :) to make some code look all neat like that you just have to use HTML view within the blogger interface, and put it between the pre tags as follows:
The "brushes" allow you to define the type of code and therefore which syntax gets highlighted etc.  In this case I've used the cpp brush but there are heaps of others documented at the authors website here

In some cases when the pre method doesn't work (such as when it gets confused over the less than character <) you can instead escape your code with the following. Note also this code also features the argument to have your code auto-hidden; great for long posts:

No comments: