diff --git a/components/prism-hcl.js b/components/prism-hcl.js index f7950f047d..86bacb96fb 100644 --- a/components/prism-hcl.js +++ b/components/prism-hcl.js @@ -1,5 +1,9 @@ Prism.languages.hcl = { 'comment': /(?:\/\/|#).*|\/\*[\s\S]*?(?:\*\/|$)/, + 'heredoc': { + pattern: /<<(\w+)(?:[^\1])*?\1/, + alias: 'string' + }, 'keyword': [ { pattern: /(?:resource|data)\s+(?:[\w-]+|"[\w-]+")(?=\s+"[\w-]+"\s+{)/i, diff --git a/components/prism-hcl.min.js b/components/prism-hcl.min.js index e5abbaf1a7..ba4a95a6e2 100644 --- a/components/prism-hcl.min.js +++ b/components/prism-hcl.min.js @@ -1 +1 @@ -Prism.languages.hcl={comment:/(?:\/\/|#).*|\/\*[\s\S]*?(?:\*\/|$)/,keyword:[{pattern:/(?:resource|data)\s+(?:[\w-]+|"[\w-]+")(?=\s+"[\w-]+"\s+{)/i,inside:{type:{pattern:/(resource|data|\s+)(?:[\w-]+|"[\w-]+")/i,lookbehind:!0,alias:"variable"}}},{pattern:/(?:provider|provisioner|variable|output|module|backend)\s+"?[\w-]+"?\s+(?={)/i,inside:{type:{pattern:/(provider|provisioner|variable|output|module|backend)\s+"?[\w-]+"?\s+/i,lookbehind:!0,alias:"variable"}}},{pattern:/[\w-]+(?=\s+{)/}],interpolation:{pattern:/\${(?:[\w[\](+)\-*%^"',?=:\/\s\\]+\.?)+}/i,inside:{type:{pattern:/((?:terraform|var|self|count|module|path|data|local)\.)[\w\*]+/i,lookbehind:!0,alias:"variable"},keyword:/terraform|var|self|count|module|path|data|local/i,"function":/\w+(?=\()/,string:/"(?:\\[\s\S]|[^\\"])*"/,punctuation:/[!"\$#%&'()*+,.\/;<=>@\[\\\]^`{|}~]/,number:/-?\d+\.?\d*/,others:{pattern:/[\w\*]+/,alias:"string"}}},property:[/[\w-\.]+(?=\s*=)/,/"(?:\\[\s\S]|[^\\"])+"(?=\s*[:=])/],string:/"(?:\\[\s\S]|[^\\"])*"/,number:/0x[\da-f]+|\d+\.?\d*(?:e[+-]?\d+)?/i,"boolean":/\b(?:true|false)\b/i,punctuation:/[=\[\]{}]/}; \ No newline at end of file +Prism.languages.hcl={comment:/(?:\/\/|#).*|\/\*[\s\S]*?(?:\*\/|$)/,heredoc:{pattern:/<<(\w+)(?:[^\1])*?\1/,alias:"string"},keyword:[{pattern:/(?:resource|data)\s+(?:[\w-]+|"[\w-]+")(?=\s+"[\w-]+"\s+{)/i,inside:{type:{pattern:/(resource|data|\s+)(?:[\w-]+|"[\w-]+")/i,lookbehind:!0,alias:"variable"}}},{pattern:/(?:provider|provisioner|variable|output|module|backend)\s+"?[\w-]+"?\s+(?={)/i,inside:{type:{pattern:/(provider|provisioner|variable|output|module|backend)\s+"?[\w-]+"?\s+/i,lookbehind:!0,alias:"variable"}}},{pattern:/[\w-]+(?=\s+{)/}],property:[/[\w-\.]+(?=\s*=(?!=))/,/"(?:\\[\s\S]|[^\\"])+"(?=\s*[:=])/],string:{pattern:/"(?:[^\\$"]|\\[\s\S]|\$(?:(?=")|\$+|[^"${])|\$\{(?:[^{}"]|"(?:[^\\"]|\\[\s\S])*")*\})*"/,inside:{interpolation:{pattern:/(^|[^$])\$\{(?:[^{}"]|"(?:[^\\"]|\\[\s\S])*")*\}/,lookbehind:!0,inside:{type:{pattern:/((?:terraform|var|self|count|module|path|data|local)\.)[\w\*]+/i,lookbehind:!0,alias:"variable"},keyword:/terraform|var|self|count|module|path|data|local/gi,"function":/\w+(?=\()/,string:/"(?:\\[\s\S]|[^\\"])*"/,punctuation:/[!\$#%&'()*+,.\/;<=>@\[\\\]^`{|}~?:]/,number:/-?\d+\.?\d*/}}}},number:/0x[\da-f]+|\d+\.?\d*(?:e[+-]?\d+)?/i,"boolean":/\b(?:true|false)\b/i,punctuation:/[=\[\]{}]/}; \ No newline at end of file diff --git a/tests/languages/hcl/string_feature.test b/tests/languages/hcl/string_feature.test index 4b86b90398..d69f019cb9 100644 --- a/tests/languages/hcl/string_feature.test +++ b/tests/languages/hcl/string_feature.test @@ -1,6 +1,14 @@ "double quoted\"' % string" multiline_literal = "hello world" +foo = <