Skip to content

Commit

Permalink
Fix order of output modifiers and attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
kolen committed Feb 16, 2024
1 parent 7f51d8c commit 3591c61
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 9 deletions.
2 changes: 1 addition & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ module.exports = grammar({
field('attr_shortcuts', $.attr_shortcuts),
)
),
optional(field('attrs', $.attrs)),
optional($._output_modifiers),
optional(field('attrs', $.attrs)),
choice(
$._inline,
seq(
Expand Down
16 changes: 8 additions & 8 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,8 @@
"type": "CHOICE",
"members": [
{
"type": "FIELD",
"name": "attrs",
"content": {
"type": "SYMBOL",
"name": "attrs"
}
"type": "SYMBOL",
"name": "_output_modifiers"
},
{
"type": "BLANK"
Expand All @@ -186,8 +182,12 @@
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_output_modifiers"
"type": "FIELD",
"name": "attrs",
"content": {
"type": "SYMBOL",
"name": "attrs"
}
},
{
"type": "BLANK"
Expand Down
36 changes: 36 additions & 0 deletions test/corpus/tags.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,42 @@ Tag with space before traling space modifier
(css_identifier)))
(element_text)))

=====================================================
Trailing space modifier with non-delimited attributes
=====================================================

a< title="example"

----

(source_file
(element
(tag_name)
(output_modifier_leading_whitespace)
(attrs
(attr
(attr_name)
(attr_assignment)
(attr_value)))))

===============================================================
Trailing space modifier with delimited attributes without space
===============================================================

a<[title="example"]

----

(source_file
(element
(tag_name)
(output_modifier_leading_whitespace)
(attrs
(attr
(attr_name)
(attr_assignment)
(attr_value)))))

=============================
Extension attribute shortcuts
=============================
Expand Down

0 comments on commit 3591c61

Please sign in to comment.