Skip to content

Commit

Permalink
Dataweave: Fixed keywords being highlighted as functions (#3113)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment committed Oct 5, 2021
1 parent 5c412cb commit 532212b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion components/prism-dataweave.js
Expand Up @@ -30,12 +30,12 @@
pattern: /\/(?:[^\\\/\r\n]|\\[^\r\n])+\//,
greedy: true
},
'keyword': /\b(?:and|as|at|case|do|else|fun|if|input|is|match|not|ns|null|or|output|type|unless|update|using|var)\b/,
'function': /\b[A-Z_]\w*(?=\s*\()/i,
'number': /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
'punctuation': /[{}[\];(),.:@]/,
'operator': /<<|>>|->|[<>~=]=?|!=|--?-?|\+\+?|!|\?/,
'boolean': /\b(?:false|true)\b/,
'keyword': /\b(?:and|as|at|case|do|else|fun|if|input|is|match|not|ns|null|or|output|type|unless|update|using|var)\b/
};

}(Prism));
2 changes: 1 addition & 1 deletion components/prism-dataweave.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions tests/languages/dataweave/keywords_feature.test
Expand Up @@ -15,11 +15,15 @@ update {
if(true or false and not true) do {

}
else
else
payload match {
case a is String -> x as String
}

null
unless
using

----------------------------------------------------

[
Expand Down Expand Up @@ -89,7 +93,7 @@ payload match {

["punctuation", "}"],

["function", "if"],
["keyword", "if"],
["punctuation", "("],
["boolean", "true"],
["keyword", "or"],
Expand All @@ -105,7 +109,7 @@ payload match {

["keyword", "else"],

" \r\npayload ",
"\r\npayload ",
["keyword", "match"],
["punctuation", "{"],

Expand All @@ -118,7 +122,11 @@ payload match {
["keyword", "as"],
" String\r\n",

["punctuation", "}"]
["punctuation", "}"],

["keyword", "null"],
["keyword", "unless"],
["keyword", "using"]
]

----------------------------------------------------
Expand Down

0 comments on commit 532212b

Please sign in to comment.