diff options
| author | Armand Philippot <git@armandphilippot.com> | 2021-12-30 19:47:21 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2021-12-30 19:47:21 +0100 |
| commit | a98b5ea6fe8e8cc98a55e0fd793e6e8660ea31c1 (patch) | |
| tree | 542810ab5aef99150db228bb54fd58303dcb31c7 /public/prism/prism-maxscript.js | |
| parent | ab355897a12b7bda1089a44de326d41455a0f7a3 (diff) | |
chore: add prismjs for syntax highlighting
Diffstat (limited to 'public/prism/prism-maxscript.js')
| -rw-r--r-- | public/prism/prism-maxscript.js | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/public/prism/prism-maxscript.js b/public/prism/prism-maxscript.js new file mode 100644 index 0000000..6660af1 --- /dev/null +++ b/public/prism/prism-maxscript.js @@ -0,0 +1,96 @@ +(function (Prism) { + var keywords = + /\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; + + Prism.languages.maxscript = { + comment: { + pattern: /\/\*[\s\S]*?(?:\*\/|$)|--.*/, + greedy: true, + }, + string: { + pattern: /(^|[^"\\@])(?:"(?:[^"\\]|\\[\s\S])*"|@"[^"]*")/, + lookbehind: true, + greedy: true, + }, + path: { + pattern: /\$(?:[\w/\\.*?]|'[^']*')*/, + greedy: true, + alias: 'string', + }, + + 'function-call': { + pattern: RegExp( + '((?:' + + // start of line + (/^/.source + + '|' + + // operators and other language constructs + /[;=<>+\-*/^({\[]/.source + + '|' + + // keywords as part of statements + /\b(?:and|by|case|catch|collect|do|else|if|in|not|or|return|then|to|try|where|while|with)\b/ + .source) + + ')[ \t]*)' + + '(?!' + + keywords.source + + ')' + + /[a-z_]\w*\b/.source + + '(?=[ \t]*(?:' + + // variable + ('(?!' + + keywords.source + + ')' + + /[a-z_]/.source + + '|' + + // number + /\d|-\.?\d/.source + + '|' + + // other expressions or literals + /[({'"$@#?]/.source) + + '))', + 'im' + ), + lookbehind: true, + greedy: true, + alias: 'function', + }, + + 'function-definition': { + pattern: /(\b(?:fn|function)\s+)\w+\b/i, + lookbehind: true, + alias: 'function', + }, + + argument: { + pattern: /\b[a-z_]\w*(?=:)/i, + alias: 'attr-name', + }, + + keyword: keywords, + boolean: /\b(?:false|true)\b/, + + time: { + pattern: + /(^|[^\w.])(?:(?:(?:\d+(?:\.\d*)?|\.\d+)(?:[eEdD][+-]\d+|[LP])?[msft])+|\d+:\d+(?:\.\d*)?)(?![\w.:])/, + lookbehind: true, + alias: 'number', + }, + number: [ + { + pattern: + /(^|[^\w.])(?:(?:\d+(?:\.\d*)?|\.\d+)(?:[eEdD][+-]\d+|[LP])?|0x[a-fA-F0-9]+)(?![\w.:])/, + lookbehind: true, + }, + /\b(?:e|pi)\b/, + ], + + constant: /\b(?:dontcollect|ok|silentValue|undefined|unsupplied)\b/, + color: { + pattern: /\b(?:black|blue|brown|gray|green|orange|red|white|yellow)\b/i, + alias: 'constant', + }, + + operator: /[-+*/<>=!]=?|[&^?]|#(?!\()/, + punctuation: /[()\[\]{}.:,;]|#(?=\()|\\$/m, + }; +})(Prism); |
