PrismJS / prism

Lightweight, robust, elegant syntax highlighting.
https://prismjs.com
MIT License
12.34k stars 1.29k forks source link

Parameterized pseudo-classes break selector highlighting in SCSS #3740

Open LeaVerou opened 1 year ago

LeaVerou commented 1 year ago

Information:

Description SCSS selectors that include parenthesized pseudo-classes are not highlighted as selectors. Note that CSS does not have this issue.

Example

Triggers the bug:

foo :foo() bar {

}
image

Does not trigger the bug:

foo :foo bar {

}
image

Workaround

This appears to fix it in my setup (simply removing () from [^@;{}()\s], but not sure whether it breaks something else (@golmote any idea why that avoids parens?):

Prism.languages.scss.selector.pattern = /(?=\S)[^@;{}()]?(?:[^@;{}\s]|\s+(?!\s)|#\{\$[-\w]+\})+(?=\s*\{(?:\}|\s|[^}][^:{}]*[:{][^}]))/;
Golmote commented 3 weeks ago

The pattern you suggested breaks the highlighting of the following code:

@mixin prefix($property, $value, $prefixes) {
}

where prefix should be tokenized as a function.