File tree Expand file tree Collapse file tree 1 file changed +36
-2
lines changed
Expand file tree Collapse file tree 1 file changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,41 @@ Description: language definition for Splunk search processing language (SPL)
55Category: enterprise
66*/
77
8- import * as regex from '../lib/regex.js' ;
8+ // === Start ===
9+ // Functions from highlight.js/lib/regex.js
10+ // Source: https://github.com/highlightjs/highlight.js/blob/main/src/lib/regex.js
11+ /**
12+ * @param {RegExp | string } re
13+ * @returns {string }
14+ */
15+ function source ( re ) {
16+ if ( ! re ) return null ;
17+ if ( typeof re === "string" ) return re ;
18+
19+ return re . source ;
20+ }
21+
22+ /**
23+ * @param {...(RegExp | string) } args
24+ * @returns {string }
25+ */
26+ function concat ( ...args ) {
27+ const joined = args . map ( ( x ) => source ( x ) ) . join ( "" ) ;
28+ return joined ;
29+ }
30+
31+ /**
32+ * Any of the passed expresssions may match
33+ *
34+ * Creates a huge this | this | that | that match
35+ * @param {(RegExp | string)[] } args
36+ * @returns {string }
37+ */
38+ function either ( ...args ) {
39+ const joined = '(' + args . map ( ( x ) => source ( x ) ) . join ( "|" ) + ")" ;
40+ return joined ;
41+ }
42+ // === End ===
943
1044/** @type LanguageFn */
1145export default function ( hljs ) {
@@ -137,7 +171,7 @@ export default function(hljs) {
137171
138172 const FUNCTION_CALL = {
139173 className : 'function' ,
140- begin : regex . concat ( / \b / , regex . either ( ...FUNCTIONS ) , / \s * \( / ) ,
174+ begin : concat ( / \b / , either ( ...FUNCTIONS ) , / \s * \( / ) ,
141175 keywords : {
142176 keyword : FUNCTIONS
143177 }
You can’t perform that action at this time.
0 commit comments