Haml Syntax Highlighter, version 0.1

Posted by ericp on 2007-02-02 11:14

We were asked recently when Komodo would provide syntax highlighting for http://haml.hamptoncatlin.com/, a rails markup language for showing views.

It didn't take long to whip up an extension with UDL, only it doesn't handle indent blocks, since we haven't implemented indentation-based parsing yet. Still, since all a syntax highlighter has to do is color text, but not understand it (most of the time), it works until indentation becomes significant.

This screenshot of the standard.haml test file in Komodo shows what you'll get if you install this extension:

Those yellow strings are my doing; I like to see what's going on when I write a syntax highlighter, but I don't want the scheme to be too hard on the eyes.

The attached zipfile contains two nested zip files:

haml_language-0.1.0-ko.xpi : install this into Komodo to get Haml syntax highlighting

haml.zip : contains the source code for building the xpi. See my tutorial on supporting Kid to see how to merge this source code with the Luddite build system. The instructions are in the first part.

I give this xpi a version 0.1 because indentation is significant in Haml the same way it is in Python, and we need to add that to UDL. For example, this will work in this version:

/ a comment

but this won't:

  indentation means this is a comment
but this line is data content

Anyone who figures out how to make indentation blocks work with this version of UDL, please let me know how you did it.

haml_bundle.zip5.46 KB

kbenton | Fri, 2007-02-02 11:22

That's fantastic! Now, if we can get real Perl Template Toolkit syntax highlighting, that would be great :-) Right now, it treats Perl TT as HTML and while it's very common for TT users to code in HTML, TT has its own syntax and I believe it's appropriate to deal with the two separately so the TT portions of the page stand out more than the HTML (or other) portions. Generally, when I'm coding a HTML page for TT, I prototype it in HTML, then add the TT stuff later. It's that time when I would really benefit from real TT syntax highlighting.


ActiveState Staff
Fri, 2007-02-02 11:31

By default, Komodo treats *.ttkt.html files as Template Toolkit files, and
*.html files as HTML files (where the root part doesn't contain a ".").

You can use Prefs|File Assocations to indicate that you always want .html
files to be treated as Template Toolkit files.

The gain here is that you won't have to manually change file views with
the View|View As Language|... command. You'll even have the benefits
of HTML syntax-checking and auto-completion.

blackrat | Wed, 2008-03-26 09:35

Hi Eric,
I installed the XPI file by using extensions manager, but syntax highlighting doesn't appear to work, even though the document type is recognised as haml. Any ideas as to where to look?


ActiveState Staff
Wed, 2008-03-26 10:51

Which platform are you on, and which version of Komodo?

Can you post the first few lines?

I installed the .xpi from the community site, not my own, on Windows XP,
restarted Komodo (4.3), and it worked fine. No fiddling under the hood

ltackett | Sat, 2008-03-29 06:14

Fresh install of Komodo Edit 4.3 from src on Ubuntu 7.10, and Haml doesn't highlight for me either. Same symptoms too, document type is detected as Haml, and a Haml filter is in the "open file" menu.

mordeletj | Wed, 2008-11-19 03:15

I can't install this .xpi on Komodo Edit 5. An error message appear with "Haml Language" will not be installed because it does not provide secure updates"

I tried to disable this message in "about:config" page with "extensions.checkUpdateSecurity" key at "false", but no result.

Any idea ?

ActiveState Staff
Wed, 2008-11-19 10:52

Removing the "updateURL" from the install.rdf should work around the security restriction, but I just tried this extension in Komodo 5 and it did not seem to be highlighting anything (i.e. it wasn't working).

mordeletj | Thu, 2008-11-20 02:00

It works fine with my Komodo Edit 5.0.1. on Vista.
Like you told me, i removed the "updateURL" line from the install.rdf (and i updated the "maxVersion" line)

Thanks !

ActiveState Staff
Wed, 2008-11-19 17:17

It works on Linux as well. Stay tuned for the URL.