Skip to content

Heredoc broken when using injected bash grammar with indentation #288

@cloud303-pdavis

Description

@cloud303-pdavis

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions