diff --git a/grammar.js b/grammar.js index 7c5cd63..2787a1e 100644 --- a/grammar.js +++ b/grammar.js @@ -156,7 +156,7 @@ module.exports = grammar({ ), ), attr_name: $ => $._attr_name, - _attr_name: $ => /[a-zA-Z0-9_-]+/, // TODO: very wrong + _attr_name: $ => token(prec(-2, /[^ \t\n\\0\"\'> /[ \t]*=[ \t]*/, attr_assignment_noescape: $ => /[ \t]*==[ \t]*/, attr_value: $ => choice( @@ -176,7 +176,7 @@ module.exports = grammar({ optional($._text_nested) ), - _element_rest_text: $ => token(prec(-2, /[^ \t][^\n]*/)), + _element_rest_text: $ => token(prec(-3, /[^ \t][^\n]*/)), // From css grammar https://github.com/tree-sitter/tree-sitter-css/blob/master/grammar.js // Originally: /\A(#{keys}+)((?:\p{Word}|-|\/\d+|:(\w|-)+)*)/ diff --git a/src/grammar.json b/src/grammar.json index cce6224..29128f9 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -914,8 +914,15 @@ "name": "_attr_name" }, "_attr_name": { - "type": "PATTERN", - "value": "[a-zA-Z0-9_-]+" + "type": "TOKEN", + "content": { + "type": "PREC", + "value": -2, + "content": { + "type": "PATTERN", + "value": "[^ \\t\\n\\\\0\\\"\\'>