Tuesday, December 20, 2011

Highlighting Eiffel syntax in Blogger (DONE!)

Syntax highlighting of programming languages seems to require a little tweaking in Blogger. SyntaxHighlighter from Alex Gorbatchev is a most widespread syntax highlighter used in Blogger but it doesn't support Eiffel out-of-the-box.
Luckily it's all JavaScript and supports Delphi and Pascal and it's hosted on github, so I forked it (with git it's fast, light and easy to merge the changes in the main trunk) to add (Smart)Eiffel support, thanks to the nice guide the main developer provided.

2011-12-22 update: I tried a really quick hack and I got a preliminary working version. To use it in Blogger I had to switch to a "simple" theme, one whose sources can be hacked, adding in the head the following code:
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css" rel="stylesheet" type="text/css"></link>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js" type="text/javascript">
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shAutoloader.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXML.js' type='text/javascript'/>
<script src='http://www.monodes.com/scripts/shBrushEiffel.js' type='text/javascript'/>

<script language='javascript'>
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/2.1.364/scripts/clipboard.swf';

Please note that I couldn't directly use the file on github, perhaps it does not like https so I falled back putting on a website on mine (namely at 'http://www.monodes.com/scripts/shBrushEiffel.js') until I improve it a little before proposing it to the main trunk.
Also since Alex says:
While the hosting is offered as a free service, I’m currently receiving approximately 22m requests a and 83GB in bandwidth every month which is costing me an additional $40 on Amazon S3. Where am I going with this? You guessed it – please donate to help me pay for this :)
I think I would rather put an entire copy of the package on my domain.


  1. To attract new developers we shall be somehow pretty, otherwise the beauty of the language will be ruined by the ugliness of the formatting.
    Also it may help me dealing with generators: did you hear me writing about an Eiffel to Javascript compiler? :-)

  2. Well, actually I shall refine it a little; see these issues:
    Please feel free to add other