Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix edge cases where expression includes delimiters #50

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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