Why I'm using code2blog and how to extend it

This article was originally created for a blog I'm not running anymore. That's why it's written in a style, which is rather untypical for a tutorial. Anyway, you just shouldn't let you keep off from reading.

Why I'm using code2blog

As you may have noticed, I'm posting source code snippets many a time. In order to achieve a better readability it seems to be a good idea to highlight some special characters just as a specialized IDE does. However it is somewhat difficult to accomplish this goal satisfiable, that is, all common browsers should display the highlighted code correctly. Apparently there are four possibilities to do it:

So far so good

How to extend it

Adding new languages
Sad to say that although code2blog is just a graphical front end for the Source-highlight command line program which supports Shell script highlighting as per its supported languages list, it doesn't offer the language in its pull down menu. Since code2blog is just a script and therefore automatically open source I decided to add some more languages to the menu.
In what follows I want to explain how everybody can add the language he needs to code2blog (assumed this language is supported by GNU Source-highlight).
If you open code2blog in a text editor you can see, among other things, the following:
INPUT_LIST = [ "bison", "c", "cpp", "caml", "changelog", "diff", "eps", "flex", "html", "java", "javascript", "latex", "logtalk", "lua", "pascal", "perl", "postscript", "python", "ruby", "sml", "style", ]

As you can guess this is the part where the languages for the pull down menu are listed. Consequently adding new languages should be rather easy. But from where to get the information on how to label the new language? Because the contents of the pull down menu are just passed along to Source-highlight, you cannot simply use any name you want to, otherwise the console would report an error message. However you can find out the required name with a simple trick:
Open a console window and type in the following line: source-highlight --lang-list You get a long list of supported languages with their correct name. So if you want to add shell support, for instance, you have to find the line
shell = sh.lang and then add a "shell", entry to the mentioned list in the code2blog script (to preserve a consistent structure you should continue the alphabetic order).
Apropos: As you can see, the shell language uses the sh.lang language file. This means you could also just add a sh entry to the pull down menu list, because they are in any case handled the same way.

Setting a new default language
Finally you can change the language which is selected in the menu by default (since the given default python is not exactly what many users will use most frequently, this is a useful adjustment, saving some of the time you need to use the program).
Therefore you have to find the line in the code2blog script which is responsible for this:
self.input_format.set_active(*any_number*) You have to replace *any_number* with the index number of the entry you want to be the default one. Note that the count starts at 0 (verbal: zero). So if your preferred language is the fifth element in the pull down menu you have to replace *any_number* with 4.

Have fun with code2blog :-)