From fe36cfc2e7998c46442253c6f278ee33109f97ea Mon Sep 17 00:00:00 2001 From: kolen Date: Thu, 15 Feb 2024 01:09:49 +0300 Subject: [PATCH] Add support for output modifiers for tags --- grammar.js | 1 + src/grammar.json | 12 ++++++++++++ src/node-types.json | 14 +++++++++++++- test/corpus/tags.txt | 31 +++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 test/corpus/tags.txt diff --git a/grammar.js b/grammar.js index 720f1ac..f18337d 100644 --- a/grammar.js +++ b/grammar.js @@ -79,6 +79,7 @@ module.exports = grammar({ ) ), optional(field('attrs', $.attrs)), + optional($._output_modifiers), choice( $._inline, seq( diff --git a/src/grammar.json b/src/grammar.json index bf28aad..f5913ba 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -182,6 +182,18 @@ } ] }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "_output_modifiers" + }, + { + "type": "BLANK" + } + ] + }, { "type": "CHOICE", "members": [ diff --git a/src/node-types.json b/src/node-types.json index a3a94aa..ccb3bf9 100644 --- a/src/node-types.json +++ b/src/node-types.json @@ -157,7 +157,7 @@ } }, "children": { - "multiple": false, + "multiple": true, "required": false, "types": [ { @@ -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 } ] } diff --git a/test/corpus/tags.txt b/test/corpus/tags.txt new file mode 100644 index 0000000..e22dec6 --- /dev/null +++ b/test/corpus/tags.txt @@ -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)))