Skip to content

Heredoc broken when using injected bash grammar with indentation #288

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

Open
cloud303-pdavis opened this issue Mar 12, 2025 · 0 comments
Open

Comments

@cloud303-pdavis
Copy link

cloud303-pdavis commented Mar 12, 2025

The base bash highlighting "breaks" if there is a space before the closing heredoc tag

thing=foobar

cat <<EOF >/tmp/foobar
thing = ${thing}
 EOF  # breaks with a space here

echo "done"

Now this is correct from the perspective of a regular bash script, but if the bash grammar is embedded within another grammar with a leading indent (like a block of code in a yaml document) it breaks the highlighting

mything:
  UserData: 
    Fn::Base64:|
      thing=foobar
    
      cat <<EOF >/tmp/foobar
      thing = ${thing}
      EOF

      echo "done"

I am using this to inject the grammar

; extends

(block_mapping_pair
  key: (flow_node) @_run
  (#any-of? @_run "UserData")
  value: (block_node
		   (block_mapping
			 (block_mapping_pair
			   key: (flow_node)
			   value: (block_node
						(block_scalar) @injection.content
						(#set! injection.language "bash"))))))

I'm not sure if there is a way even a way around this though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant