|
| 1 | +(function (Prism) { |
| 2 | + /** |
| 3 | + * @param {string} lang |
| 4 | + * @param {string} pattern |
| 5 | + */ |
| 6 | + var createLanguageString = function (lang, pattern) { |
| 7 | + return { |
| 8 | + pattern: RegExp(/\{!/.source + '(?:' + (pattern || lang) + ')' + /$[\s\S]*\}/.source, 'm'), |
| 9 | + greedy: true, |
| 10 | + inside: { |
| 11 | + 'embedded': { |
| 12 | + pattern: /(^\{!\w+\b)[\s\S]+(?=\}$)/, |
| 13 | + lookbehind: true, |
| 14 | + alias: 'language-' + lang, |
| 15 | + inside: Prism.languages[lang] |
| 16 | + }, |
| 17 | + 'string': /[\s\S]+/ |
| 18 | + } |
| 19 | + }; |
| 20 | + }; |
| 21 | + |
| 22 | + Prism.languages.arturo = { |
| 23 | + 'comment': { |
| 24 | + pattern: /;.*/, |
| 25 | + greedy: true |
| 26 | + }, |
| 27 | + |
| 28 | + 'character': { |
| 29 | + pattern: /`.`/, |
| 30 | + alias: 'char', |
| 31 | + greedy: true |
| 32 | + }, |
| 33 | + |
| 34 | + 'number': { |
| 35 | + pattern: /\b\d+(?:\.\d+(?:\.\d+(?:-[\w+-]+)?)?)?\b/, |
| 36 | + }, |
| 37 | + |
| 38 | + 'string': { |
| 39 | + pattern: /"(?:[^"\\\r\n]|\\.)*"/, |
| 40 | + greedy: true |
| 41 | + }, |
| 42 | + |
| 43 | + 'regex': { |
| 44 | + pattern: /\{\/.*?\/\}/, |
| 45 | + greedy: true |
| 46 | + }, |
| 47 | + |
| 48 | + 'html-string': createLanguageString('html'), |
| 49 | + 'css-string': createLanguageString('css'), |
| 50 | + 'js-string': createLanguageString('js'), |
| 51 | + 'md-string': createLanguageString('md'), |
| 52 | + 'sql-string': createLanguageString('sql'), |
| 53 | + 'sh-string': createLanguageString('shell', 'sh'), |
| 54 | + |
| 55 | + 'multistring': { |
| 56 | + pattern: /».*|\{:[\s\S]*?:\}|\{[\s\S]*?\}|^-{6}$[\s\S]*/m, |
| 57 | + alias: 'string', |
| 58 | + greedy: true |
| 59 | + }, |
| 60 | + |
| 61 | + 'label': { |
| 62 | + pattern: /\w+\b\??:/, |
| 63 | + alias: 'property' |
| 64 | + }, |
| 65 | + |
| 66 | + 'literal': { |
| 67 | + pattern: /'(?:\w+\b\??:?)/, |
| 68 | + alias: 'constant' |
| 69 | + }, |
| 70 | + |
| 71 | + 'type': { |
| 72 | + pattern: /:(?:\w+\b\??:?)/, |
| 73 | + alias: 'class-name' |
| 74 | + }, |
| 75 | + |
| 76 | + 'color': /#\w+/, |
| 77 | + |
| 78 | + 'predicate': { |
| 79 | + pattern: /\b(?:all|and|any|ascii|attr|attribute|attributeLabel|binary|block|char|contains|database|date|dictionary|empty|equal|even|every|exists|false|floating|function|greater|greaterOrEqual|if|in|inline|integer|is|key|label|leap|less|lessOrEqual|literal|logical|lower|nand|negative|nor|not|notEqual|null|numeric|odd|or|path|pathLabel|positive|prefix|prime|regex|same|set|some|sorted|standalone|string|subset|suffix|superset|symbol|symbolLiteral|true|try|type|unless|upper|when|whitespace|word|xnor|xor|zero)\?/, |
| 80 | + alias: 'keyword' |
| 81 | + }, |
| 82 | + |
| 83 | + 'builtin-function': { |
| 84 | + pattern: /\b(?:abs|acos|acosh|acsec|acsech|actan|actanh|add|after|alert|alias|and|angle|append|arg|args|arity|array|as|asec|asech|asin|asinh|atan|atan2|atanh|attr|attrs|average|before|benchmark|blend|break|call|capitalize|case|ceil|chop|clear|clip|close|color|combine|conj|continue|copy|cos|cosh|crc|csec|csech|ctan|ctanh|cursor|darken|dec|decode|define|delete|desaturate|deviation|dialog|dictionary|difference|digest|digits|div|do|download|drop|dup|e|else|empty|encode|ensure|env|escape|execute|exit|exp|extend|extract|factors|fdiv|filter|first|flatten|floor|fold|from|function|gamma|gcd|get|goto|hash|hypot|if|inc|indent|index|infinity|info|input|insert|inspect|intersection|invert|jaro|join|keys|kurtosis|last|let|levenshtein|lighten|list|ln|log|loop|lower|mail|map|match|max|median|min|mod|module|mul|nand|neg|new|nor|normalize|not|now|null|open|or|outdent|pad|palette|panic|path|pause|permissions|permutate|pi|pop|popup|pow|powerset|powmod|prefix|print|prints|process|product|query|random|range|read|relative|remove|rename|render|repeat|replace|request|return|reverse|round|sample|saturate|script|sec|sech|select|serve|set|shl|shr|shuffle|sin|sinh|size|skewness|slice|sort|spin|split|sqrt|squeeze|stack|strip|sub|suffix|sum|switch|symbols|symlink|sys|take|tan|tanh|terminal|terminate|to|truncate|try|type|unclip|union|unique|unless|until|unzip|upper|values|var|variance|volume|webview|while|with|wordwrap|write|xnor|xor|zip)\b/, |
| 85 | + alias: 'keyword' |
| 86 | + }, |
| 87 | + |
| 88 | + 'sugar': { |
| 89 | + pattern: /->|=>|\||::/, |
| 90 | + alias: 'operator' |
| 91 | + }, |
| 92 | + |
| 93 | + 'punctuation': /[()[\],]/, |
| 94 | + |
| 95 | + 'symbol': { |
| 96 | + pattern: /<:|-:|ø|@|#|\+|\||\*|\$|---|-|%|\/|\.\.|\^|~|=|<|>|\\/ |
| 97 | + }, |
| 98 | + |
| 99 | + 'boolean': { |
| 100 | + pattern: /\b(?:false|maybe|true)\b/ |
| 101 | + } |
| 102 | + }; |
| 103 | + |
| 104 | + Prism.languages.art = Prism.languages['arturo']; |
| 105 | +}(Prism)); |
1 commit comments
celtic-coder commentedon Mar 21, 2022
Great work - well done! 👍