slim-template / ruby-slim.tmbundle

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

Syntax highlighting stops after a markdown block #81

Open DannyBen opened 2 years ago

DannyBen commented 2 years ago

This used to work well in previous versions of sublime (or the plugin), but now markdown blocks break the syntax highlighting.

image

deathaxe commented 1 year ago

This issue is fixed in Slim 2.0.

Slim 2.0 for ST4 has been released at Package Control, with source moved to https://github.com/SublimeText/Slim.

DannyBen commented 1 year ago

Thanks - I noticed that my slim syntax changed, but in my opinion - it changed for the worst. Not sure if it is another bug or the intended highlighting.

I don't remember exactly how it was before, but class names now have a different color. It throws the entire balance for me.

image

deathaxe commented 1 year ago

The scopes used for various tokens are equal to those which HTML uses for same semantically constructs.

As .row.grow.scroll expands to <div class="row grow scroll" a meta.attribute-with-value-class string scope has been choosen.

grafik

Tags such as div, a, img are scoped meta.tag entity.name.tag as they are in HTML. Them not being highlighted seems to be a color scheme issue.

The following screenshots show your code snippet with Mariana and a tweaked Brackets Dark:

grafik

grafik

I agree string scope for class names to probably be a bit overused. Not quite sure about proper alternatives though.

DannyBen commented 1 year ago

I think that previously, they received the same color as div, which made more sense to me, as the below snippet would render all in the same color, except #bloomberg-logo - which felt right, since they all do the same thing of opening a new block.

The fact that these classes are strings in another format are arguably less relevant, no?

.row.grow.scroll
  .panel.side-panel
    div#bloomberg-logo

I am not 100% sure how it was - maybe just the first class was with the same color as div? I remember it was easy to read: .row then .panel then div.

deathaxe commented 1 year ago

With former Slim the first class name was not scoped and the following ones received entity.other.attribute-name which is semantically wrong, IMHO. Those are rather attribute values.

grafik

grafik

The fact that these classes are strings in another format are arguably less relevant, no?

This is basically correct and I've spend some time to come up with a proper decision.

I guess something like entity.name.class and entity.name.id would be appropriate as tags are already scoped entity.name.tag. Need however to make sure nothing bad happens as entity.name.class is used for class definitions in all kinds of source syntaxes. But I guess anything would be better than string.

DannyBen commented 1 year ago

I understand your point. These last screenshots are as I remember it. They made much more sense to me.

I know that the classes in .row.grow.scroll are "the same" - but since 'row is first, it made it clear and semantic. I guess I subconsciously also developed my classes so that they work well with the slim syntax.

I feel that the first class (if it appears on its own row, like in our example) should be in a different color, like any other "block starter" - but I totally understand the dilemma.

The thing is, that the new syntax sort of reminds me of how sublime looks when you "borrow" a syntax from another language, since the language you are using does not have proper highlighting (imaging using YAML highlighting for TOML files). It feels very off balance, like the highlighting logic does not "understand" the importance of the tokens.

deathaxe commented 1 year ago

Attribute shortcuts are scoped meta.attribute-shortcut entity.name.attribute as of Slim 2.0.1.

So they can be highlighted with a unique color. The first one in a line won't however receive a dedicated scope as it doesn't have a special meaning semantically.

grafik

grafik

Note:

Different highlighting of classes and ids can be configured by a color scheme via following scopes:

DannyBen commented 1 year ago

Cool. The screenshot looks better already, thanks for that. I will be waiting for it to reach package control.