Skip to content

Commit a1f071c

Browse files
committed
Add #shared-names for selector and property names
1 parent 942299b commit a1f071c

File tree

1 file changed

+132
-0
lines changed

1 file changed

+132
-0
lines changed

src/vscode-css/grammars/css.cson

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,6 +1751,9 @@
17511751
'''
17521752
'name': 'variable.css'
17531753
}
1754+
{
1755+
'include': '#shared-names'
1756+
}
17541757
{
17551758
'include': '#property-names'
17561759
}
@@ -2112,6 +2115,135 @@
21122115
'name': 'entity.name.tag.custom.css'
21132116
}
21142117
]
2118+
'shared-names':
2119+
# Shared names are keywords that are listed in both selector and property name contexts.
2120+
'patterns': [
2121+
# The following are considered selectors by default:
2122+
{
2123+
'begin': '''(?xi)
2124+
# Selector match must be preceded by one of the following:
2125+
(?<=
2126+
^ # Start of line
2127+
| (^|[^\\:])\\s # Whitespace, after the start of a line or any character except a colon
2128+
| [{}] # Opening or closing brace (condensed property list syntax)
2129+
| \\*/ # Comment end
2130+
| \\\\(?:[0-9a-fA-F]{1,6}|.) # Escape sequence
2131+
)
2132+
2133+
(?=
2134+
# Selector must match:
2135+
(?:
2136+
# HTML elements
2137+
header|image|label|marquee|mask|nav|ruby|shadow|span|style
2138+
# SVG elements
2139+
|color-profile|line|text
2140+
)
2141+
2142+
# Selector must NOT be followed by any any of the following:
2143+
(?!
2144+
.*; # Any characters followed by a semicolon (denotes a property)
2145+
| [^{]*} # Any characters, except an opening brace, followed by a closing bracket (denotes a property)
2146+
| - # A dash (denotes a property name)
2147+
| \\:\\s+ # A colon followed by whitespace (denotes a property name)
2148+
)
2149+
)
2150+
'''
2151+
'end': '''(?xi)
2152+
# Selector match ends with one of the following:
2153+
(?=
2154+
\\s # Whitespace
2155+
| \\/\\* # Comment
2156+
| , # Comma
2157+
| { # Opening property list brace
2158+
| $ # End of line
2159+
)
2160+
'''
2161+
'patterns': [
2162+
{
2163+
'include': '#selector'
2164+
}
2165+
]
2166+
}
2167+
# The following are considered property names by default when attached to a colon:
2168+
{
2169+
'begin': '''(?xi)
2170+
# Selector match must be preceded by one of the following:
2171+
(?<=
2172+
^ # Start of line
2173+
| (^|[^\\:])\\s # Whitespace, after the start of a line or any character except a colon
2174+
| [{}] # Opening or closing brace (condensed property list syntax)
2175+
| \\*/ # Comment end
2176+
| \\\\(?:[0-9a-fA-F]{1,6}|.) # Escape sequence
2177+
)
2178+
2179+
(?=
2180+
# Selector must match:
2181+
(?:
2182+
# HTML elements
2183+
content|font|mark
2184+
# SVG elements
2185+
|cursor|filter
2186+
)
2187+
2188+
# Selector must NOT be followed by any any of the following:
2189+
(?!
2190+
.*; # Any characters followed by a semicolon (denotes a property)
2191+
| [^{]*} # Any characters, except an opening brace, followed by a closing bracket (denotes a property)
2192+
| - # A dash (denotes a property name)
2193+
| \\: # A colon, unless it's with one of the following:
2194+
(?!
2195+
# A opening bracket before an closing bracket
2196+
[^}]*{
2197+
# A pseudo-class selectors
2198+
| active|any-link|checked|disabled|empty|enabled|first
2199+
| (?:first|last|only)-(?:child|of-type)|focus|focus-visible|focus-within|fullscreen|host|hover
2200+
| in-range|indeterminate|invalid|link|out-of-range
2201+
| read-only|read-write|required|root|scope|target|unresolved
2202+
| valid|visited
2203+
2204+
# A functional pseudo-class selectors
2205+
| (?: dir|lang
2206+
| not|has|matches|where|is
2207+
| nth-(?:last-)?(?:child|of-type)
2208+
)\\(
2209+
2210+
# A single-colon pseudo-element selectors
2211+
| after
2212+
| before
2213+
| first-letter
2214+
| first-line
2215+
| (?:
2216+
\\-
2217+
(?:
2218+
ah|apple|atsc|epub|hp|khtml|moz
2219+
| ms|o|rim|ro|tc|wap|webkit|xv
2220+
)
2221+
| (?:
2222+
mso|prince
2223+
)
2224+
)
2225+
-[a-z-]+
2226+
)
2227+
)
2228+
)
2229+
'''
2230+
'end': '''(?xi)
2231+
# Selector match ends with one of the following:
2232+
(?=
2233+
\\s # Whitespace
2234+
| \\/\\* # Comment
2235+
| , # Comma
2236+
| { # Opening property list brace
2237+
| $ # End of line
2238+
)
2239+
'''
2240+
'patterns': [
2241+
{
2242+
'include': '#selector'
2243+
}
2244+
]
2245+
}
2246+
]
21152247
'string':
21162248
'patterns': [
21172249
{

0 commit comments

Comments
 (0)