Skip to content

Commit 99d4cf0

Browse files
committed
fix: Parse complex quoted attributes
1 parent 7387dc5 commit 99d4cf0

File tree

6 files changed

+11191
-10657
lines changed

6 files changed

+11191
-10657
lines changed

grammar.js

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,10 +399,44 @@ module.exports = grammar(HTML, {
399399

400400
binding_name: ($) => seq(choice($.identifier, $.member_expression)),
401401

402+
_attribute_node: ($) =>
403+
choice(
404+
repeat(choice(token.immediate(/[^"]/), $._escape_sequence)),
405+
prec(1, $.interpolation),
406+
),
407+
402408
_normal_attribute: ($) =>
403409
seq(
404410
$.attribute_name,
405-
optional(seq('=', choice($.attribute_value, $.quoted_attribute_value))),
411+
optional(
412+
seq(
413+
'=',
414+
choice(
415+
seq(
416+
$._double_quote,
417+
repeat(
418+
choice(
419+
alias(token.immediate(/[^"{]+/), $.string_content),
420+
$._escape_sequence,
421+
$.interpolation,
422+
),
423+
),
424+
$._double_quote,
425+
),
426+
seq(
427+
$._single_quote,
428+
repeat(
429+
choice(
430+
alias(token.immediate(/[^'{]+/), $.string_content),
431+
$._escape_sequence,
432+
$.interpolation,
433+
),
434+
),
435+
$._single_quote,
436+
),
437+
),
438+
),
439+
),
406440
),
407441

408442
// ---------- Expressions ---------

src/grammar.json

Lines changed: 110 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/node-types.json

Lines changed: 7 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)