Skip to content

Commit 931824b

Browse files
committed
Introduce url_expression
1 parent dda5cfc commit 931824b

File tree

6 files changed

+9429
-8082
lines changed

6 files changed

+9429
-8082
lines changed

grammar.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export default grammar({
6868
namespace_statement: $ => seq(
6969
'@namespace',
7070
optional(alias($.identifier, $.namespace_name)),
71-
choice($.string_value, $.call_expression),
71+
choice($.string_value, $.url_expression),
7272
';',
7373
),
7474

@@ -377,6 +377,7 @@ export default grammar({
377377
$.binary_expression,
378378
$.parenthesized_value,
379379
$.call_expression,
380+
$.url_expression,
380381
$.important,
381382
)),
382383

@@ -461,6 +462,16 @@ export default grammar({
461462
')',
462463
),
463464

465+
url_expression: $ => seq(
466+
/[uU][rR][lL]/, '(',
467+
field('value', choice(
468+
$.plain_url,
469+
$.plain_value,
470+
$.string_value,
471+
)),
472+
')'
473+
),
474+
464475
class_name: $ => seq(
465476
choice($.identifier, $.escape_sequence),
466477
repeat(choice(
@@ -493,6 +504,12 @@ export default grammar({
493504
)),
494505
)),
495506

507+
plain_url: _ => token(
508+
// Regex derived from https://www.w3.org/TR/CSS2/grammar.html
509+
// TODO: add support for non-ASCII characters also allowed by the specs
510+
/([!#$%&*-~]|\\[^\r\n\f0-9a-f])+/
511+
),
512+
496513
important_value: _ => token(seq(
497514
'!',
498515
/[a-zA-Z]/,

src/grammar.json

Lines changed: 50 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/node-types.json

Lines changed: 71 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)