Another little improvement for the HTML recipe. This time is for properly highlighting attributes whose name contains a dash, like “http-equiv”. I also touched the tag rule, so that the DOCTYPE is recognized now:
/*
===============================================================================
Chili Recipe for the XHTML language
...............................................................................
Version: 1.5b - 2007/02 - http://noteslog.com/chili/
-------------------------------------------------------------------------------
Copyright (c) 2006 Andrea Ercolino
http://www.opensource.org/licenses/mit-license.php
===============================================================================
*/
{
steps: {
mlcom : { exp: /\<!--(?:.|\n)*?--\>/ }
, tag : { exp: /(?:\<\!?\w+)|(?:\>)|(?:\<\/\w+\>)|(?:\/\>)/ }
, aname : { exp: /\s+[\w-]+(?=\s*=)/ }
, avalue: { exp: /([\"\'])(?:(?:[^\1\\]*?(?:\1\1|\\.))*[^\1\\]*?)\1/ }
, entity: { exp: /&[\w#]+?;/ }
}
}
Some days ago I discovered that an HTML tag can have attributes whose values span multiple lines. This is very useful when the value is a piece of javascript code, which in fact is immune to white space.
The HTML recipe I bundled to Chili 1.5 is a bit wrong, though, because it doesn’t consider that possibility. This is one that does:
/*
===============================================================================
Chili Recipe for the HTML language
...............................................................................
Version: 1.5a - 2007/02 - http://noteslog.com/chili/
-------------------------------------------------------------------------------
Copyright (c) 2006 Andrea Ercolino
http://www.opensource.org/licenses/mit-license.php
===============================================================================
*/
{
steps: {
mlcom : { exp: /\<!--(?:.|\n)*?--\>/ }
, tag : { exp: /(?:\<\w+)|(?:\>)|(?:\<\/\w+\>)|(?:\/\>)/ }
, aname : { exp: /\s+\w+(?=\s*=)/ }
, avalue: { exp: /([\"\'])(?:(?:[^\1\\]*?(?:\1\1|\\.))*[^\1\\]*?)\1/ }
, entity: { exp: /&[\w#]+?;/ }
}
}
I’ve found that dp.SyntaxHighlighter is similar to Chili, in that it uses language descriptions based on JavaScript regular expressions, so it’s quite easy to convert them to Chili recipes. Here are the first 5 conversions (more to come): Java, C++, C#, CSS, and Delphi.