Skip to content

Commit c93c066

Browse files
Added support for Splunk SPL (#1962)
This adds support for Splunk SPL and corrects the position of the SQL in `components.json`.
1 parent e8811d2 commit c93c066

File tree

13 files changed

+446
-7
lines changed

13 files changed

+446
-7
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: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -832,15 +832,19 @@
832832
"require": "markup-templating",
833833
"owner": "Golmote"
834834
},
835-
"sql": {
836-
"title": "SQL",
837-
"owner": "multipetros"
838-
},
839835
"soy": {
840836
"title": "Soy (Closure Template)",
841837
"require": "markup-templating",
842838
"owner": "Golmote"
843839
},
840+
"splunk-spl": {
841+
"title": "Splunk SPL",
842+
"owner": "RunDevelopment"
843+
},
844+
"sql": {
845+
"title": "SQL",
846+
"owner": "multipetros"
847+
},
844848
"stylus": {
845849
"title": "Stylus",
846850
"owner": "vkbansal"

components/prism-splunk-spl.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Prism.languages['splunk-spl'] = {
2+
'comment': /`comment\("(?:\\.|[^\\"])*"\)`/,
3+
'string': {
4+
pattern: /"(?:\\.|[^\\"])*"/,
5+
greedy: true
6+
},
7+
// https://docs.splunk.com/Documentation/Splunk/7.3.0/SearchReference/ListOfSearchCommands
8+
'keyword': /\b(?:abstract|accum|addcoltotals|addinfo|addtotals|analyzefields|anomalies|anomalousvalue|anomalydetection|append|appendcols|appendcsv|appendlookup|appendpipe|arules|associate|audit|autoregress|bin|bucket|bucketdir|chart|cluster|cofilter|collect|concurrency|contingency|convert|correlate|datamodel|dbinspect|dedup|delete|delta|diff|erex|eval|eventcount|eventstats|extract|fieldformat|fields|fieldsummary|filldown|fillnull|findtypes|folderize|foreach|format|from|gauge|gentimes|geom|geomfilter|geostats|head|highlight|history|iconify|input|inputcsv|inputlookup|iplocation|join|kmeans|kv|kvform|loadjob|localize|localop|lookup|makecontinuous|makemv|makeresults|map|mcollect|metadata|metasearch|meventcollect|mstats|multikv|multisearch|mvcombine|mvexpand|nomv|outlier|outputcsv|outputlookup|outputtext|overlap|pivot|predict|rangemap|rare|regex|relevancy|reltime|rename|replace|rest|return|reverse|rex|rtorder|run|savedsearch|script|scrub|search|searchtxn|selfjoin|sendemail|set|setfields|sichart|sirare|sistats|sitimechart|sitop|sort|spath|stats|strcat|streamstats|table|tags|tail|timechart|timewrap|top|transaction|transpose|trendline|tscollect|tstats|typeahead|typelearner|typer|union|uniq|untable|where|x11|xmlkv|xmlunescape|xpath|xyseries)\b/i,
9+
'operator-word': {
10+
pattern: /\b(?:and|as|by|not|or|xor)\b/i,
11+
alias: 'operator'
12+
},
13+
'function': /\w+(?=\s*\()/,
14+
'property': /\w+(?=\s*=(?!=))/,
15+
'date': {
16+
// MM/DD/YYYY(:HH:MM:SS)?
17+
pattern: /\b\d{1,2}\/\d{1,2}\/\d{1,4}(?:(?::\d{1,2}){3})?\b/,
18+
alias: 'number'
19+
},
20+
'number': /\b\d+(?:\.\d+)?\b/,
21+
'boolean': /\b(?:f|false|t|true)\b/i,
22+
'operator': /[<>=]=?|[-+*/%|]/,
23+
'punctuation': /[()[\],]/
24+
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<h2>Full example</h2>
2+
<pre><code>source=monthly_data.csv
3+
| rename remote_ip AS ip
4+
| eval isLocal=if(cidrmatch("123.132.32.0/25",ip), "local", "not local")
5+
| eval error=case(status == 200, "OK", status == 404, "Not found", true(), "Other")
6+
`comment("TODO: Add support for more status codes")`
7+
| sort amount</code></pre>

plugins/show-language/prism-show-language.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,9 @@
117117
"sass": "Sass (Sass)",
118118
"scss": "Sass (Scss)",
119119
"shell-session": "Shell session",
120-
"sql": "SQL",
121120
"soy": "Soy (Closure Template)",
121+
"splunk-spl": "Splunk SPL",
122+
"sql": "SQL",
122123
"tap": "TAP",
123124
"toml": "TOML",
124125
"tt2": "Template Toolkit 2",

plugins/show-language/prism-show-language.min.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.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
`comment("This is a comment")`
2+
`comment("This is too
3+
but on more than one line")`
4+
`comment("| stats sum(b) BY index")`
5+
6+
----------------------------------------------------
7+
8+
[
9+
["comment", "`comment(\"This is a comment\")`"],
10+
["comment", "`comment(\"This is too\r\nbut on more than one line\")`"],
11+
["comment", "`comment(\"| stats sum(b) BY index\")`"]
12+
]
13+
14+
----------------------------------------------------
15+
16+
Checks for comments.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
1/1/1970
2+
12/31/1999:23:59:59
3+
4+
----------------------------------------------------
5+
6+
[
7+
["date", "1/1/1970"],
8+
["date", "12/31/1999:23:59:59"]
9+
]
10+
11+
----------------------------------------------------
12+
13+
Checks for dates.

0 commit comments

Comments
 (0)