A few days ago I posted about using qlcolorcode to display syntax highlighted ColdFusion code in Mac OS X’s Finder’s quick look. Now – I had a bit of a look into how to use/extend the same plugin for displaying Action Script and MXML code as well.
Qlcolorcode already has built-in support for Action Script (although it’s not complete and really 100% correct for AS3 as it appears to me), but it’s supposed to do the trick. I ran into the issue that it unfortunately didn’t work for me. A bit time spent looking around and playing with the default application to open .as files on my Mac brought up the following blog post. Of particular interest are the comments:
I can just speak for Snow Leopard and in that case you’d want to look into comments 8, 12 and 18. Basically after this step the relevant section in my Info.plist in the Qlcolourcode plugin package looks as below and syntax highlighting for Action Script works (sort of):
CFBundleDocumentTypes CFBundleTypeRole QLGenerator LSItemContentTypes public.source-code public.xml com.apple.property-list org.tug.tex public.plain-text com.apple.applesingle-archive
The next step was to get MXML working. That’s a bit trickier because it’s not yet built-in into the plugin. Luckily Qlcolorcode supports XML and as MXML is a proper, fully XML-compliant language it can’t be too hard to enable it for MXML. The good thing is – someone has done it before:
The bad thing – this is for OS X 10.5 and it didn’t work out of the box for me. In general I’d recommend to follow the descriptions in there. The command to run in step 5 on OS X 10.6 would be different though:
qlmanage -d3 -p yourmxmlfile.mxml 2>&1 | grep 'Generator used'
Also the path used in step 8 had to be different for me. Instead of Resources/highlight/etc/highlight/ the filetypes.conf would have to be looked for in Resources/etc/highlight/. Also in my version of the file the file type definitions for xml and html did look differently:
$ext(xml)=sgm sgml nrm ent hdr hub dtd wml vxml wml tld svg xsl ecf jnlp mxml
As you can see, I added the mxml file suffix to where it made much more sense imho. From here on just follow the instructions and you should be good to go.
This should provide a working solution – not necessarily a perfect one as the highlighting for AS 3 is not quite right and it would be nice to tweak the syntax highlighting for MXML and CF; some new CF tags are not properly picked up etc. I might have a look into that – it’s not too hard actually because qlcolorcode uses highlight internally. Will keep you posted 🙂