[TxMt] comment.line.number-sign.ruby != source.asp.embedded.html

Allan Odgaard allan at macromates.com
Thu Aug 11 21:38:27 UTC 2005

On 11/08/2005, at 23.27, Sune Foldager wrote:

>> I have the following ASP.net code
>> <tag attribute="<%# Users.PageSize %>" />
>> the scope of the #... part is coming up as comment.line.number- 
>> sign.ruby instead of source.asp.embedded.html
> The reason is that ruby (or eruby rather) uses <%  %> as delimiters  
> also. There should be an ASP bundle with a language that can be  
> used, I think?

I assume he's already using that.

The problem is that TM uses the rule which gives the longest match.  
The HTML grammar has a specific rule for the <%#...%> case (since the  
Ruby syntax doesn't know about erb and would include %> in the comment).

This rule will always be a longer match than the begin = "<%" in the  
ASP grammar (since for begin/end rules, the length of the begin  
pattern is used), thus the Ruby comment rule (in the HTML grammar)  
will win over the embedded ASP rule, in the ASP grammar which  
includes the HTML grammar.

This is one of the reasons why I recently proposed to change the  
system to always use the first rule which matches, rather than the  
longest :)

For now I'd suggest just removing the Ruby comment rule from the HTML  
grammar, and hopefully soon I'll change the precedence algorithm (I  
need to check and possibly re-arrange all grammars when doing so).

More information about the textmate mailing list