diff --git a/lib/rouge/lexers/terraform.rb b/lib/rouge/lexers/terraform.rb index f540ec2d17..8b9545552f 100644 --- a/lib/rouge/lexers/terraform.rb +++ b/lib/rouge/lexers/terraform.rb @@ -81,9 +81,24 @@ def self.builtins mixin :expression end + state :regexps do + rule %r/"\// do + token Str::Delimiter + goto :regexp_inner + end + end + + state :regexp_inner do + rule %r/[^"\/\\]+/, Str::Regex + rule %r/\\./, Str::Regex + rule %r/\/"/, Str::Delimiter, :pop! + rule %r/["\/]/, Str::Regex + end + id = /[$a-z_\-][a-z0-9_\-]*/io state :expression do + mixin :regexps mixin :primitives rule %r/\s+/, Text diff --git a/spec/visual/samples/terraform b/spec/visual/samples/terraform index cc5791b203..511d04be87 100644 --- a/spec/visual/samples/terraform +++ b/spec/visual/samples/terraform @@ -79,3 +79,8 @@ resource "aws_subnet" "main" { vpc_id = aws_vpc.main.id fqns = aws_route53_record.cert_validation[*].fqdn } + +## Object with regular expression +resource "aws_cloudfront_distribution" "s3_distribution" { + aliases = ["www.${replace(var.domain_name, "/\\.$/", "")}"] +}