slim-template / ruby-slim.tmbundle

A Textmate / Sublime Text bundle for Slim
http://slim-lang.com/
MIT License
184 stars 46 forks source link

Control code not appropriately highlighted (Solution attached) #11

Closed squidfunk closed 12 years ago

squidfunk commented 12 years ago

Hey there,

If you write:

- @facets.each do |facet|

the code is not highlighted as Ruby code. The error lies in the following line:

begin = '^\s*([\w.#_-]*[\w]+)';

If you replace it by the following Regex, it works:

begin = '^\s*([\w.#_][\w.#_-]*[\w]+)';

This Regex is used to detect keywords. However, there is no keyword starting with "-". divs are always starting at least with "#" or ".", so the "-" can only be part of classnames (and therefore not stand at the beginning).

I thought it isn't worth forking, since it is only one regex found in two lines within the code, so maybe you include it in the future if considered useful.

All the best, Martin

inancgumus commented 12 years ago

Can you add this? I'm having the same problem.

desperatethelark commented 12 years ago

I also am not getting any syntax highlighting on lines like this. for example, - unless foo renders as plain white text, whereas = unless foo recognizes unless as ruby code. I attempted to replace the Regex above with the one @squidfunk provided, but that didn't fix it for me.

Also, if it helps, I'm using Sublime Text 2.

--Update--

The most recent version seems to have fixed this issue, at least in all the instances I have tried.

inancgumus commented 12 years ago

I've found a quick solution for this:

If I write at the beginning of a file, it disables highlighting:

-title "#{something} somewhere"
-other @something

But if I write like below, it enables highlighting again:

-other @something
-title "#{something} somewhere"

You can use this for a dirty little quick fix.