Skip to content

Commit 4fbdd2f

Browse files
authoredSep 15, 2021
Added support for MAXScript (#3060)
1 parent 746a4b1 commit 4fbdd2f

19 files changed

+573
-2
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

+4
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,10 @@
812812
"title": "MATLAB",
813813
"owner": "Golmote"
814814
},
815+
"maxscript": {
816+
"title": "MAXScript",
817+
"owner": "RunDevelopment"
818+
},
815819
"mel": {
816820
"title": "MEL",
817821
"owner": "Golmote"

‎components/prism-maxscript.js

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
Prism.languages.maxscript = {
2+
'comment': {
3+
pattern: /\/\*[\s\S]*?(?:\*\/|$)|--.*/,
4+
greedy: true
5+
},
6+
'string': {
7+
pattern: /(^|[^"\\@])(?:"(?:[^"\\]|\\[\s\S])*"|@"[^"]*")/,
8+
lookbehind: true,
9+
greedy: true
10+
},
11+
'path': {
12+
pattern: /\$(?:[\w/\\.*?]|'[^']*')*/,
13+
greedy: true,
14+
alias: 'string'
15+
},
16+
17+
'function-definition': {
18+
pattern: /(\b(?:function|fn)\s+)\w+\b/,
19+
lookbehind: true,
20+
alias: 'function'
21+
},
22+
23+
'argument': {
24+
pattern: /\b[a-z_]\w*(?=:)/i,
25+
alias: 'attr-name'
26+
},
27+
28+
'keyword': /\b(?:about|and|animate|as|at|attributes|by|case|catch|collect|continue|coordsys|do|else|exit|fn|for|from|function|global|if|in|local|macroscript|mapped|max|not|of|off|on|or|parameters|persistent|plugin|rcmenu|return|rollout|set|struct|then|throw|to|tool|try|undo|utility|when|where|while|with)\b/i,
29+
'boolean': /\b(?:true|false|on|off)\b/,
30+
31+
'time': {
32+
pattern: /(^|[^\w.])(?:(?:(?:\d+(?:\.\d*)?|\.\d+)(?:[eEdD][+-]\d+|[LP])?[msft])+|\d+:\d+(?:\.\d*)?)(?![\w.:])/,
33+
lookbehind: true,
34+
alias: 'number'
35+
},
36+
'number': [
37+
{
38+
pattern: /(^|[^\w.])(?:(?:\d+(?:\.\d*)?|\.\d+)(?:[eEdD][+-]\d+|[LP])?|0x[a-fA-F0-9]+)(?![\w.:])/,
39+
lookbehind: true
40+
},
41+
/\b(?:e|pi)\b/
42+
],
43+
44+
'constant': /\b(?:black|blue|brown|gray|green|orange|red|white|yellow)\b/,
45+
'color': {
46+
pattern: /\b(?:dontcollect|ok|silentValue|undefined|unsupplied)\b/i,
47+
alias: 'constant'
48+
},
49+
50+
'operator': /[-+*/<>=!]=?|[&^]|#(?!\()/,
51+
'punctuation': /[()\[\]{}.:,;]|#(?=\()|\\$/m
52+
};

‎components/prism-maxscript.min.js

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

‎examples/prism-maxscript.html

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<h2>Strings</h2>
2+
<pre><code>-- Source: https://help.autodesk.com/view/MAXDEV/2022/ENU/?guid=GUID-5E5E1A71-24E2-4605-9720-2178B941DECC
3+
4+
plugin RenderEffect MonoChrome
5+
name:"MonoChrome"
6+
classID:#(0x9e6e9e77, 0xbe815df4)
7+
(
8+
rollout about_rollout "About..."
9+
(
10+
label about_label "MonoChrome Filter"
11+
)
12+
on apply r_image progressCB: do
13+
(
14+
progressCB.setTitle "MonoChrome Effect"
15+
local oldEscapeEnable = escapeEnable
16+
escapeEnable = false
17+
bmp_w = r_image.width
18+
bmp_h = r_image.height
19+
for y = 0 to bmp_h-1 do
20+
(
21+
if progressCB.progress y (bmp_h-1) then exit
22+
pixel_line = getPixels r_image [0,y] bmp_w
23+
for x = 1 to bmp_w do
24+
(
25+
p_v = pixel_line[x].value
26+
pixel_line[x] = color p_v p_v p_v pixel_line[x].alpha
27+
)--end x loop
28+
setPixels r_image [0,y] pixel_line
29+
)--end y loop
30+
escapeEnable = oldEscapeEnable
31+
)--end on apply
32+
)--end plugin
33+
</code></pre>

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

+1
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@
143143
"md": "Markdown",
144144
"markup-templating": "Markup templating",
145145
"matlab": "MATLAB",
146+
"maxscript": "MAXScript",
146147
"mel": "MEL",
147148
"mongodb": "MongoDB",
148149
"moon": "MoonScript",

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

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
true false
2+
3+
----------------------------------------------------
4+
5+
[
6+
["boolean", "true"], ["boolean", "false"]
7+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
black
2+
blue
3+
brown
4+
gray
5+
green
6+
orange
7+
red
8+
white
9+
yellow
10+
11+
----------------------------------------------------
12+
13+
[
14+
["constant", "black"],
15+
["constant", "blue"],
16+
["constant", "brown"],
17+
["constant", "gray"],
18+
["constant", "green"],
19+
["constant", "orange"],
20+
["constant", "red"],
21+
["constant", "white"],
22+
["constant", "yellow"]
23+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* this is a long comment
2+
blah blah
3+
print "debug 1" -- code commented out
4+
more comments
5+
*/
6+
7+
for i in 1 to 10 do(/* messageBox "in loop"; */frabulate i )
8+
9+
-- comment
10+
11+
----------------------------------------------------
12+
13+
[
14+
["comment", "/* this is a long comment\r\nblah blah\r\nprint \"debug 1\" -- code commented out\r\nmore comments\r\n*/"],
15+
16+
["keyword", "for"],
17+
" i ",
18+
["keyword", "in"],
19+
["number", "1"],
20+
["keyword", "to"],
21+
["number", "10"],
22+
["keyword", "do"],
23+
["punctuation", "("],
24+
["comment", "/* messageBox \"in loop\"; */"],
25+
"frabulate i ",
26+
["punctuation", ")"],
27+
28+
["comment", "-- comment"]
29+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
dontcollect
2+
ok
3+
silentValue
4+
undefined
5+
unsupplied
6+
7+
----------------------------------------------------
8+
9+
[
10+
["color", "dontcollect"],
11+
["color", "ok"],
12+
["color", "silentValue"],
13+
["color", "undefined"],
14+
["color", "unsupplied"]
15+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
function my_add a b = a + b
2+
3+
fn factorial n = if n <= 0 then 1 else n * factorial (n - 1)
4+
5+
mapped function rand_color x =
6+
x.wireColor = random (color 0 0 0) (color 255 255 255)
7+
8+
fn starfield count extent:[200,200,200] pos:[0,0,0] =
9+
(
10+
-- something
11+
)
12+
13+
----------------------------------------------------
14+
15+
[
16+
["keyword", "function"],
17+
["function-definition", "my_add"],
18+
" a b ",
19+
["operator", "="],
20+
" a ",
21+
["operator", "+"],
22+
" b\r\n\r\n",
23+
24+
["keyword", "fn"],
25+
["function-definition", "factorial"],
26+
" n ",
27+
["operator", "="],
28+
["keyword", "if"],
29+
" n ",
30+
["operator", "<="],
31+
["number", "0"],
32+
["keyword", "then"],
33+
["number", "1"],
34+
["keyword", "else"],
35+
" n ",
36+
["operator", "*"],
37+
" factorial ",
38+
["punctuation", "("],
39+
"n ",
40+
["operator", "-"],
41+
["number", "1"],
42+
["punctuation", ")"],
43+
44+
["keyword", "mapped"],
45+
["keyword", "function"],
46+
["function-definition", "rand_color"],
47+
" x ",
48+
["operator", "="],
49+
50+
"\r\n x",
51+
["punctuation", "."],
52+
"wireColor ",
53+
["operator", "="],
54+
" random ",
55+
["punctuation", "("],
56+
"color ",
57+
["number", "0"],
58+
["number", "0"],
59+
["number", "0"],
60+
["punctuation", ")"],
61+
["punctuation", "("],
62+
"color ",
63+
["number", "255"],
64+
["number", "255"],
65+
["number", "255"],
66+
["punctuation", ")"],
67+
68+
["keyword", "fn"],
69+
["function-definition", "starfield"],
70+
" count ",
71+
["argument", "extent"],
72+
["punctuation", ":"],
73+
["punctuation", "["],
74+
["number", "200"],
75+
["punctuation", ","],
76+
["number", "200"],
77+
["punctuation", ","],
78+
["number", "200"],
79+
["punctuation", "]"],
80+
["argument", "pos"],
81+
["punctuation", ":"],
82+
["punctuation", "["],
83+
["number", "0"],
84+
["punctuation", ","],
85+
["number", "0"],
86+
["punctuation", ","],
87+
["number", "0"],
88+
["punctuation", "]"],
89+
["operator", "="],
90+
91+
["punctuation", "("],
92+
93+
["comment", "-- something"],
94+
95+
["punctuation", ")"]
96+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
about;
2+
and;
3+
animate;
4+
as;
5+
at;
6+
attributes;
7+
by;
8+
case;
9+
catch;
10+
collect;
11+
continue;
12+
coordsys;
13+
do;
14+
else;
15+
exit;
16+
fn;
17+
for;
18+
from;
19+
function;
20+
global;
21+
if;
22+
in;
23+
local;
24+
macroscript;
25+
mapped;
26+
max;
27+
not;
28+
of;
29+
off;
30+
on;
31+
or;
32+
parameters;
33+
persistent;
34+
plugin;
35+
rcmenu;
36+
return;
37+
rollout;
38+
set;
39+
struct;
40+
then;
41+
throw;
42+
to;
43+
tool;
44+
try;
45+
undo;
46+
utility;
47+
when;
48+
where;
49+
while;
50+
with;
51+
52+
----------------------------------------------------
53+
54+
[
55+
["keyword", "about"], ["punctuation", ";"],
56+
["keyword", "and"], ["punctuation", ";"],
57+
["keyword", "animate"], ["punctuation", ";"],
58+
["keyword", "as"], ["punctuation", ";"],
59+
["keyword", "at"], ["punctuation", ";"],
60+
["keyword", "attributes"], ["punctuation", ";"],
61+
["keyword", "by"], ["punctuation", ";"],
62+
["keyword", "case"], ["punctuation", ";"],
63+
["keyword", "catch"], ["punctuation", ";"],
64+
["keyword", "collect"], ["punctuation", ";"],
65+
["keyword", "continue"], ["punctuation", ";"],
66+
["keyword", "coordsys"], ["punctuation", ";"],
67+
["keyword", "do"], ["punctuation", ";"],
68+
["keyword", "else"], ["punctuation", ";"],
69+
["keyword", "exit"], ["punctuation", ";"],
70+
["keyword", "fn"], ["punctuation", ";"],
71+
["keyword", "for"], ["punctuation", ";"],
72+
["keyword", "from"], ["punctuation", ";"],
73+
["keyword", "function"], ["punctuation", ";"],
74+
["keyword", "global"], ["punctuation", ";"],
75+
["keyword", "if"], ["punctuation", ";"],
76+
["keyword", "in"], ["punctuation", ";"],
77+
["keyword", "local"], ["punctuation", ";"],
78+
["keyword", "macroscript"], ["punctuation", ";"],
79+
["keyword", "mapped"], ["punctuation", ";"],
80+
["keyword", "max"], ["punctuation", ";"],
81+
["keyword", "not"], ["punctuation", ";"],
82+
["keyword", "of"], ["punctuation", ";"],
83+
["keyword", "off"], ["punctuation", ";"],
84+
["keyword", "on"], ["punctuation", ";"],
85+
["keyword", "or"], ["punctuation", ";"],
86+
["keyword", "parameters"], ["punctuation", ";"],
87+
["keyword", "persistent"], ["punctuation", ";"],
88+
["keyword", "plugin"], ["punctuation", ";"],
89+
["keyword", "rcmenu"], ["punctuation", ";"],
90+
["keyword", "return"], ["punctuation", ";"],
91+
["keyword", "rollout"], ["punctuation", ";"],
92+
["keyword", "set"], ["punctuation", ";"],
93+
["keyword", "struct"], ["punctuation", ";"],
94+
["keyword", "then"], ["punctuation", ";"],
95+
["keyword", "throw"], ["punctuation", ";"],
96+
["keyword", "to"], ["punctuation", ";"],
97+
["keyword", "tool"], ["punctuation", ";"],
98+
["keyword", "try"], ["punctuation", ";"],
99+
["keyword", "undo"], ["punctuation", ";"],
100+
["keyword", "utility"], ["punctuation", ";"],
101+
["keyword", "when"], ["punctuation", ";"],
102+
["keyword", "where"], ["punctuation", ";"],
103+
["keyword", "while"], ["punctuation", ";"],
104+
["keyword", "with"], ["punctuation", ";"]
105+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
123
2+
123.45
3+
-0.00345
4+
1.0e-6
5+
0x0E
6+
.1
7+
8+
e pi
9+
10+
----------------------------------------------------
11+
12+
[
13+
["number", "123"],
14+
["number", "123.45"],
15+
["operator", "-"], ["number", "0.00345"],
16+
["number", "1.0e-6"],
17+
["number", "0x0E"],
18+
["number", ".1"],
19+
20+
["number", "e"], ["number", "pi"]
21+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
+ - * /
2+
+= -= *= /=
3+
4+
=
5+
== != < <= > >=
6+
7+
^ & #
8+
9+
----------------------------------------------------
10+
11+
[
12+
["operator", "+"],
13+
["operator", "-"],
14+
["operator", "*"],
15+
["operator", "/"],
16+
17+
["operator", "+="],
18+
["operator", "-="],
19+
["operator", "*="],
20+
["operator", "/="],
21+
22+
["operator", "="],
23+
24+
["operator", "=="],
25+
["operator", "!="],
26+
["operator", "<"],
27+
["operator", "<="],
28+
["operator", ">"],
29+
["operator", ">="],
30+
31+
["operator", "^"], ["operator", "&"], ["operator", "#"]
32+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
$box01 -- object named 'box01'
2+
$torso/left_up_arm/left_low_arm -- hierarchy path name
3+
$*box* -- all objects with 'box' in
4+
-- the name
5+
$torso/* -- all the direct children of
6+
-- $torso
7+
$helpers/d* -- all helper objects whose name starts with 'd'
8+
9+
$dummy/head/neck
10+
$dummy/*
11+
$neck*
12+
$box0?
13+
$dummy/*/*
14+
$dummy/.../box*
15+
$dummy...*
16+
$*box*.position += [10, 10, 0]
17+
18+
$.pos = [0,0,0]
19+
hide $
20+
rotate $ 35 z_axis
21+
22+
$'a silly name!!'
23+
$'what the \*'
24+
bodyPart=$'Bip01 L UpperArm'
25+
bodyPart=$Bip01_L_UpperArm
26+
27+
----------------------------------------------------
28+
29+
[
30+
["path", "$box01"],
31+
["comment", "-- object named 'box01'"],
32+
["path", "$torso/left_up_arm/left_low_arm"],
33+
["comment", "-- hierarchy path name"],
34+
["path", "$*box*"],
35+
["comment", "-- all objects with 'box' in"],
36+
["comment", "-- the name"],
37+
["path", "$torso/*"],
38+
["comment", "-- all the direct children of"],
39+
["comment", "-- $torso"],
40+
["path", "$helpers/d*"],
41+
["comment", "-- all helper objects whose name starts with 'd'"],
42+
43+
["path", "$dummy/head/neck"],
44+
45+
["path", "$dummy/*"],
46+
47+
["path", "$neck*"],
48+
49+
["path", "$box0?"],
50+
51+
["path", "$dummy/*/*"],
52+
53+
["path", "$dummy/.../box*"],
54+
55+
["path", "$dummy...*"],
56+
57+
["path", "$*box*.position"],
58+
["operator", "+="],
59+
["punctuation", "["],
60+
["number", "10"],
61+
["punctuation", ","],
62+
["number", "10"],
63+
["punctuation", ","],
64+
["number", "0"],
65+
["punctuation", "]"],
66+
67+
["path", "$.pos"],
68+
["operator", "="],
69+
["punctuation", "["],
70+
["number", "0"],
71+
["punctuation", ","],
72+
["number", "0"],
73+
["punctuation", ","],
74+
["number", "0"],
75+
["punctuation", "]"],
76+
77+
"\r\nhide ",
78+
["path", "$"],
79+
80+
"\r\nrotate ",
81+
["path", "$"],
82+
["number", "35"],
83+
" z_axis\r\n\r\n",
84+
85+
["path", "$'a silly name!!'"],
86+
["path", "$'what the \\*'"],
87+
"\r\nbodyPart", ["operator", "="], ["path", "$'Bip01 L UpperArm'"],
88+
"\r\nbodyPart", ["operator", "="], ["path", "$Bip01_L_UpperArm"]
89+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
( ) [ ] { }
2+
. : , ;
3+
#(
4+
\
5+
6+
----------------------------------------------------
7+
8+
[
9+
["punctuation", "("],
10+
["punctuation", ")"],
11+
["punctuation", "["],
12+
["punctuation", "]"],
13+
["punctuation", "{"],
14+
["punctuation", "}"],
15+
16+
["punctuation", "."],
17+
["punctuation", ":"],
18+
["punctuation", ","],
19+
["punctuation", ";"],
20+
21+
["punctuation", "#"],
22+
["punctuation", "("],
23+
24+
["punctuation", "\\"]
25+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
""
2+
"foo should be quoted like this: \"foo\" and a new line: \n"
3+
"Twas brillig and the slithy tobes
4+
did gyre and gimbol in the wabe
5+
or something like that..."
6+
"g:\\3dsmax25\\scenes"
7+
@"g:\temp\newfolder\render"
8+
9+
----------------------------------------------------
10+
11+
[
12+
["string", "\"\""],
13+
["string", "\"foo should be quoted like this: \\\"foo\\\" and a new line: \\n\""],
14+
["string", "\"Twas brillig and the slithy tobes\r\ndid gyre and gimbol in the wabe\r\nor something like that...\""],
15+
["string", "\"g:\\\\3dsmax25\\\\scenes\""],
16+
["string", "@\"g:\\temp\\newfolder\\render\""]
17+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2.5s
2+
1m15s
3+
2m30s5f2t
4+
125f
5+
18.25f
6+
1f20t
7+
2:10.0
8+
0:0.29
9+
10+
----------------------------------------------------
11+
12+
[
13+
["time", "2.5s"],
14+
["time", "1m15s"],
15+
["time", "2m30s5f2t"],
16+
["time", "125f"],
17+
["time", "18.25f"],
18+
["time", "1f20t"],
19+
["time", "2:10.0"],
20+
["time", "0:0.29"]
21+
]

0 commit comments

Comments
 (0)
Please sign in to comment.