Skip to content

Commit c1dce99

Browse files
authored
Added Bicep support (#3027)
1 parent e289ec6 commit c1dce99

13 files changed

+360
-1
lines changed

components.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@
184184
},
185185
"owner": "RunDevelopment"
186186
},
187+
"bicep": {
188+
"title": "Bicep",
189+
"owner": "johnnyreilly"
190+
},
187191
"birb": {
188192
"title": "Birb",
189193
"require": "clike",

components/prism-bicep.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// based loosely upon: https://github.com/Azure/bicep/blob/main/src/textmate/bicep.tmlanguage
2+
Prism.languages.bicep = {
3+
'comment': [
4+
{
5+
// multiline comments eg /* ASDF */
6+
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
7+
lookbehind: true,
8+
greedy: true
9+
},
10+
{
11+
// singleline comments eg // ASDF
12+
pattern: /(^|[^\\:])\/\/.*/,
13+
lookbehind: true,
14+
greedy: true
15+
}
16+
],
17+
'string': {
18+
// this doesn't handle string interpolalation or multiline strings as yet
19+
pattern: /'(?:\\.|[^'\\\r\n])*'/,
20+
greedy: true
21+
},
22+
'number': /(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:E[+-]?\d+)?/i,
23+
'boolean': /\b(?:true|false)\b/,
24+
'keyword': /\b(?:targetScope|resource|module|param|var|output|for|in|if|existing|null)\b/, // https://github.com/Azure/bicep/blob/114a3251b4e6e30082a58729f19a8cc4e374ffa6/src/textmate/bicep.tmlanguage#L184
25+
'function': /\b(?:array|concat|contains|createArray|empty|first|intersection|last|length|max|min|range|skip|take|union)(?:\$|\b)/, // https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/template-functions-array
26+
'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/,
27+
'punctuation': /[{}[\];(),.:]/,
28+
'decorator': /@\w+\b/
29+
};

components/prism-bicep.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/prism-bicep.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<h2>Variable assignment</h2>
2+
<pre><code>var foo = 'bar'</code></pre>
3+
4+
<h2>Operators</h2>
5+
<pre><code>(1 + 2 * 3)/4 >= 3 &amp;&amp; 4 &lt; 5 || 6 > 7</code></pre>
6+
7+
<h2>Keywords</h2>
8+
<pre><code>resource appServicePlan 'Microsoft.Web/serverfarms@2020-09-01' existing = = if (diagnosticsEnabled) {
9+
name: logAnalyticsWsName
10+
}
11+
module cosmosDb './cosmosdb.bicep' = {
12+
name: 'cosmosDbDeploy'
13+
}
14+
param env string
15+
var oneNumber = 123
16+
output databaseName string = cosmosdbDatabaseName
17+
for item in cosmosdbAllowedIpAddresses: {
18+
ipAddressOrRange: item
19+
}</code></pre>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
true
2+
false
3+
4+
----------------------------------------------------
5+
6+
[
7+
["boolean", "true"],
8+
["boolean", "false"]
9+
]
10+
11+
----------------------------------------------------
12+
13+
Checks for booleans.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@secure()
2+
param demoPassword string
3+
@allowed([
4+
'one'
5+
'two'
6+
])
7+
param demoEnum string
8+
9+
----------------------------------------------------
10+
11+
[
12+
["decorator", "@secure"], ["punctuation", "("], ["punctuation", ")"],
13+
["keyword", "param"], " demoPassword string\r\n",
14+
["decorator", "@allowed"], ["punctuation", "("], ["punctuation", "["],
15+
["string", "'one'"],
16+
["string", "'two'"],
17+
["punctuation", "]"], ["punctuation", ")"],
18+
["keyword", "param"], " demoEnum string"
19+
]
20+
21+
----------------------------------------------------
22+
23+
Checks for functions. Also checks for unicode characters in identifiers.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
array
2+
concat
3+
contains
4+
createArray
5+
empty
6+
first
7+
intersection
8+
last
9+
length
10+
max
11+
min
12+
range
13+
skip
14+
take
15+
union
16+
17+
----------------------------------------------------
18+
19+
[
20+
["function", "array"],
21+
["function", "concat"],
22+
["function", "contains"],
23+
["function", "createArray"],
24+
["function", "empty"],
25+
["function", "first"],
26+
["function", "intersection"],
27+
["function", "last"],
28+
["function", "length"],
29+
["function", "max"],
30+
["function", "min"],
31+
["function", "range"],
32+
["function", "skip"],
33+
["function", "take"],
34+
["function", "union"]
35+
]
36+
37+
----------------------------------------------------
38+
39+
Checks for functions. Based upon https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/template-functions-array
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
targetScope
2+
resource appServicePlan 'Microsoft.Web/serverfarms@2020-09-01' existing = = if (diagnosticsEnabled) {
3+
name: logAnalyticsWsName
4+
}
5+
module cosmosDb './cosmosdb.bicep' = {
6+
name: 'cosmosDbDeploy'
7+
}
8+
param env string
9+
var oneNumber = 123
10+
output databaseName string = cosmosdbDatabaseName
11+
for item in cosmosdbAllowedIpAddresses: {
12+
ipAddressOrRange: item
13+
}
14+
if
15+
null
16+
17+
----------------------------------------------------
18+
19+
[
20+
["keyword", "targetScope"],
21+
22+
["keyword", "resource"],
23+
" appServicePlan ",
24+
["string", "'Microsoft.Web/serverfarms@2020-09-01'"],
25+
["keyword", "existing"],
26+
["operator", "="],
27+
["operator", "="],
28+
["keyword", "if"],
29+
["punctuation", "("],
30+
"diagnosticsEnabled",
31+
["punctuation", ")"],
32+
["punctuation", "{"],
33+
34+
"\r\n name",
35+
["operator", ":"],
36+
" logAnalyticsWsName\r\n",
37+
38+
["punctuation", "}"],
39+
40+
["keyword", "module"],
41+
" cosmosDb ",
42+
["string", "'./cosmosdb.bicep'"],
43+
["operator", "="],
44+
["punctuation", "{"],
45+
46+
"\r\n name",
47+
["operator", ":"],
48+
["string", "'cosmosDbDeploy'"],
49+
50+
["punctuation", "}"],
51+
52+
["keyword", "param"],
53+
" env string\r\n",
54+
55+
["keyword", "var"],
56+
" oneNumber ",
57+
["operator", "="],
58+
["number", "123"],
59+
60+
["keyword", "output"],
61+
" databaseName string ",
62+
["operator", "="],
63+
" cosmosdbDatabaseName\r\n",
64+
65+
["keyword", "for"],
66+
" item ",
67+
["keyword", "in"],
68+
" cosmosdbAllowedIpAddresses",
69+
["operator", ":"],
70+
["punctuation", "{"],
71+
72+
"\r\n\tipAddressOrRange",
73+
["operator", ":"],
74+
" item\r\n",
75+
76+
["punctuation", "}"],
77+
78+
["keyword", "if"],
79+
80+
["keyword", "null"]
81+
]
82+
83+
----------------------------------------------------
84+
85+
Checks for all keywords.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
42
2+
3.14159
3+
4e10
4+
3.2E+6
5+
2.1e-10
6+
0b1101
7+
0o571
8+
0xbabe
9+
0xBABE
10+
11+
NaN
12+
Infinity
13+
14+
123n
15+
0x123n
16+
17+
1_000_000_000_000
18+
1_000_000.220_720
19+
0b0101_0110_0011_1000
20+
0o12_34_56
21+
0x40_76_38_6A_73
22+
4_642_473_943_484_686_707n
23+
0.000_001
24+
1e10_000
25+
26+
----------------------------------------------------
27+
28+
[
29+
["number", "42"],
30+
["number", "3.14159"],
31+
["number", "4e10"],
32+
["number", "3.2E+6"],
33+
["number", "2.1e-10"],
34+
["number", "0"], "b1101\r\n",
35+
["number", "0"], "o571\r\n",
36+
["number", "0"], "xbabe\r\n",
37+
["number", "0"], "xBABE\r\n\r\nNaN\r\nInfinity\r\n\r\n",
38+
39+
["number", "123"], "n\r\n",
40+
["number", "0"], "x123n\r\n\r\n",
41+
42+
["number", "1"],
43+
"_000_000_000_000\r\n",
44+
45+
["number", "1"],
46+
"_000_000",
47+
["punctuation", "."],
48+
["number", "220"],
49+
"_720\r\n",
50+
51+
["number", "0"],
52+
"b0101_0110_0011_1000\r\n",
53+
54+
["number", "0"],
55+
"o12_34_56\r\n",
56+
57+
["number", "0"],
58+
"x40_76_38_6A_73\r\n",
59+
60+
["number", "4"],
61+
"_642_473_943_484_686_707n\r\n",
62+
63+
["number", "0.000"],
64+
"_001\r\n",
65+
66+
["number", "1e10"],
67+
"_000"
68+
]
69+
70+
----------------------------------------------------
71+
72+
Checks for decimal numbers, binary numbers, octal numbers, hexadecimal numbers.
73+
Also checks for keywords representing numbers.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
- -- -=
2+
+ ++ +=
3+
< <= << <<=
4+
> >= >> >>= >>> >>>=
5+
= == === =>
6+
! != !==
7+
& && &= &&=
8+
| || |= ||=
9+
* ** *= **=
10+
/ /= ~
11+
^ ^= % %=
12+
? : ...
13+
?? ?. ??=
14+
15+
----------------------------------------------------
16+
17+
[
18+
["operator", "-"], ["operator", "--"], ["operator", "-="],
19+
["operator", "+"], ["operator", "++"], ["operator", "+="],
20+
["operator", "<"], ["operator", "<="], ["operator", "<<"], ["operator", "<<="],
21+
["operator", ">"], ["operator", ">="], ["operator", ">>"], ["operator", ">>="], ["operator", ">>>"], ["operator", ">>>="],
22+
["operator", "="], ["operator", "=="], ["operator", "==="], ["operator", "=>"],
23+
["operator", "!"], ["operator", "!="], ["operator", "!=="],
24+
["operator", "&"], ["operator", "&&"], ["operator", "&="], ["operator", "&&="],
25+
["operator", "|"], ["operator", "||"], ["operator", "|="], ["operator", "||="],
26+
["operator", "*"], ["operator", "**"], ["operator", "*="], ["operator", "**="],
27+
["operator", "/"], ["operator", "/="], ["operator", "~"],
28+
["operator", "^"], ["operator", "^="], ["operator", "%"], ["operator", "%="],
29+
["operator", "?"], ["operator", ":"], ["operator", "..."],
30+
["operator", "??"], ["operator", "?."], ["operator", "??="]
31+
]
32+
33+
----------------------------------------------------
34+
35+
Checks for all operators.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'Microsoft.Web/sites/config@2020-12-01'
2+
'https://${frontDoorName}.azurefd.net/.auth/login/aad/callback'
3+
4+
----------------------------------------------------
5+
6+
[
7+
["string", "'Microsoft.Web/sites/config@2020-12-01'"],
8+
["string", "'https://${frontDoorName}.azurefd.net/.auth/login/aad/callback'"]
9+
]
10+
11+
----------------------------------------------------
12+
13+
Checks for strings.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
var oneString = 'abc'
2+
var oneNumber = 123
3+
var numbers = [
4+
123
5+
]
6+
var oneObject = {
7+
abc: 123
8+
}
9+
10+
----------------------------------------------------
11+
12+
[
13+
["keyword", "var"], " oneString ", ["operator", "="], ["string", "'abc'"],
14+
["keyword", "var"], " oneNumber ", ["operator", "="], ["number", "123"],
15+
["keyword", "var"], " numbers ", ["operator", "="], ["punctuation", "["],
16+
["number", "123"],
17+
["punctuation", "]"],
18+
["keyword", "var"], " oneObject ", ["operator", "="], ["punctuation", "{"],
19+
"\r\n\tabc", ["operator", ":"], ["number", "123"],
20+
["punctuation", "}"]
21+
]
22+
23+
----------------------------------------------------
24+
25+
Checks for vars.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy