cmur2 / language-terraform

Terraform.io support for Atom
MIT License
49 stars 32 forks source link

Escaping double quotes #30

Open jsonmaur opened 7 years ago

jsonmaur commented 7 years ago

It breaks the formatting when escaping double quotes in a string, and the string has a "/*" in it. The resource I'm running into the formatting problem with is a CloudWatch metric filter:

resource "aws_cloudwatch_log_metric_filter" "metric-name" {
  name = "MetricName"
  pattern = "{ $.key = \"value/*\" }"
  log_group_name = "${aws_cloudwatch_log_group.main.name}"
  metric_transformation {
    name = "metricName"
    namespace = "metricNamespace"
    value = 1
  }
}

Looks like it may be a bigger formatting problem with HCL, since the GitHub markdown syntax highlighting has the same problem. Nevertheless, this is a valid metric filter pattern for AWS. And if you try to escape the * to fix the formatting, you get the error illegal char escape from Terraform.

eedwards-sk commented 6 years ago

The issue here is that you're using what is recognized as multi-line comment formatting /* comment */

Since there's no ending */ to finish the 'comment', the rest of your text is formatted as multi-line comments.

Maybe a fix would be to only match the multi-line comment syntax if it starts the line?

software-opal commented 4 years ago

I don't think that reading is correct:

The rendering of:

"[\"prometheus\"]"

is Screenshot 2019-12-13 at 1 17 00 PM.

drmaciej commented 2 years ago

has anyone stumbled upon any workarounds? I'm seeing the same now - I'm escaping a double quote: "\"", and everything after that is rendered in green, as if it was a string.