Skip to content

Commit

Permalink
remove one item array and fix capturing group unused
Browse files Browse the repository at this point in the history
Signed-off-by: Outsider <outsideris@gmail.com>
  • Loading branch information
outsideris committed Dec 18, 2018
1 parent 803f817 commit 5406c69
Showing 1 changed file with 28 additions and 38 deletions.
66 changes: 28 additions & 38 deletions components/prism-hcl.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,62 +4,52 @@ Prism.languages.hcl = {
{
pattern: /(?:resource|data)\s+(?:[\w-]+|"[\w-]+")(?=\s+"[\w-]+"\s+{)/i,
inside: {
'type': [
{
pattern: /(resource|data|\s+)(?:[\w-]+|"[\w-]+")/i,
lookbehind: true,
alias: 'variable'
}
]
'type': {
pattern: /(resource|data|\s+)(?:[\w-]+|"[\w-]+")/i,
lookbehind: true,
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: true,
alias: 'variable'
}
]
'type': {
pattern: /(provider|provisioner|variable|output|module|backend)\s+"?[\w-]+"?\s+/i,
lookbehind: true,
alias: 'variable'
}
}
},
{
pattern: /[\w-]+(?=\s+{)/
}
],
'interpolation': [
{
pattern: /\${(?:[\w[\](+)\-*%^"',?=:/\s\\]+\.?)+}/i,
inside: {
'type': [
{
pattern: /((?:terraform|var|self|count|module|path|data|local)\.)[\w\*]+/i,
lookbehind: true,
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'
}
]
'interpolation': {
pattern: /\${(?:[\w[\](+)\-*%^"',?=:/\s\\]+\.?)+}/i,
inside: {
'type': {
pattern: /((?:terraform|var|self|count|module|path|data|local)\.)[\w\*]+/i,
lookbehind: true,
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,
'boolean': /\b(?:true|false)\b/i,
'punctuation': /[=\[\]{}]/,
};

0 comments on commit 5406c69

Please sign in to comment.