Skip to content

Commit c4f6b2c

Browse files
Adding basic support for Mathematica (#2921)
Co-authored-by: Michael Schmidt <[email protected]>
1 parent ad9878a commit c4f6b2c

12 files changed

+140
-3
lines changed

components.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components.json

+9
Original file line numberDiff line numberDiff line change
@@ -1346,6 +1346,15 @@
13461346
"require": "markup",
13471347
"owner": "Golmote"
13481348
},
1349+
"wolfram": {
1350+
"title": "Wolfram language",
1351+
"alias": ["mathematica", "nb", "wl"],
1352+
"aliasTitles": {
1353+
"mathematica": "Mathematica",
1354+
"nb": "Mathematica Notebook"
1355+
},
1356+
"owner": "msollami"
1357+
},
13491358
"xeora": {
13501359
"title": "Xeora",
13511360
"require": "markup",

components/prism-wolfram.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Prism.languages.wolfram = {
2+
'comment': // Allow one level of nesting - note: regex taken from applescipt
3+
/\(\*(?:\(\*(?:[^*]|\*(?!\)))*\*\)|(?!\(\*)[\s\S])*?\*\)/,
4+
'string': {
5+
pattern: /"(?:\\.|[^"\\\r\n])*"/,
6+
greedy: true
7+
},
8+
'keyword': /\b(?:Abs|AbsArg|Accuracy|Block|Do|For|Function|If|Manipulate|Module|Nest|NestList|None|Return|Switch|Table|Which|While)\b/,
9+
'context': {
10+
pattern: /\w+`+\w*/,
11+
alias: 'class-name'
12+
},
13+
'blank': {
14+
pattern: /\b\w+_\b/,
15+
alias: 'regex'
16+
},
17+
'global-variable': {
18+
pattern: /\$\w+/,
19+
alias: 'variable'
20+
},
21+
'boolean': /\b(?:True|False)\b/,
22+
'number': /(?:\b(?=\d)|\B(?=\.))(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?j?\b/i,
23+
'operator': /\/\.|\;|\=\.|\^\=|\^\:\=|\:\=|\<\<|\>\>|\<\||\|\>|\:\>|\|\-\>|\-\>|\<\-|\@\@\@|\@\@|\@|\/\@|\=\!\=|\=\=\=|\=\=|\=|\+|\-|\^|\*|\[\/-+%=]=?|\!\=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
24+
'punctuation': /[\|{}[\];(),.:]/
25+
};
26+
27+
Prism.languages.mathematica = Prism.languages.wolfram;
28+
Prism.languages.wl = Prism.languages.wolfram;
29+
Prism.languages.nb = Prism.languages.wolfram;

components/prism-wolfram.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/prism-wolfram.html

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<h2>Comments</h2>
2+
<pre><code>
3+
(* This is a comment *)
4+
</code></pre>
5+
6+
<h2>Strings</h2>
7+
<pre><code>
8+
"foo bar baz"
9+
</code></pre>
10+
11+
<h2>Numbers</h2>
12+
<pre><code>
13+
7
14+
3.14
15+
10.
16+
.001
17+
1e100
18+
3.14e-10
19+
2147483647
20+
</code></pre>
21+
22+
<h2>Full example</h2>
23+
<pre><code>
24+
(* Most operators are supported *)
25+
f /@ {1, 2, 3};
26+
f @@ Range[10];
27+
f @@@ y;
28+
Module[{x=1},
29+
Return @ $Failed
30+
]
31+
</code></pre>

plugins/autoloader/prism-autoloader.js

+3
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@
239239
"url": "uri",
240240
"vb": "visual-basic",
241241
"vba": "visual-basic",
242+
"mathematica": "wolfram",
243+
"nb": "wolfram",
244+
"wl": "wolfram",
242245
"xeoracube": "xeora",
243246
"yml": "yaml"
244247
}/*]*/;

plugins/autoloader/prism-autoloader.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

+3
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@
230230
"vb": "Visual Basic",
231231
"wasm": "WebAssembly",
232232
"wiki": "Wiki markup",
233+
"wolfram": "Wolfram language",
234+
"nb": "Mathematica Notebook",
235+
"wl": "Wolfram language",
233236
"xeoracube": "XeoraCube",
234237
"xml-doc": "XML doc (.net)",
235238
"xojo": "Xojo (REALbasic)",

0 commit comments

Comments
 (0)