Skip to content

Commit 4fbdd2f

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

19 files changed

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

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

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

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

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

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

0 commit comments

Comments
 (0)