Skip to content

Commit

Permalink
Add support for output modifiers for tags
Browse files Browse the repository at this point in the history
  • Loading branch information
kolen committed Feb 14, 2024
1 parent f4b5381 commit fe36cfc
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
1 change: 1 addition & 0 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ module.exports = grammar({
)
),
optional(field('attrs', $.attrs)),
optional($._output_modifiers),
choice(
$._inline,
seq(
Expand Down
12 changes: 12 additions & 0 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,18 @@
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_output_modifiers"
},
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [
Expand Down
14 changes: 13 additions & 1 deletion src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
}
},
"children": {
"multiple": false,
"multiple": true,
"required": false,
"types": [
{
Expand All @@ -171,6 +171,18 @@
{
"type": "nested_inline",
"named": true
},
{
"type": "output_modifier_leading_whitespace",
"named": true
},
{
"type": "output_modifier_legacy_trailing_whitespace",
"named": true
},
{
"type": "output_modifier_trailing_whitespace",
"named": true
}
]
}
Expand Down
31 changes: 31 additions & 0 deletions test/corpus/tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
============================
Tag and shortcut css classes
============================

span.menu.active

---

(source_file
(element
(tag_name)
(attr_shortcuts
(shortcut_class
(css_identifier))
(shortcut_class
(css_identifier)))))

===============================
Tag with traling space modifier
===============================

.menu<

---

(source_file
(element
(attr_shortcuts
(shortcut_class
(css_identifier)))
(output_modifier_leading_whitespace)))

0 comments on commit fe36cfc

Please sign in to comment.