Random Stuff About Stuff

Blogger Getting Started

May 03, 2012

I'm not on Blogger anymore So this post doesn't look like it should anymore as it's moved several platforms now

Blogger Getting Started

So I decided to give this blogging thing a go.  Mainly so that when I figure out something I’ll have a place to find it again and in theory should help me document the process of doing things etc…

So I decided to go with blogger, Wordpress is good of course but I have a Google account and sure it seems to offer more customisation… kind of.

So first order to business was code highlighting, I reckon I will be posting code so I want it to look pretty and be readable etc… So it turns out there are loads of options for this but two seem to stand out

SyntaxHighlighter
http://alexgorbatchev.com/SyntaxHighlighter/
Which sure seems to have alot of hits on Google

Google Code Prettify
http://code.google.com/p/google-code-prettify/
Used on Google code and stackoverflow it seems

So maybe because I’m used to seeing it on stackoverflow I think I’ll try the google code prettify and sure it’s another Google project so it’ll be easy to integrate into Blogger right?

So how does random code look in normal mode

/** * @author David Kerwick * Created 3 May 2012 */public class HelloWorld {        public void hi(){        System.out.println("Hello Blogger");    }}

Not bad really, a bit dull though and as soon as the code got longer it would be hard to read.
I also had to get the HelloWorld in, it just won’t feel right starting without it :)

So how to add the highlighting.  Like most things I’m way behind the curve so it was easy find other people who had added it.

Adding SyntaxHighlighter
Adding Google Code Prettify

So first roadblock, that sure didn’t take long, I haven’t even finished my first post!
The Edit HTML button they both speak of in the Template section is greyed out.
Turns out Dynamic Views don’t allow the addition of third party scripts or css.
Bummer.

So you can do get it working
http://www.alexconrad.org/2011/12/highlight-code-with-bloggers-dynamic.html

But that’s a bit of a hack I think, so Dynamic Views it was nice not to use you, time to switch to something else. Switched to a simple view and now this should work

<pre class="prettyprint linenums">
/**  
 * @author David Kerwick  
 * Created 3 May 2012  
 */  

public class HelloWorld {  

    public void hi(){  
        System.out.println("Hello Blogger");  
    }  
}
</pre>

Which it does, happy days all praise the Internet. It looks butt ugly now time to try figure out themes on prettify, another post perhaps


Written by David Kerwick who lives and works Dublin as a Java Technical Lead.