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

Terraform lexer does not support HCL heredoc syntax #1909

Closed
offbyone opened this issue Oct 7, 2021 · 4 comments
Closed

Terraform lexer does not support HCL heredoc syntax #1909

offbyone opened this issue Oct 7, 2021 · 4 comments
Labels
A-lexing area: changes to individual lexers good first issue Good for newcomers help wanted Community help appreciated!

Comments

@offbyone
Copy link

offbyone commented Oct 7, 2021

I am using pygments 2.10.0 to highlight a terraform config containing this:

resource "local_file" "tf_ansible_vars_file_new" {
  content  = <<-DOC
    # Ansible vars_file containing variable values from Terraform.
    # Generated by Terraform mgmt configuration.

    iot_credential_provider_endpoint: ${data.aws_iot_endpoint.credentials.endpoint_address}
    iot_credential_role_alias: ${aws_iot_role_alias.cert-dns.alias}
    DOC
  filename = "./vars/tf_ansible_vars_file.yml"
}

What I get out of it is the attached image.
image

@Anteru Anteru added good first issue Good for newcomers help wanted Community help appreciated! A-lexing area: changes to individual lexers labels Oct 7, 2021
@offbyone
Copy link
Author

offbyone commented Oct 8, 2021

If you can point me at an example of heredoc lexing, I'm happy to take a kick at fixing this.

@Anteru
Copy link
Collaborator

Anteru commented Oct 8, 2021

The PowerShell lexer has a "heredoc" lexer, see: https://github.com/pygments/pygments/blob/master/pygments/lexers/shell.py#L721

@offbyone
Copy link
Author

Hm. Those heredocs are quite a bit different; Terraform's are a lot like bash's syntax. I'll see if I can find an example.

offbyone added a commit to offbyone/pygments that referenced this issue Oct 10, 2021
offbyone added a commit to offbyone/pygments that referenced this issue Oct 11, 2021
@Anteru Anteru closed this as completed in 5d69adb Nov 6, 2021
@michaelbrewer
Copy link

Looks like this is not completely closed as Terraform support << format as well see: https://www.terraform.io/language/expressions/strings#heredoc-strings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lexing area: changes to individual lexers good first issue Good for newcomers help wanted Community help appreciated!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants