Skip to content

Commit

Permalink
Added support for Arturo (#3403)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Schmidt <msrd0000@gmail.com>
  • Loading branch information
drkameleon and RunDevelopment authored Mar 21, 2022
1 parent 63806d5 commit e2fe1f7
Show file tree
Hide file tree
Showing 31 changed files with 1,501 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,19 @@
"alias": "arm-asm",
"owner": "RunDevelopment"
},
"arturo": {
"title": "Arturo",
"alias": "art",
"optional": [
"bash",
"css",
"javascript",
"markup",
"markdown",
"sql"
],
"owner": "drkameleon"
},
"asciidoc": {
"alias": "adoc",
"title": "AsciiDoc",
Expand Down
105 changes: 105 additions & 0 deletions components/prism-arturo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
(function (Prism) {
/**
* @param {string} lang
* @param {string} pattern
*/
var createLanguageString = function (lang, pattern) {
return {
pattern: RegExp(/\{!/.source + '(?:' + (pattern || lang) + ')' + /$[\s\S]*\}/.source, 'm'),
greedy: true,
inside: {
'embedded': {
pattern: /(^\{!\w+\b)[\s\S]+(?=\}$)/,
lookbehind: true,
alias: 'language-' + lang,
inside: Prism.languages[lang]
},
'string': /[\s\S]+/
}
};
};

Prism.languages.arturo = {
'comment': {
pattern: /;.*/,
greedy: true
},

'character': {
pattern: /`.`/,
alias: 'char',
greedy: true
},

'number': {
pattern: /\b\d+(?:\.\d+(?:\.\d+(?:-[\w+-]+)?)?)?\b/,
},

'string': {
pattern: /"(?:[^"\\\r\n]|\\.)*"/,
greedy: true
},

'regex': {
pattern: /\{\/.*?\/\}/,
greedy: true
},

'html-string': createLanguageString('html'),
'css-string': createLanguageString('css'),
'js-string': createLanguageString('js'),
'md-string': createLanguageString('md'),
'sql-string': createLanguageString('sql'),
'sh-string': createLanguageString('shell', 'sh'),

'multistring': {
pattern: /».*|\{:[\s\S]*?:\}|\{[\s\S]*?\}|^-{6}$[\s\S]*/m,
alias: 'string',
greedy: true
},

'label': {
pattern: /\w+\b\??:/,
alias: 'property'
},

'literal': {
pattern: /'(?:\w+\b\??:?)/,
alias: 'constant'
},

'type': {
pattern: /:(?:\w+\b\??:?)/,
alias: 'class-name'
},

'color': /#\w+/,

'predicate': {
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)\?/,
alias: 'keyword'
},

'builtin-function': {
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/,
alias: 'keyword'
},

'sugar': {
pattern: /->|=>|\||::/,
alias: 'operator'
},

'punctuation': /[()[\],]/,

'symbol': {
pattern: /<:|-:|ø|@|#|\+|\||\*|\$|---|-|%|\/|\.\.|\^|~|=|<|>|\\/
},

'boolean': {
pattern: /\b(?:false|maybe|true)\b/
}
};

Prism.languages.art = Prism.languages['arturo'];
}(Prism));
1 change: 1 addition & 0 deletions components/prism-arturo.min.js

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

Loading

1 comment on commit e2fe1f7

@celtic-coder
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work - well done! 👍

Please sign in to comment.