Skip to content

Commit cf3260a

Browse files
committed
Update shared names rules
1 parent a3cb480 commit cf3260a

File tree

2 files changed

+135
-73
lines changed

2 files changed

+135
-73
lines changed

src/vscode-css/grammars/css.cson

Lines changed: 119 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -2136,82 +2136,131 @@
21362136
}
21372137
]
21382138
'shared-names':
2139-
# Shared names are keywords that can be used as selector or property names.
2140-
# If the following conditions are met, the keyword is considered a selector:
2141-
'begin': '''(?xi)
2142-
# Selector match must be preceded by one of the following:
2143-
(?<=
2144-
^ # Start of line
2145-
| (^|[^\\:])\\s # Whitespace, after the start of a line or any character except a colon
2146-
| [{}] # Opening or closing brace (condensed property list syntax)
2147-
| \\*/ # Comment end
2148-
| \\\\(?:[0-9a-fA-F]{1,6}|.) # Escape sequence
2149-
)
2139+
# Shared names are keywords that are listed in both selector and property name contexts.
2140+
'patterns': [
2141+
# The following are considered selectors by default:
2142+
{
2143+
'begin': '''(?xi)
2144+
# Selector match must be preceded by one of the following:
2145+
(?<=
2146+
^ # Start of line
2147+
| (^|[^\\:])\\s # Whitespace, after the start of a line or any character except a colon
2148+
| [{}] # Opening or closing brace (condensed property list syntax)
2149+
| \\*/ # Comment end
2150+
| \\\\(?:[0-9a-fA-F]{1,6}|.) # Escape sequence
2151+
)
21502152
2151-
(?=
2152-
# Selector must match:
2153-
(?:
2154-
# HTML elements
2155-
content|font|header|image|label|mark|marquee|mask|nav|ruby|shadow|span|style
2156-
# SVG elements
2157-
|color-profile|cursor|filter|line|text
2153+
(?=
2154+
# Selector must match:
2155+
(?:
2156+
# HTML elements
2157+
header|image|label|marquee|mask|nav|ruby|shadow|span|style
2158+
# SVG elements
2159+
|color-profile|line|text
2160+
)
2161+
2162+
# Selector must NOT be followed by any any of the following:
2163+
(?!
2164+
.*; # Any characters followed by a semicolon (denotes a property)
2165+
| [^{]*} # Any characters, except an opening brace, followed by a closing bracket (denotes a property)
2166+
| - # A dash (denotes a property name)
2167+
)
2168+
)
2169+
'''
2170+
'end': '''(?xi)
2171+
# Selector match ends with one of the following:
2172+
(?=
2173+
\\s # Whitespace
2174+
| \\/\\* # Comment
2175+
| , # Comma
2176+
| { # Opening property list brace
2177+
| $ # End of line
2178+
)
2179+
'''
2180+
'patterns': [
2181+
{
2182+
'include': '#selector'
2183+
}
2184+
]
2185+
}
2186+
# The following are considered property names by default when attached to a colon:
2187+
{
2188+
'begin': '''(?xi)
2189+
# Selector match must be preceded by one of the following:
2190+
(?<=
2191+
^ # Start of line
2192+
| (^|[^\\:])\\s # Whitespace, after the start of a line or any character except a colon
2193+
| [{}] # Opening or closing brace (condensed property list syntax)
2194+
| \\*/ # Comment end
2195+
| \\\\(?:[0-9a-fA-F]{1,6}|.) # Escape sequence
21582196
)
21592197
2160-
# Selector must NOT be followed by any any of the following:
2161-
(?!
2162-
.*; # Any characters followed by a semicolon (denotes a property)
2163-
| .*} # Any characters followed by a closing bracket (denotes a property)
2164-
| - # A dash (denotes a property name)
2165-
# | \\s*\\: # A colon, unless it's with one of the following:
2166-
# (?!
2167-
# # A opening bracket before an closing bracket
2168-
# [^}]*{
2169-
# # A pseudo-class selectors
2170-
# | active|any-link|checked|disabled|empty|enabled|first
2171-
# | (?:first|last|only)-(?:child|of-type)|focus|focus-visible|focus-within|fullscreen|host|hover
2172-
# | in-range|indeterminate|invalid|link|out-of-range
2173-
# | read-only|read-write|required|root|scope|target|unresolved
2174-
# | valid|visited
2198+
(?=
2199+
# Selector must match:
2200+
(?:
2201+
# HTML elements
2202+
content|font|mark
2203+
# SVG elements
2204+
|cursor|filter
2205+
)
21752206
2176-
# # A functional pseudo-class selectors
2177-
# | (?: dir|lang
2178-
# | not|has|matches|where|is
2179-
# | nth-(?:last-)?(?:child|of-type)
2180-
# )\\(
2207+
# Selector must NOT be followed by any any of the following:
2208+
(?!
2209+
.*; # Any characters followed by a semicolon (denotes a property)
2210+
| [^{]*} # Any characters, except an opening brace, followed by a closing bracket (denotes a property)
2211+
| - # A dash (denotes a property name)
2212+
| \\: # A colon, unless it's with one of the following:
2213+
(?!
2214+
# A opening bracket before an closing bracket
2215+
[^}]*{
2216+
# A pseudo-class selectors
2217+
| active|any-link|checked|disabled|empty|enabled|first
2218+
| (?:first|last|only)-(?:child|of-type)|focus|focus-visible|focus-within|fullscreen|host|hover
2219+
| in-range|indeterminate|invalid|link|out-of-range
2220+
| read-only|read-write|required|root|scope|target|unresolved
2221+
| valid|visited
21812222
2182-
# # A single-colon pseudo-element selectors
2183-
# | after
2184-
# | before
2185-
# | first-letter
2186-
# | first-line
2187-
# | (?:
2188-
# \\-
2189-
# (?:
2190-
# ah|apple|atsc|epub|hp|khtml|moz
2191-
# | ms|o|rim|ro|tc|wap|webkit|xv
2192-
# )
2193-
# | (?:
2194-
# mso|prince
2195-
# )
2196-
# )
2197-
# -[a-z-]+
2198-
# )
2223+
# A functional pseudo-class selectors
2224+
| (?: dir|lang
2225+
| not|has|matches|where|is
2226+
| nth-(?:last-)?(?:child|of-type)
2227+
)\\(
2228+
2229+
# A single-colon pseudo-element selectors
2230+
| after
2231+
| before
2232+
| first-letter
2233+
| first-line
2234+
| (?:
2235+
\\-
2236+
(?:
2237+
ah|apple|atsc|epub|hp|khtml|moz
2238+
| ms|o|rim|ro|tc|wap|webkit|xv
2239+
)
2240+
| (?:
2241+
mso|prince
2242+
)
2243+
)
2244+
-[a-z-]+
2245+
)
2246+
)
21992247
)
2200-
)
2201-
'''
2202-
'end': '''(?xi)
2203-
# Selector match ends with one of the following:
2204-
(?=
2205-
\\s # Whitespace
2206-
| \\/\\* # Comment
2207-
| , # Comma
2208-
| { # Opening property list brace
2209-
| $ # End of line
2210-
)
2211-
'''
2212-
'patterns': [
2213-
{
2214-
'include': '#selector'
2248+
'''
2249+
'end': '''(?xi)
2250+
# Selector match ends with one of the following:
2251+
(?=
2252+
\\s # Whitespace
2253+
| \\/\\* # Comment
2254+
| , # Comma
2255+
| { # Opening property list brace
2256+
| $ # End of line
2257+
)
2258+
'''
2259+
'patterns': [
2260+
{
2261+
'include': '#selector'
2262+
}
2263+
]
22152264
}
22162265
]
22172266
'string':

syntaxes/css.tmLanguage.json

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1812,11 +1812,24 @@
18121812
]
18131813
},
18141814
"shared-names": {
1815-
"begin": "(?xi)\n# Selector match must be preceded by one of the following:\n(?<=\n ^ # Start of line\n | (^|[^\\:])\\s # Whitespace, after the start of a line or any character except a colon\n | [{}] # Opening or closing brace (condensed property list syntax)\n | \\*/ # Comment end\n | \\\\(?:[0-9a-fA-F]{1,6}|.) # Escape sequence\n)\n\n(?=\n # Selector must match:\n (?:\n # HTML elements\n content|font|header|image|label|mark|marquee|mask|nav|ruby|shadow|span|style\n # SVG elements\n |color-profile|cursor|filter|line|text\n )\n\n # Selector must NOT be followed by any any of the following:\n (?!\n .*; # Any characters followed by a semicolon (denotes a property)\n | .*} # Any characters followed by a closing bracket (denotes a property)\n | - # A dash (denotes a property name)\n # | \\s*\\: # A colon, unless it's with one of the following:\n # (?!\n # # A opening bracket before an closing bracket\n # [^}]*{\n # # A pseudo-class selectors\n # | active|any-link|checked|disabled|empty|enabled|first\n # | (?:first|last|only)-(?:child|of-type)|focus|focus-visible|focus-within|fullscreen|host|hover\n # | in-range|indeterminate|invalid|link|out-of-range\n # | read-only|read-write|required|root|scope|target|unresolved\n # | valid|visited\n\n # # A functional pseudo-class selectors\n # | (?: dir|lang\n # | not|has|matches|where|is\n # | nth-(?:last-)?(?:child|of-type)\n # )\\(\n\n # # A single-colon pseudo-element selectors\n # | after\n # | before\n # | first-letter\n # | first-line\n # | (?:\n # \\-\n # (?:\n # ah|apple|atsc|epub|hp|khtml|moz\n # | ms|o|rim|ro|tc|wap|webkit|xv\n # )\n # | (?:\n # mso|prince\n # )\n # )\n # -[a-z-]+\n # )\n )\n)",
1816-
"end": "(?xi)\n# Selector match ends with one of the following:\n(?=\n \\s # Whitespace\n | \\/\\* # Comment\n | , # Comma\n | { # Opening property list brace\n | $ # End of line\n)",
18171815
"patterns": [
18181816
{
1819-
"include": "#selector"
1817+
"begin": "(?xi)\n# Selector match must be preceded by one of the following:\n(?<=\n ^ # Start of line\n | (^|[^\\:])\\s # Whitespace, after the start of a line or any character except a colon\n | [{}] # Opening or closing brace (condensed property list syntax)\n | \\*/ # Comment end\n | \\\\(?:[0-9a-fA-F]{1,6}|.) # Escape sequence\n)\n\n(?=\n # Selector must match:\n (?:\n # HTML elements\n header|image|label|marquee|mask|nav|ruby|shadow|span|style\n # SVG elements\n |color-profile|line|text\n )\n\n # Selector must NOT be followed by any any of the following:\n (?!\n .*; # Any characters followed by a semicolon (denotes a property)\n | [^{]*} # Any characters, except an opening brace, followed by a closing bracket (denotes a property)\n | - # A dash (denotes a property name)\n )\n)",
1818+
"end": "(?xi)\n# Selector match ends with one of the following:\n(?=\n \\s # Whitespace\n | \\/\\* # Comment\n | , # Comma\n | { # Opening property list brace\n | $ # End of line\n)",
1819+
"patterns": [
1820+
{
1821+
"include": "#selector"
1822+
}
1823+
]
1824+
},
1825+
{
1826+
"begin": "(?xi)\n# Selector match must be preceded by one of the following:\n(?<=\n ^ # Start of line\n | (^|[^\\:])\\s # Whitespace, after the start of a line or any character except a colon\n | [{}] # Opening or closing brace (condensed property list syntax)\n | \\*/ # Comment end\n | \\\\(?:[0-9a-fA-F]{1,6}|.) # Escape sequence\n)\n\n(?=\n # Selector must match:\n (?:\n # HTML elements\n content|font|mark\n # SVG elements\n |cursor|filter\n )\n\n # Selector must NOT be followed by any any of the following:\n (?!\n .*; # Any characters followed by a semicolon (denotes a property)\n | [^{]*} # Any characters, except an opening brace, followed by a closing bracket (denotes a property)\n | - # A dash (denotes a property name)\n | \\: # A colon, unless it's with one of the following:\n (?!\n # A opening bracket before an closing bracket\n [^}]*{\n # A pseudo-class selectors\n | active|any-link|checked|disabled|empty|enabled|first\n | (?:first|last|only)-(?:child|of-type)|focus|focus-visible|focus-within|fullscreen|host|hover\n | in-range|indeterminate|invalid|link|out-of-range\n | read-only|read-write|required|root|scope|target|unresolved\n | valid|visited\n\n # A functional pseudo-class selectors\n | (?: dir|lang\n | not|has|matches|where|is\n | nth-(?:last-)?(?:child|of-type)\n )\\(\n\n # A single-colon pseudo-element selectors\n | after\n | before\n | first-letter\n | first-line\n | (?:\n \\-\n (?:\n ah|apple|atsc|epub|hp|khtml|moz\n | ms|o|rim|ro|tc|wap|webkit|xv\n )\n | (?:\n mso|prince\n )\n )\n -[a-z-]+\n )\n )\n)",
1827+
"end": "(?xi)\n# Selector match ends with one of the following:\n(?=\n \\s # Whitespace\n | \\/\\* # Comment\n | , # Comma\n | { # Opening property list brace\n | $ # End of line\n)",
1828+
"patterns": [
1829+
{
1830+
"include": "#selector"
1831+
}
1832+
]
18201833
}
18211834
]
18221835
},

0 commit comments

Comments
 (0)