Skip to content

Commit e008ea0

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

17 files changed

+555
-1
lines changed
 

‎components.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎components.json

+4
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

+44
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

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎examples/prism-kusto.html

+8
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>
+24
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+
]
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+
]
+13
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+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// comment
2+
3+
----------------------------------------------------
4+
5+
[
6+
["comment", "// comment"]
7+
]
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+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
min()
2+
3+
----------------------------------------------------
4+
5+
[
6+
["function", "min"],
7+
["punctuation", "("],
8+
["punctuation", ")"]
9+
]
+145
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
access
2+
alias
3+
and
4+
anti
5+
as
6+
asc
7+
auto
8+
between
9+
by
10+
contains
11+
contains_cs
12+
database
13+
declare
14+
desc
15+
endswith
16+
endswith_cs
17+
external
18+
from
19+
fullouter
20+
has
21+
has_all
22+
has_cs
23+
hasperfix
24+
hasperfix_cs
25+
hassuffix
26+
hassuffix_cs
27+
in
28+
ingestion
29+
inline
30+
inner
31+
innerunique
32+
into
33+
left
34+
leftanti
35+
leftantisemi
36+
leftinner
37+
leftouter
38+
leftsemi
39+
let
40+
like
41+
local
42+
matches regex
43+
not
44+
nulls first
45+
nulls last
46+
of
47+
on
48+
or
49+
pattern
50+
print
51+
query_parameters
52+
range
53+
restrict
54+
right
55+
rightanti
56+
rightantisemi
57+
rightinner
58+
rightouter
59+
rightsemi
60+
schema
61+
set
62+
startswith
63+
startswith_cs
64+
step
65+
table
66+
tables
67+
to
68+
view
69+
where
70+
with
71+
72+
----------------------------------------------------
73+
74+
[
75+
["keyword", "access"],
76+
["keyword", "alias"],
77+
["keyword", "and"],
78+
["keyword", "anti"],
79+
["keyword", "as"],
80+
["keyword", "asc"],
81+
["keyword", "auto"],
82+
["keyword", "between"],
83+
["keyword", "by"],
84+
["keyword", "contains"],
85+
["keyword", "contains_cs"],
86+
["keyword", "database"],
87+
["keyword", "declare"],
88+
["keyword", "desc"],
89+
["keyword", "endswith"],
90+
["keyword", "endswith_cs"],
91+
["keyword", "external"],
92+
["keyword", "from"],
93+
["keyword", "fullouter"],
94+
["keyword", "has"],
95+
["keyword", "has_all"],
96+
["keyword", "has_cs"],
97+
["keyword", "hasperfix"],
98+
["keyword", "hasperfix_cs"],
99+
["keyword", "hassuffix"],
100+
["keyword", "hassuffix_cs"],
101+
["keyword", "in"],
102+
["keyword", "ingestion"],
103+
["keyword", "inline"],
104+
["keyword", "inner"],
105+
["keyword", "innerunique"],
106+
["keyword", "into"],
107+
["keyword", "left"],
108+
["keyword", "leftanti"],
109+
["keyword", "leftantisemi"],
110+
["keyword", "leftinner"],
111+
["keyword", "leftouter"],
112+
["keyword", "leftsemi"],
113+
["keyword", "let"],
114+
["keyword", "like"],
115+
["keyword", "local"],
116+
["keyword", "matches regex"],
117+
["keyword", "not"],
118+
["keyword", "nulls first"],
119+
["keyword", "nulls last"],
120+
["keyword", "of"],
121+
["keyword", "on"],
122+
["keyword", "or"],
123+
["keyword", "pattern"],
124+
["keyword", "print"],
125+
["keyword", "query_parameters"],
126+
["keyword", "range"],
127+
["keyword", "restrict"],
128+
["keyword", "right"],
129+
["keyword", "rightanti"],
130+
["keyword", "rightantisemi"],
131+
["keyword", "rightinner"],
132+
["keyword", "rightouter"],
133+
["keyword", "rightsemi"],
134+
["keyword", "schema"],
135+
["keyword", "set"],
136+
["keyword", "startswith"],
137+
["keyword", "startswith_cs"],
138+
["keyword", "step"],
139+
["keyword", "table"],
140+
["keyword", "tables"],
141+
["keyword", "to"],
142+
["keyword", "view"],
143+
["keyword", "where"],
144+
["keyword", "with"]
145+
]
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
0
2+
123
3+
123.456
4+
123.456e-7
5+
6+
0xfF
7+
8+
+inf
9+
-inf
10+
11+
// time
12+
12d
13+
12h
14+
12m
15+
12min
16+
12s
17+
12sec
18+
12ms
19+
20+
----------------------------------------------------
21+
22+
[
23+
["number", "0"],
24+
["number", "123"],
25+
["number", "123.456"],
26+
["number", "123.456e-7"],
27+
28+
["number", "0xfF"],
29+
30+
["number", "+inf"],
31+
["number", "-inf"],
32+
33+
["comment", "// time"],
34+
["number", "12d"],
35+
["number", "12h"],
36+
["number", "12m"],
37+
["number", "12min"],
38+
["number", "12s"],
39+
["number", "12sec"],
40+
["number", "12ms"]
41+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
+ - * / %
2+
== != < <= > >=
3+
=~ !~
4+
= !
5+
6+
=>
7+
..
8+
9+
----------------------------------------------------
10+
11+
[
12+
["operator", "+"],
13+
["operator", "-"],
14+
["operator", "*"],
15+
["operator", "/"],
16+
["operator", "%"],
17+
18+
["operator", "=="],
19+
["operator", "!="],
20+
["operator", "<"],
21+
["operator", "<="],
22+
["operator", ">"],
23+
["operator", ">="],
24+
25+
["operator", "=~"],
26+
["operator", "!~"],
27+
28+
["operator", "="],
29+
["operator", "!"],
30+
31+
["operator", "=>"],
32+
["operator", ".."]
33+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
( ) [ ] { }
2+
, ; . :
3+
4+
----------------------------------------------------
5+
6+
[
7+
["punctuation", "("],
8+
["punctuation", ")"],
9+
["punctuation", "["],
10+
["punctuation", "]"],
11+
["punctuation", "{"],
12+
["punctuation", "}"],
13+
14+
["punctuation", ","],
15+
["punctuation", ";"],
16+
["punctuation", "."],
17+
["punctuation", ":"]
18+
]
+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
""
2+
''
3+
@""
4+
@''
5+
"foo\""
6+
'bar\''
7+
@"\"
8+
@'\'
9+
10+
```
11+
multiline
12+
```
13+
14+
// Obfuscated string literals
15+
h'hello'
16+
h@'world'
17+
h"hello"
18+
19+
// string concatenation
20+
21+
print strlen("Hello"', '@"world!"); // Nothing between them
22+
23+
print strlen("Hello" ', ' @"world!"); // Separated by whitespace only
24+
25+
print strlen("Hello"
26+
// Comment
27+
', '@"world!"); // Separated by whitespace and a comment
28+
29+
----------------------------------------------------
30+
31+
[
32+
["string", "\"\""],
33+
["string", "''"],
34+
["string", "@\"\""],
35+
["string", "@''"],
36+
["string", "\"foo\\\"\""],
37+
["string", "'bar\\''"],
38+
["string", "@\"\\\""],
39+
["string", "@'\\'"],
40+
41+
["string", "```\r\nmultiline\r\n```"],
42+
43+
["comment", "// Obfuscated string literals"],
44+
["string", "h'hello'"],
45+
["string", "h@'world'"],
46+
["string", "h\"hello\""],
47+
48+
["comment", "// string concatenation"],
49+
50+
["keyword", "print"],
51+
["function", "strlen"],
52+
["punctuation", "("],
53+
["string", "\"Hello\""],
54+
["string", "', '"],
55+
["string", "@\"world!\""],
56+
["punctuation", ")"],
57+
["punctuation", ";"],
58+
["comment", "// Nothing between them"],
59+
60+
["keyword", "print"],
61+
["function", "strlen"],
62+
["punctuation", "("],
63+
["string", "\"Hello\""],
64+
["string", "', '"],
65+
["string", "@\"world!\""],
66+
["punctuation", ")"],
67+
["punctuation", ";"],
68+
["comment", "// Separated by whitespace only"],
69+
70+
["keyword", "print"],
71+
["function", "strlen"],
72+
["punctuation", "("],
73+
["string", "\"Hello\""],
74+
75+
["comment", "// Comment"],
76+
77+
["string", "', '"],
78+
["string", "@\"world!\""],
79+
["punctuation", ")"],
80+
["punctuation", ";"],
81+
["comment", "// Separated by whitespace and a comment"]
82+
]
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
Logs
2+
| where Timestamp > ago(1d)
3+
| join
4+
(
5+
Events
6+
| where continent == 'Europe'
7+
) on RequestId
8+
9+
----------------------------------------------------
10+
11+
[
12+
"Logs\r\n",
13+
14+
["operator", "|"],
15+
["verb", "where"],
16+
" Timestamp ",
17+
["operator", ">"],
18+
["function", "ago"],
19+
["punctuation", "("],
20+
["number", "1d"],
21+
["punctuation", ")"],
22+
23+
["operator", "|"],
24+
["verb", "join"],
25+
26+
["punctuation", "("],
27+
28+
"\r\n Events\r\n ",
29+
30+
["operator", "|"],
31+
["verb", "where"],
32+
" continent ",
33+
["operator", "=="],
34+
["string", "'Europe'"],
35+
36+
["punctuation", ")"],
37+
["keyword", "on"],
38+
" RequestId"
39+
]

0 commit comments

Comments
 (0)
Please sign in to comment.