Skip to content

Commit

Permalink
Fix edge cases where expression includes delimiters
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatanklosko authored and connorlay committed Jan 29, 2025
1 parent a63c69c commit d62e69c
Show file tree
Hide file tree
Showing 6 changed files with 830 additions and 785 deletions.
11 changes: 10 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,16 @@ module.exports = grammar({
),

_expression_value: ($) =>
choice(/[^{}]+/, seq("{", optional($._expression_value), "}")),
// Note that we alias "{" and "}", so they are not targetted by
// delimiter highlight queries.
choice(
/[^{}]+/,
seq(
alias("{", "left"),
repeat($._expression_value),
alias("}", "right")
)
),

special_attribute: ($) => seq($.special_attribute_name, "=", $.expression),

Expand Down
5 changes: 4 additions & 1 deletion queries/injections.scm
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@

; expressions live within HTML tags, and do not need to be combined
; <link href={ Routes.static_path(..) } />
; note that we include children, because expression_value may consist
; of multiple nodes, when the value contains { and }
((expression (expression_value) @injection.content)
(#set! injection.language "elixir"))
(#set! injection.language "elixir")
(#set! injection.include-children))
33 changes: 19 additions & 14 deletions src/grammar.json

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

8 changes: 8 additions & 0 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 d62e69c

Please sign in to comment.