Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CSS] Separate URL token and URL function (fixes #3583) #3584

Merged
merged 1 commit into from
Jul 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 4 additions & 5 deletions css3/css3Lexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ fragment Name
: Nmchar+
;

fragment Url
: ( [!#$%&*-~] | Nonascii | Escape )*
Url
: U R L '(' Whitespace ( [!#$%&*-~] | Nonascii | Escape )* Whitespace ')'
;

Space
Expand Down Expand Up @@ -374,9 +374,8 @@ Percentage
: Number '%'
;

Uri
: U R L '(' Whitespace String_ Whitespace ')'
| U R L '(' Whitespace Url Whitespace ')'
Url_
: 'url('
;

UnicodeRange
Expand Down
23 changes: 15 additions & 8 deletions css3/css3Parser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ charset
;

imports
: Import ws ( String_ | Uri ) ws mediaQueryList ';' ws # goodImport
| Import ws ( String_ | Uri ) ws ';' ws # goodImport
| Import ws ( String_ | Uri ) ws mediaQueryList # badImport
| Import ws ( String_ | Uri ) ws # badImport
: Import ws ( String_ | url ) ws mediaQueryList ';' ws # goodImport
| Import ws ( String_ | url ) ws ';' ws # goodImport
| Import ws ( String_ | url ) ws mediaQueryList # badImport
| Import ws ( String_ | url ) ws # badImport
;

// Namespaces
// https://www.w3.org/TR/css-namespaces-3/
namespace_
: Namespace ws (namespacePrefix ws)? ( String_ | Uri ) ws ';' ws # goodNamespace
| Namespace ws (namespacePrefix ws)? ( String_ | Uri ) ws # badNamespace
: Namespace ws (namespacePrefix ws)? ( String_ | url ) ws ';' ws # goodNamespace
| Namespace ws (namespacePrefix ws)? ( String_ | url ) ws # badNamespace
;

namespacePrefix
Expand Down Expand Up @@ -193,7 +193,7 @@ term
| UnicodeRange ws # knownTerm
| ident ws # knownTerm
| var_ # knownTerm
| Uri ws # knownTerm
| url ws # knownTerm
| hexcolor # knownTerm
| calc # knownTerm
| function_ # knownTerm
Expand Down Expand Up @@ -238,7 +238,7 @@ any_
| unknownDimension ws
| String_ ws
//| Delim ws // Not implemented yet
| Uri ws
| url ws
| Hash ws
| UnicodeRange ws
| Includes ws
Expand Down Expand Up @@ -325,6 +325,13 @@ generalEnclosed
: ( Function_ | '(' ) ( any_ | unused )* ')'
;

// Url
// https://www.w3.org/TR/css3-values/#urls
url
: Url_ ws String_ ws ')'
| Url
;

// Variable
// https://www.w3.org/TR/css-variables-1
var_
Expand Down