Skip to content

Commit c4f6b2c

Browse files
Adding basic support for Mathematica (#2921)
Co-authored-by: Michael Schmidt <mitchi5000.ms@googlemail.com>
1 parent ad9878a commit c4f6b2c

File tree

12 files changed

+140
-3
lines changed

12 files changed

+140
-3
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: 9 additions & 0 deletions
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

Lines changed: 29 additions & 0 deletions
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

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-wolfram.html

Lines changed: 31 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 0 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy