Skip to content

Commit

Permalink
support heredoc
Browse files Browse the repository at this point in the history
Signed-off-by: Outsider <outsideris@gmail.com>
  • Loading branch information
outsideris committed Dec 25, 2018
1 parent 8022bed commit c05d498
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions 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,
Expand Down
2 changes: 1 addition & 1 deletion components/prism-hcl.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion tests/languages/hcl/string_feature.test
@@ -1,14 +1,28 @@
"double quoted\"' % string"
multiline_literal = "hello
world"
foo = <<EOF
bar
baz
EOF
bar = <<EOF_TEXT
bar
"baz"
EOF_TEXT

----------------------------------------------------

[
["string", ["\"double quoted\\\"' % string\""]],
["property", "multiline_literal"],
["punctuation", "="],
["string", ["\"hello\r\n world\""]]
["string", ["\"hello\r\n world\""]],
["property", "foo"],
["punctuation", "="],
["heredoc", "<<EOF\r\n bar\r\n baz\r\n EOF"],
["property", "bar"],
["punctuation", "="],
["heredoc", "<<EOF_TEXT\r\n bar\r\n \"baz\"\r\n EOF_TEXT"]
]

----------------------------------------------------
Expand Down

0 comments on commit c05d498

Please sign in to comment.