Skip to content

Commit

Permalink
fix: update highlight terraform code
Browse files Browse the repository at this point in the history
  • Loading branch information
yilanboy committed Dec 26, 2024
1 parent 84008b8 commit d4a5f64
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions resources/ts/highlight-terraform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function (hljs: HLJSApi) {
'locals',
'module',
'data',
'terraform|10',
'terraform',
'for',
'in',
'if',
Expand Down Expand Up @@ -38,21 +38,27 @@ export default function (hljs: HLJSApi) {
scope: 'variable',
begin: /\${/,
end: /}/,
relevance: 9,
},
],
relevance: 10,
};

const PARAMETER = {
scope: 'variable',
const ATTRIBUTE = {
scope: 'attr',
match: /\n\s*[a-zA-Z0-9_]+\s*(?==)/,
};

const BLOCK_PARAMETER = {
const BLOCK_ATTRIBUTE = {
scope: 'keyword',
match: /\n\s*[a-zA-Z0-9_]+\s*(?={)/,
};

const PARAMETER = {
scope: 'params',
begin: /(?<==\s)(?!true\b|false\b|null\b)(\[.*?]|[\w.]+)/,
relevance: 10,
};

const FUNCTION = {
scope: 'title.function',
match: /[a-zA-Z0-9_]+(?=\()/,
Expand Down Expand Up @@ -91,8 +97,9 @@ export default function (hljs: HLJSApi) {
hljs.COMMENT(/#/, /$/),
NUMBERS,
STRINGS,
ATTRIBUTE,
BLOCK_ATTRIBUTE,
PARAMETER,
BLOCK_PARAMETER,
FUNCTION,
EQUALS,
LEFT_BRACE,
Expand Down

0 comments on commit d4a5f64

Please sign in to comment.