Skip to content

Commit e008ea0

Browse files
Added support for Kusto (#3068)
1 parent 4433ccf commit e008ea0

17 files changed

+555
-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
@@ -731,6 +731,10 @@
731731
"alias": "kum",
732732
"owner": "edukisto"
733733
},
734+
"kusto": {
735+
"title": "Kusto",
736+
"owner": "RunDevelopment"
737+
},
734738
"latex": {
735739
"title": "LaTeX",
736740
"alias": ["tex", "context"],

components/prism-kusto.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
Prism.languages.kusto = {
2+
'comment': {
3+
pattern: /\/\/.*/,
4+
greedy: true
5+
},
6+
'string': {
7+
pattern: /```[\s\S]*?```|[hH]?(?:"(?:[^\r\n\\"]|\\.)*"|'(?:[^\r\n\\']|\\.)*'|@(?:"[^\r\n"]*"|'[^\r\n']*'))/,
8+
greedy: true
9+
},
10+
11+
'verb': {
12+
pattern: /(\|\s*)[a-z][\w-]*/i,
13+
lookbehind: true,
14+
alias: 'keyword'
15+
},
16+
17+
'command': {
18+
pattern: /\.[a-z][a-z\d-]*\b/,
19+
alias: 'keyword'
20+
},
21+
22+
'class-name': /\b(?:bool|datetime|decimal|dynamic|guid|int|long|real|string|timespan)\b/,
23+
'keyword': /\b(?:access|alias|and|anti|as|asc|auto|between|by|database|declare|desc|external|from|fullouter|has_all|in|ingestion|inline|inner|innerunique|into|let|like|local|not|of|on|or|pattern|print|query_parameters|range|restrict|schema|set|step|table|tables|to|view|where|with|(?:has(?:perfix|suffix)?|contains|(?:starts|ends)with)(?:_cs)?|(?:left|right)(?:anti(?:semi)?|inner|outer|semi)?|matches\s+regex|nulls\s+(?:first|last))(?![\w-])/,
24+
'boolean': /\b(?:true|false|null)\b/,
25+
26+
'function': /\b[a-z_]\w*(?=\s*\()/,
27+
28+
'datetime': [
29+
{
30+
// RFC 822 + RFC 850
31+
pattern: /\b(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)\s*,\s*)?\d{1,2}(?:\s+|-)(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)(?:\s+|-)\d{2}\s+\d{2}:\d{2}(?::\d{2})?(?:\s*(?:\b(?:(?:U|GM|[ECMT][DS])T|[A-Z])|[+-]\d{4}))?\b/,
32+
alias: 'number'
33+
},
34+
{
35+
// ISO 8601
36+
pattern: /[+-]?\b(?:\d{4}-\d{2}-\d{2}(?:[ T]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?)?|\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?)Z?/,
37+
alias: 'number'
38+
}
39+
],
40+
'number': /\b(?:0x[0-9A-Fa-f]+|\d+(?:\.\d+)?(?:[Ee][+-]?\d+)?)(?:(?:min|sec|[mnµ]s|tick|microsecond|[dhms])\b)?|[+-]?\binf\b/,
41+
42+
'operator': /=>|[!=]~|[!=<>]=?|[-+*/%|]|\.\./,
43+
'punctuation': /[()\[\]{},;.:]/
44+
};

components/prism-kusto.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-kusto.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<h2>Full example</h2>
2+
<pre><code>// Source: https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/tutorial?pivots=azuredataexplorer
3+
4+
StormEvents
5+
| where StartTime > datetime(2007-02-01) and StartTime &lt; datetime(2007-03-01)
6+
| where EventType == 'Flood' and State == 'CALIFORNIA'
7+
| project StartTime, EndTime , State , EventType , EpisodeNarrative
8+
</code></pre>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
true bool(true)
2+
false bool(false)
3+
bool(null)
4+
5+
----------------------------------------------------
6+
7+
[
8+
["boolean", "true"],
9+
["class-name", "bool"],
10+
["punctuation", "("],
11+
["boolean", "true"],
12+
["punctuation", ")"],
13+
14+
["boolean", "false"],
15+
["class-name", "bool"],
16+
["punctuation", "("],
17+
["boolean", "false"],
18+
["punctuation", ")"],
19+
20+
["class-name", "bool"],
21+
["punctuation", "("],
22+
["boolean", "null"],
23+
["punctuation", ")"]
24+
]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
bool
2+
datetime
3+
decimal
4+
dynamic
5+
guid
6+
int
7+
long
8+
real
9+
string
10+
timespan
11+
12+
----------------------------------------------------
13+
14+
[
15+
["class-name", "bool"],
16+
["class-name", "datetime"],
17+
["class-name", "decimal"],
18+
["class-name", "dynamic"],
19+
["class-name", "guid"],
20+
["class-name", "int"],
21+
["class-name", "long"],
22+
["class-name", "real"],
23+
["class-name", "string"],
24+
["class-name", "timespan"]
25+
]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.show tables
2+
| count
3+
4+
.set foo=234
5+
6+
----------------------------------------------------
7+
8+
[
9+
["command", ".show"], ["keyword", "tables"],
10+
["operator", "|"], ["verb", "count"],
11+
12+
["command", ".set"], " foo", ["operator", "="], ["number", "234"]
13+
]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// comment
2+
3+
----------------------------------------------------
4+
5+
[
6+
["comment", "// comment"]
7+
]
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// ISO 8601
2+
2014-05-25T08:20:03.123456Z
3+
2014-05-25T08:20:03.123456
4+
2014-05-25T08:20
5+
2014-11-08 15:55:55.123456Z
6+
2014-11-08 15:55:55
7+
2014-11-08 15:55
8+
2014-11-08
9+
10+
// RFC 822
11+
Sat, 8 Nov 14 15:05:02 GMT
12+
Sat, 8 Nov 14 15:05:02
13+
Sat, 8 Nov 14 15:05
14+
Sat, 8 Nov 14 15:05 GMT
15+
8 Nov 14 15:05:02 GMT
16+
8 Nov 14 15:05:02
17+
8 Nov 14 15:05
18+
8 Nov 14 15:05 GMT
19+
20+
// RFC 850
21+
Saturday, 08-Nov-14 15:05:02 GMT
22+
Saturday, 08-Nov-14 15:05:02
23+
Saturday, 08-Nov-14 15:05 GMT
24+
Saturday, 08-Nov-14 15:05
25+
08-Nov-14 15:05:02 GMT
26+
08-Nov-14 15:05:02
27+
08-Nov-14 15:05 GMT
28+
08-Nov-14 15:05
29+
30+
----------------------------------------------------
31+
32+
[
33+
["comment", "// ISO 8601"],
34+
["datetime", "2014-05-25T08:20:03.123456Z"],
35+
["datetime", "2014-05-25T08:20:03.123456"],
36+
["datetime", "2014-05-25T08:20"],
37+
["datetime", "2014-11-08 15:55:55.123456Z"],
38+
["datetime", "2014-11-08 15:55:55"],
39+
["datetime", "2014-11-08 15:55"],
40+
["datetime", "2014-11-08"],
41+
42+
["comment", "// RFC 822"],
43+
["datetime", "Sat, 8 Nov 14 15:05:02 GMT"],
44+
["datetime", "Sat, 8 Nov 14 15:05:02"],
45+
["datetime", "Sat, 8 Nov 14 15:05"],
46+
["datetime", "Sat, 8 Nov 14 15:05 GMT"],
47+
["datetime", "8 Nov 14 15:05:02 GMT"],
48+
["datetime", "8 Nov 14 15:05:02"],
49+
["datetime", "8 Nov 14 15:05"],
50+
["datetime", "8 Nov 14 15:05 GMT"],
51+
52+
["comment", "// RFC 850"],
53+
["datetime", "Saturday, 08-Nov-14 15:05:02 GMT"],
54+
["datetime", "Saturday, 08-Nov-14 15:05:02"],
55+
["datetime", "Saturday, 08-Nov-14 15:05 GMT"],
56+
["datetime", "Saturday, 08-Nov-14 15:05"],
57+
["datetime", "08-Nov-14 15:05:02 GMT"],
58+
["datetime", "08-Nov-14 15:05:02"],
59+
["datetime", "08-Nov-14 15:05 GMT"],
60+
["datetime", "08-Nov-14 15:05"]
61+
]

0 commit comments

Comments
 (0)