Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding basic support for mathematica #2921

Merged
merged 16 commits into from
Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -1346,6 +1346,16 @@
"require": "markup",
"owner": "Golmote"
},
"wolfram": {
"title": "Wolfram language",
"alias": ["mathematica", "nb", "wl"],
"aliasTitles": {
"mathematica": "Mathematica",
"wl": "Wolfram Language",
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
"nb": "Mathematica Notebook"
},
"owner": "msollami"
},
"xeora": {
"title": "Xeora",
"require": "markup",
Expand Down
29 changes: 29 additions & 0 deletions components/prism-wolfram.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Prism.languages.wolfram = {
'comment': // Allow one level of nesting - note: regex taken from applescipt
/\(\*(?:\(\*(?:[^*]|\*(?!\)))*\*\)|(?!\(\*)[\s\S])*?\*\)/,
'string': {
pattern: /"(?:\\.|[^"\\\r\n])*"/,
greedy: true
},
'keyword': /\b(?:Abs|AbsArg|Accuracy|Block|Do|For|Function|If|Manipulate|Module|Nest|NestList|None|Return|Switch|Table|Which|While)\b/,
'context': {
pattern: /\w+`+\w*/,
alias: 'class-name'
},
'blank': {
pattern: /\b\w+_\b/,
alias: 'regex'
},
'global-variable': {
pattern: /\$\w+/,
alias: 'variable'
},
'boolean': /\b(?:True|False)\b/,
'number': /(?:\b(?=\d)|\B(?=\.))(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?j?\b/i,
'operator': /\/\.|\;|\=\.|\^\=|\^\:\=|\:\=|\<\<|\>\>|\<\||\|\>|\:\>|\|\-\>|\-\>|\<\-|\@\@\@|\@\@|\@|\/\@|\=\!\=|\=\=\=|\=\=|\=|\+|\-|\^|\*|\[\/-+%=]=?|\!\=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
'punctuation': /[\|{}[\];(),.:]/
};

Prism.languages.mathematica = Prism.languages.wolfram;
Prism.languages.wl = Prism.languages.wolfram;
Prism.languages.nb = Prism.languages.wolfram;
1 change: 1 addition & 0 deletions components/prism-wolfram.min.js

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

31 changes: 31 additions & 0 deletions examples/prism-wolfram.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<h2>Comments</h2>
<pre><code>
(* This is a comment *)
</code></pre>

<h2>Strings</h2>
<pre><code>
"foo bar baz"
</code></pre>

<h2>Numbers</h2>
<pre><code>
7
3.14
10.
.001
1e100
3.14e-10
2147483647
</code></pre>

<h2>Full example</h2>
<pre><code>
(* Most operators are supported *)
f /@ {1, 2, 3};
f @@ Range[10];
f @@@ y;
Module[{x=1},
Return @ $Failed
]
</code></pre>
3 changes: 3 additions & 0 deletions plugins/autoloader/prism-autoloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@
"url": "uri",
"vb": "visual-basic",
"vba": "visual-basic",
"mathematica": "wolfram",
"nb": "wolfram",
"wl": "wolfram",
"xeoracube": "xeora",
"yml": "yaml"
}/*]*/;
Expand Down
2 changes: 1 addition & 1 deletion plugins/autoloader/prism-autoloader.min.js

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

3 changes: 3 additions & 0 deletions plugins/show-language/prism-show-language.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@
"vb": "Visual Basic",
"wasm": "WebAssembly",
"wiki": "Wiki markup",
"wolfram": "Wolfram language",
"wl": "Wolfram Language",
"nb": "Mathematica Notebook",
"xeoracube": "XeoraCube",
"xml-doc": "XML doc (.net)",
"xojo": "Xojo (REALbasic)",
Expand Down
Loading