From 9ff82dc448ea04eee482db954aa70cc2e35e1d2f Mon Sep 17 00:00:00 2001 From: este36 Date: Tue, 12 Nov 2024 16:00:15 +0100 Subject: [PATCH] added rest param to tag() and modified _else_if_tag accordingly --- grammar.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/grammar.js b/grammar.js index f9a3ca0..298c6f6 100644 --- a/grammar.js +++ b/grammar.js @@ -138,14 +138,10 @@ module.exports = grammar(HTML, { '}', ), - // Since 'else' and 'if' are separated by space, we cannot put them in a simple tag() like $._else_tag or $._if_start_tag - else_if_tag: $ => seq( - tag(':', 'else'), - field('tag', 'if'), - ), + _else_if_tag: _ => tag(':', 'else', 'if'), else_if_start: $ => seq( '{', - alias($.else_if_tag, $.block_tag), + alias($._else_if_tag, $.block_tag), field('condition', $.svelte_raw_text), '}', ), @@ -312,11 +308,13 @@ module.exports = grammar(HTML, { /** * @param {string} sym * @param {string} text + * @rest param {string} ...other * @return {SeqRule} */ -function tag(sym, text) { +function tag(sym, text, ...other) { return seq( sym, field('tag', token.immediate(text)), + ...other.map(rule => field('tag', rule)), ); }