tadast / sublime-rails-snippets

Sublime Text snippets for the latest Ruby and Rails versions
399 stars 55 forks source link

Fix escaping and unescaping evaluation characters #15

Closed bronson closed 11 years ago

bronson commented 11 years ago

Haml syntax supports !=, &= and ! to change escaping for string interpolation: http://haml.info/docs/yardoc/file.REFERENCE.html#escaping_html

Problem is, this syntax file doesn't understand this and highlights the Ruby code as plain text. Ugly!

This set of patches fixes it. Submitted in separate patches so, despite the complexity of the regexes, the intent is perfectly clear.

Submitted to you because, alas, Sublime's Rails support is being neglected and now looks truly antique. I really hope your changes make it upstream!

bronson commented 11 years ago

Here's a quick snippet to test these. Just drop the following in a .haml file:

"data" #{"code"}
! "data" #{"<code>"}
- "code"
= "code"
~ "code\ncode"
!= "code"
&= "code"
%p "data" #{"code"}
%p! "data" #{"<code>"}
%p= "code"
%p~ "code\ncode"
%p!= "code"
%p&= "code"
/ comment
-# comment
=# comment
!=# comment
&=# comment

The words code, data, and comment should all be highlighted properly. Github syntax highlighting gets it right!

tadast commented 11 years ago

Thanks Scott. I tried getting in touch with Sublime people regarding the Rails package but got no response.