Skip to content

Commit 828b833

Browse files
committed
feat: add markup and fix comment markup
* Fix comment markup (quoting comment with ```) * Using functions and search command from Splunk Enterprise 8.1.3
1 parent 98b237b commit 828b833

File tree

6 files changed

+75
-31
lines changed

6 files changed

+75
-31
lines changed

dist/spl.min.js

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "highlightjs-spl",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "highlight.js syntax definition for the Splunk search processing language (SPL).",
55
"main": "src/languages/spl.js",
66
"scripts": {

src/languages/spl.js

Lines changed: 67 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ function either(...args) {
4343

4444
/** @type LanguageFn */
4545
export default function(hljs) {
46-
const HASH_COMMENT_MODE = hljs.COMMENT('//', /$/);
46+
const HASH_COMMENT_MODE = hljs.COMMENT('```', '```');
4747

48+
// List of evaluation functions from Splunk Enterprise 8.1.3 - Alphabetical list of functions
49+
// https://docs.splunk.com/Documentation/Splunk/8.1.3/SearchReference/CommonEvalFunctions#Alphabetical_list_of_functions
4850
const EVAL_FUNCTIONS = [
4951
"abs",
5052
"acos",
@@ -63,6 +65,7 @@ export default function(hljs) {
6365
"cosh",
6466
"exact",
6567
"exp",
68+
"false",
6669
"floor",
6770
"hypot",
6871
"if",
@@ -73,10 +76,17 @@ export default function(hljs) {
7376
"isnull",
7477
"isnum",
7578
"isstr",
79+
"json_object",
80+
"json_array",
81+
"json_extract",
82+
"json_keys",
83+
"json_set",
84+
"json_valid",
7685
"len",
7786
"like",
78-
"ln",
7987
"log",
88+
"lookup",
89+
"ln",
8090
"lower",
8191
"ltrim",
8292
"match",
@@ -90,6 +100,7 @@ export default function(hljs) {
90100
"mvfind",
91101
"mvindex",
92102
"mvjoin",
103+
"mvmap",
93104
"mvrange",
94105
"mvsort",
95106
"mvzip",
@@ -123,45 +134,49 @@ export default function(hljs) {
123134
"tonumber",
124135
"tostring",
125136
"trim",
137+
"true",
126138
"typeof",
127139
"upper",
128140
"urldecode",
129141
"validate"
130142
];
131143

144+
// List of statistical and charting functions from Splunk Enterprise 8.1.3 - Alphabetical list of functions
145+
// https://docs.splunk.com/Documentation/Splunk/8.1.3/SearchReference/CommonEvalFunctions#Alphabetical_list_of_functions
132146
const TRANSFORMING_FUNCTIONS = [
133147
"avg",
134148
"count",
135149
"distinct_count",
150+
"earliest",
151+
"earliest_time",
136152
"estdc",
137153
"estdc_error",
138-
"eval",
154+
"first",
155+
"last",
156+
"latest",
157+
"latest_time",
158+
"list",
139159
"max",
140160
"mean",
141161
"median",
142162
"min",
143163
"mode",
144164
"percentile",
165+
"per_day",
166+
"per_hour",
167+
"per_minute",
168+
"per_second",
145169
"range",
170+
"rate",
171+
"rate_avg",
172+
"rate_sum",
146173
"stdev",
147174
"stdevp",
148175
"sum",
149176
"sumsq",
150-
"var",
151-
"varp",
152-
"first",
153-
"last",
154-
"list",
155177
"values",
156-
"earliest",
157-
"earliest_time",
158-
"latest",
159-
"latest_time",
160-
"per_day",
161-
"per_hour",
162-
"per_minute",
163-
"per_second",
164-
"rate"
178+
"var",
179+
"varp"
165180
];
166181

167182
const FUNCTIONS = [
@@ -177,7 +192,8 @@ export default function(hljs) {
177192
}
178193
};
179194

180-
// https://docs.splunk.com/Documentation/SplunkLight/7.3.6/References/Listofsearchcommands
195+
// List of search command from Splunk Enterprise 8.1.3 - Search Commands
196+
// https://docs.splunk.com/Documentation/Splunk/8.1.3/SearchReference/WhatsInThisManual
181197
const BUILT_IN = [
182198
"abstract",
183199
"accum",
@@ -187,32 +203,37 @@ export default function(hljs) {
187203
"analyzefields",
188204
"anomalies",
189205
"anomalousvalue",
206+
"anomalydetection",
190207
"append",
191208
"appendcols",
192209
"appendpipe",
193210
"arules",
194211
"associate",
195212
"audit",
196213
"autoregress",
214+
"awssnsalert",
215+
"bin",
197216
"bucket",
198217
"bucketdir",
218+
"cefout",
199219
"chart",
200220
"cluster",
221+
"cofilter",
201222
"collect",
202223
"concurrency",
203224
"contingency",
204225
"convert",
205226
"correlate",
206-
"crawl",
227+
"ctable",
207228
"datamodel",
229+
"datamodelsimple",
208230
"dbinspect",
209231
"dbxquery",
210-
"dbxlookup",
211232
"dedup",
212233
"delete",
213234
"delta",
214235
"diff",
215-
"dispatch",
236+
"entitymerge",
216237
"erex",
217238
"eval",
218239
"eventcount",
@@ -221,7 +242,6 @@ export default function(hljs) {
221242
"fieldformat",
222243
"fields",
223244
"fieldsummary",
224-
"file",
225245
"filldown",
226246
"fillnull",
227247
"findtypes",
@@ -231,12 +251,15 @@ export default function(hljs) {
231251
"from",
232252
"gauge",
233253
"gentimes",
254+
"geom",
255+
"geomfilter",
234256
"geostats",
235257
"head",
236258
"highlight",
237259
"history",
238-
"input",
260+
"iconify",
239261
"inputcsv",
262+
"inputintelligence",
240263
"inputlookup",
241264
"iplocation",
242265
"join",
@@ -250,8 +273,13 @@ export default function(hljs) {
250273
"makemv",
251274
"makeresults",
252275
"map",
276+
"mcollect",
253277
"metadata",
254278
"metasearch",
279+
"meventcollect",
280+
"mpreview",
281+
"msearch",
282+
"mstats",
255283
"multikv",
256284
"multisearch",
257285
"mvcombine",
@@ -266,11 +294,13 @@ export default function(hljs) {
266294
"predict",
267295
"rangemap",
268296
"rare",
297+
"redistribute",
269298
"regex",
270299
"relevancy",
271300
"reltime",
272301
"rename",
273302
"replace",
303+
"require",
274304
"rest",
275305
"return",
276306
"reverse",
@@ -291,6 +321,10 @@ export default function(hljs) {
291321
"sistats",
292322
"sitimechart",
293323
"sitop",
324+
"snowincident",
325+
"snowincidentstream",
326+
"snowevent",
327+
"snoweventstream",
294328
"sort",
295329
"spath",
296330
"stats",
@@ -300,6 +334,7 @@ export default function(hljs) {
300334
"tags",
301335
"tail",
302336
"timechart",
337+
"timewrap",
303338
"top",
304339
"transaction",
305340
"transpose",
@@ -309,13 +344,22 @@ export default function(hljs) {
309344
"typeahead",
310345
"typelearner",
311346
"typer",
347+
"union",
312348
"uniq",
313349
"untable",
350+
"walklex",
314351
"where",
315352
"x11",
316353
"xmlkv",
317354
"xmlunescape",
318355
"xpath",
356+
"xsDisplayConcept",
357+
"xsDisplayContext",
358+
"xsFindBestConcept",
359+
"xsListConcepts",
360+
"xsListContexts",
361+
"xsUpdateDDContext",
362+
"xsWhere",
319363
"xyseries"
320364
];
321365

test/detect/default.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
index="tutorialdata_access" // load dataset
1+
index="tutorialdata_access" ```load dataset```
22
| reverse
33
| streamstats current=f global=f window=1 first(bytes) as pre_bytes by JSESSIONID
44
| eval diff_bytes=abs(bytes-pre_bytes)

test/markup/default.expect.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
index=<span class="hljs-string">&quot;tutorialdata_access&quot;</span> <span class="hljs-comment">// load dataset</span>
1+
index=<span class="hljs-string">&quot;tutorialdata_access&quot;</span> <span class="hljs-comment">```load dataset```</span>
22
<span class="hljs-operator">|</span> <span class="hljs-built_in">reverse</span>
33
<span class="hljs-operator">|</span> <span class="hljs-built_in">streamstats</span> current=f global=f window=<span class="hljs-number">1</span> <span class="hljs-function"><span class="hljs-keyword">first</span>(</span>bytes) <span class="hljs-keyword">as</span> pre_bytes <span class="hljs-keyword">by</span> JSESSIONID
44
<span class="hljs-operator">|</span> <span class="hljs-built_in">eval</span> diff_bytes=<span class="hljs-function"><span class="hljs-keyword">abs</span>(</span>bytes-pre_bytes)

test/markup/default.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
index="tutorialdata_access" // load dataset
1+
index="tutorialdata_access" ```load dataset```
22
| reverse
33
| streamstats current=f global=f window=1 first(bytes) as pre_bytes by JSESSIONID
44
| eval diff_bytes=abs(bytes-pre_bytes)

0 commit comments

Comments
 (0)