Skip to content

Commit 0803525

Browse files
authored
Added support for DataWeave language (#2659)
1 parent 2457440 commit 0803525

18 files changed

+502
-2
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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,10 @@
290290
"require": "clike",
291291
"owner": "Golmote"
292292
},
293+
"dataweave": {
294+
"title": "DataWeave",
295+
"owner": "machaval"
296+
},
293297
"dax": {
294298
"title": "DAX",
295299
"owner": "peterbud"

components/prism-dataweave.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
(function (Prism) {
2+
Prism.languages.dataweave = {
3+
'url': /\b[A-Za-z]+:\/\/[\w/:.?=&-]+|\burn:[\w:.?=&-]+/,
4+
'property': {
5+
pattern: /(?:\w+#)?(?:"(?:\\.|[^\\"\r\n])*"|\w+)(?=\s*[:@])/,
6+
greedy: true
7+
},
8+
'string': {
9+
pattern: /(["'`])(?:\\[\s\S]|(?!\1)[^\\])*\1/,
10+
greedy: true
11+
},
12+
'mime-type': /\b(?:text|audio|video|application|multipart|image)\/[\w+-]+/,
13+
'date': {
14+
pattern: /\|[\w:+-]+\|/,
15+
greedy: true
16+
},
17+
'comment': [
18+
{
19+
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
20+
lookbehind: true,
21+
greedy: true
22+
},
23+
{
24+
pattern: /(^|[^\\:])\/\/.*/,
25+
lookbehind: true,
26+
greedy: true
27+
}
28+
],
29+
'regex': {
30+
pattern: /\/(?:[^\\\/\r\n]|\\[^\r\n])+\//,
31+
greedy: true
32+
},
33+
'function': /\b[A-Za-z_]\w*(?=\s*\()/i,
34+
'number': /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
35+
'punctuation': /[{}[\];(),.:@]/,
36+
'operator': /<<|>>|->|[<>~=]=?|!=|--?-?|\+\+?|\!|\?/,
37+
'boolean': /\b(?:true|false)\b/,
38+
'keyword': /\b(?:match|input|output|ns|type|update|null|if|else|using|unless|at|is|as|case|do|fun|var|not|and|or)\b/
39+
};
40+
41+
}(Prism));

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<h2>Full example</h2>
2+
<pre><code>
3+
%dw 2.0
4+
input payalod application/json
5+
ns ns0 http://localhost.com
6+
var a = 123
7+
type T = String
8+
fun test(a: Number) = a + 123
9+
output application/json
10+
---
11+
{
12+
// This is a comment
13+
/**
14+
This is a multiline comment
15+
**/
16+
name: payload.name,
17+
string: "this",
18+
'another string': true,
19+
"regex": /123/,
20+
fc: test(1),
21+
"dates": |12-12-2020-T12:00:00|,
22+
number: 123,
23+
"null": null,
24+
25+
a: {} match {
26+
case is {} -> foo.name
27+
},
28+
b: {} update {
29+
case name at .user.name -> "123"
30+
},
31+
stringMultiLine: "This is a multiline
32+
string
33+
",
34+
a: if( !true > 2) a else 2,
35+
b: do {
36+
{}
37+
}
38+
}
39+
</code></pre>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"conc": "Concurnas",
5454
"csp": "Content-Security-Policy",
5555
"css-extras": "CSS Extras",
56+
"dataweave": "DataWeave",
5657
"dax": "DAX",
5758
"django": "Django/Jinja2",
5859
"jinja2": "Django/Jinja2",

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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
true
2+
false
3+
4+
----------------------------------------------------
5+
6+
[
7+
["boolean", "true"],
8+
["boolean", "false"]
9+
]
10+
11+
----------------------------------------------------
12+
Check for boolean
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Line comment ""
2+
/* Block comment */
3+
/**
4+
* MultiLine Comment
5+
**/
6+
/* "" */
7+
8+
----------------------------------------------------
9+
10+
[
11+
["comment", "// Line comment \"\"\t"],
12+
["comment", "/* Block comment */"],
13+
["comment", "/**\r\n\t* MultiLine Comment\r\n\t**/"],
14+
["comment", "/* \"\" */"]
15+
]
16+
----------------------------------------------------
17+
Check for comments
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
|12-12-2001-T12:00:00|
2+
|12-12-2001-T12:00:00+03:00|
3+
|12-12-2001-T12:00:00Z|
4+
|12-12-2001|
5+
|12:00:00|
6+
|12:00:00Z|
7+
|12:00:00-03:00|
8+
|P1D|
9+
|P1Y1D|
10+
|P1Y1D2H3M5S|
11+
12+
----------------------------------------------------
13+
14+
[
15+
["date", "|12-12-2001-T12:00:00|"],
16+
["date", "|12-12-2001-T12:00:00+03:00|"],
17+
["date", "|12-12-2001-T12:00:00Z|"],
18+
["date", "|12-12-2001|"],
19+
["date", "|12:00:00|"],
20+
["date", "|12:00:00Z|"],
21+
["date", "|12:00:00-03:00|"],
22+
["date", "|P1D|"],
23+
["date", "|P1Y1D|"],
24+
["date", "|P1Y1D2H3M5S|"]
25+
]
26+
----------------------------------------------------
27+
Check for date

0 commit comments

Comments
 (0)