Allow more characters in unquoted property values

This commit is contained in:
Max Brunsfeld 2018-10-26 11:41:14 -07:00
parent a61bc61c74
commit b2c8e4a547
6 changed files with 1977 additions and 1663 deletions

View File

@ -95,3 +95,19 @@ a {
(block (block
(declaration (property_name) (string_value)) (declaration (property_name) (string_value))
(declaration (property_name) (string_value))))) (declaration (property_name) (string_value)))))
============================
URLs
============================
a {
b: http://something-else?foo=bar;
}
---
(stylesheet
(rule_set
(selectors (tag_name))
(block
(declaration (property_name) (plain_value)))))

View File

@ -67,8 +67,8 @@ a[b] {}
(stylesheet (stylesheet
(rule_set (selectors (attribute_selector (attribute_name))) (block)) (rule_set (selectors (attribute_selector (attribute_name))) (block))
(rule_set (selectors (attribute_selector (attribute_name) (keyword_value))) (block)) (rule_set (selectors (attribute_selector (attribute_name) (plain_value))) (block))
(rule_set (selectors (attribute_selector (attribute_name) (keyword_value))) (block)) (rule_set (selectors (attribute_selector (attribute_name) (plain_value))) (block))
(rule_set (selectors (attribute_selector (tag_name) (attribute_name))) (block))) (rule_set (selectors (attribute_selector (tag_name) (attribute_name))) (block)))
========================= =========================

View File

@ -33,11 +33,11 @@ Media statements
(binary_query (binary_query
(keyword_query) (keyword_query)
(feature_query (feature_name) (integer_value (unit)))) (feature_query (feature_name) (integer_value (unit))))
(feature_query (feature_name) (keyword_value))) (feature_query (feature_name) (plain_value)))
(block)) (block))
(media_statement (media_statement
(feature_query (feature_name) (integer_value (unit))) (feature_query (feature_name) (integer_value (unit)))
(binary_query (keyword_query) (feature_query (feature_name) (keyword_value))) (binary_query (keyword_query) (feature_query (feature_name) (plain_value)))
(block)) (block))
(media_statement (media_statement
(binary_query (negated_query (keyword_query)) (parenthesized_query (keyword_query))) (binary_query (negated_query (keyword_query)) (parenthesized_query (keyword_query)))

View File

@ -180,7 +180,8 @@ module.exports = grammar({
// Property Values // Property Values
_value: $ => choice( _value: $ => choice(
alias($.identifier, $.keyword_value), alias($.identifier, $.plain_value),
$.plain_value,
$.color_value, $.color_value,
$.integer_value, $.integer_value,
$.float_value, $.float_value,
@ -238,6 +239,8 @@ module.exports = grammar({
identifier: $ => /[a-zA-Z-_][a-zA-Z0-9-_]*/, identifier: $ => /[a-zA-Z-_][a-zA-Z0-9-_]*/,
plain_value: $ => /[a-zA-Z-_][^;()\[\]\s]*/,
at_keyword: $ => /@[a-zA-Z-_]+/, at_keyword: $ => /@[a-zA-Z-_]+/,
comment: $ => token(choice( comment: $ => token(choice(

10
src/grammar.json vendored
View File

@ -768,7 +768,11 @@
"name": "identifier" "name": "identifier"
}, },
"named": true, "named": true,
"value": "keyword_value" "value": "plain_value"
},
{
"type": "SYMBOL",
"name": "plain_value"
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
@ -1134,6 +1138,10 @@
"type": "PATTERN", "type": "PATTERN",
"value": "[a-zA-Z-_][a-zA-Z0-9-_]*" "value": "[a-zA-Z-_][a-zA-Z0-9-_]*"
}, },
"plain_value": {
"type": "PATTERN",
"value": "[a-zA-Z-_][^;()\\[\\]\\s]*"
},
"at_keyword": { "at_keyword": {
"type": "PATTERN", "type": "PATTERN",
"value": "@[a-zA-Z-_]+" "value": "@[a-zA-Z-_]+"

3601
src/parser.c vendored

File diff suppressed because it is too large Load Diff