Skip to content

Commit

Permalink
Outlaw Svelte expressions/blocks in attribute values…
Browse files Browse the repository at this point in the history
…because they're not allowed and I can't read.
  • Loading branch information
savetheclocktower committed Jul 20, 2024
1 parent 8789125 commit a31cf14
Show file tree
Hide file tree
Showing 5 changed files with 4,705 additions and 10,174 deletions.
24 changes: 7 additions & 17 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,18 @@ module.exports = grammar(HTML, {
_node: ($, original) => choice(
original,

$._svelte_statement,
$.expression,
$._svelte_expression,
),

_svelte_statement: $ => choice(
$.if_statement,
$.each_statement,
$.await_statement,
$.key_statement,
$.snippet_statement,

$.expression,

$.html_tag,
$.const_tag,
$.debug_tag,
$.render_tag,
),

_single_quoted_attribute_value: $ => repeat1(
Expand All @@ -72,8 +73,6 @@ module.exports = grammar(HTML, {
/[^\\{']+/,
// …or an expression.
$.expression,
$._svelte_expression,
$._svelte_statement,
),
),

Expand All @@ -85,8 +84,6 @@ module.exports = grammar(HTML, {
/[^\\{"]+/,
// …or an expression.
$.expression,
$._svelte_expression,
$._svelte_statement,
),
),

Expand Down Expand Up @@ -261,13 +258,6 @@ module.exports = grammar(HTML, {

expression: $ => seq('{', $.svelte_raw_text, '}'),

_svelte_expression: $ => choice(
$.html_tag,
$.const_tag,
$.debug_tag,
$.render_tag,
),

_tag_value: $ => seq(/\s+/, $.svelte_raw_text),

_html_tag: $ => tag('@', 'html', $),
Expand Down
94 changes: 30 additions & 64 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 0 additions & 36 deletions src/node-types.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a31cf14

Please sign in to comment.