简体   繁体   English

BEM嵌套SCSS与父选择器中断Sublime Text语法突出显示?

[英]BEM nesting SCSS with parent selectors breaks Sublime Text syntax highlighting?

I'm experimenting with BEM syntax on a project that uses SCSS. 我正在使用SCSS的项目上试验BEM语法。 My editor is Sublime Text 3 and I'm using SCSS syntax highlighting. 我的编辑器是Sublime Text 3,我正在使用SCSS语法高亮显示。

The problem I'm experiencing is that when I nest using the & parent selector as per this article by Mike Fowler , Sublime highlights it red. 我遇到的问题是,当我按照Mike Fowler的文章使用& parent选择器进行嵌套时,Sublime会将其突出显示为红色。 Here is an example: 这是一个例子:

在此输入图像描述

The code compiles fine, I'd just prefer that Sublime not flag these as errors. 代码编译得很好,我只是希望Sublime不将这些标记为错误。

Can anyone help config Sublime to do just that? 任何人都可以帮助配置Sublime来做到这一点吗?

I suggest using the Syntax Highlighting for Sass package for syntax highlighting. 我建议使用Syntax Highlighting for Sass包进行语法高亮显示。 Using it and the Neon Color Scheme , which fully supports all the scopes in the Syntax Highlighting for Sass package (disclaimer: I'm the theme's maintainer), your code looks like this: 使用它和Neon Color Scheme完全支持语法高亮显示Sass包中的所有范围(免责声明:我是主题的维护者),您的代码如下所示:

SHfS和Neon

with no errors (green is a class name, and & is recognized as a special SASS/SCSS symbol). 没有错误(绿色是类名,并且&被识别为特殊的SASS / SCSS符号)。 I'm not sure what package you're currently using for SCSS highlighting, but it obviously doesn't recognize the leading -- characters, or anything following leading __ characters, as valid. 我不知道你目前使用的是什么包SCSS突出,但它显然并不承认领导--字符,或任何下列领先__人物,为有效。 Switching over to the new syntax highlighting package should help. 切换到新的语法高亮包应该会有所帮助。

通过选择View> Syntax> SASS> SCSS,我解决了这个问题。这显然是由下载原始SASS包Sublime引起的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM