Showing posts with label SyntaxHighlighter. Show all posts
Showing posts with label SyntaxHighlighter. Show all posts

Saturday, November 30, 2013

Blogger or Wordpress?

I like the default look of this blog on Blogger: simple, stylish and easy to read. Still, there's a few things that I don't like:
  • E.g. the 'pop-ups' urging you to involve Google+ in your posts. I don't mind being reminded once but they keep at it in a most annoying way.
  • Also, I'm amazed that I am reduced to using the on-line editor to prepare posts. Why can I not simply use my favorite editor vim to prepare a post and then upload it?
  • Finally, it's OK to use <pre> and <code> for source code but for longer excerpts, syntax coloring and highlighting of selected lines is highly desirable. Syntaxhighlighter is OK but it is not exactly easy to use while prettify is too primitive. Compared to that, Wordpress provides an easy to use interface to SyntaxHighlighter which has everything you need and then some.

So I wondered whether I would perhaps be better off with Wordpress?

Tim Brooks provides a detailed comparison of Wordpress and Blogger from which I conclude that I'd better stick to Blogger unless I use the self-hosting method: installing wordpress, which is open source under the GPL license, on my own server. On Ubuntu, it seems trivial to install Wordpress.

Tuesday, November 12, 2013

Showing source code in a post

Since I'm interested in computer science, I'll probably want to show some source code at some point in the future. There appear to be many possibilities, of which I looked at 3.
  1. The obvious way would be to use <pre> like so:
    int fib(unsigned int n) {
      if ( n <=1 )
        return n;
      else
        return fib(n-1) + fib(n-2);
    }
    
    unsigned int a[] = 
      { fib(1), fib(2), fib(3) };
    
  2. Using SyntaxHighlighter: this gives nice results but the method seems complicated and I wondered whether something simpler is available.
  3. Google-code's prettify seems simple enough. Here's the input: <script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js"></script> <pre class="prettyprint lang-cpp"> int fib(unsigned int n) { ... </pre> And here's the result:
    int fib(unsigned int n) {
      if ( n <=1 )
        return n;
      else
        return fib(n-1) + fib(n-2);
    }
    
    unsigned int a[] = 
      { fib(1), fib(2), fib(3) };
    
    So adding one "script" line gives you syntax coloring and a box around the code.
I guess, I'll use (1) or (3).