From 5406c6910b59c32adb24c6d815de16c313135cab Mon Sep 17 00:00:00 2001 From: Outsider Date: Wed, 19 Dec 2018 00:36:56 +0900 Subject: [PATCH] remove one item array and fix capturing group unused Signed-off-by: Outsider --- components/prism-hcl.js | 66 +++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 38 deletions(-) diff --git a/components/prism-hcl.js b/components/prism-hcl.js index 0b3921ffd0..0232a1e15b 100644 --- a/components/prism-hcl.js +++ b/components/prism-hcl.js @@ -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': /[=\[\]{}]/, };