prism-arturo.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. Prism.languages.arturo = {
  22. 'comment': {
  23. pattern: /;.*/,
  24. greedy: true
  25. },
  26. 'character': {
  27. pattern: /`.`/,
  28. alias: 'char',
  29. greedy: true
  30. },
  31. 'number': {
  32. pattern: /\b\d+(?:\.\d+(?:\.\d+(?:-[\w+-]+)?)?)?\b/,
  33. },
  34. 'string': {
  35. pattern: /"(?:[^"\\\r\n]|\\.)*"/,
  36. greedy: true
  37. },
  38. 'regex': {
  39. pattern: /\{\/.*?\/\}/,
  40. greedy: true
  41. },
  42. 'html-string': createLanguageString('html'),
  43. 'css-string': createLanguageString('css'),
  44. 'js-string': createLanguageString('js'),
  45. 'md-string': createLanguageString('md'),
  46. 'sql-string': createLanguageString('sql'),
  47. 'sh-string': createLanguageString('shell', 'sh'),
  48. 'multistring': {
  49. pattern: /».*|\{:[\s\S]*?:\}|\{[\s\S]*?\}|^-{6}$[\s\S]*/m,
  50. alias: 'string',
  51. greedy: true
  52. },
  53. 'label': {
  54. pattern: /\w+\b\??:/,
  55. alias: 'property'
  56. },
  57. 'literal': {
  58. pattern: /'(?:\w+\b\??:?)/,
  59. alias: 'constant'
  60. },
  61. 'type': {
  62. pattern: /:(?:\w+\b\??:?)/,
  63. alias: 'class-name'
  64. },
  65. 'color': /#\w+/,
  66. 'predicate': {
  67. 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)\?/,
  68. alias: 'keyword'
  69. },
  70. 'builtin-function': {
  71. 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/,
  72. alias: 'keyword'
  73. },
  74. 'sugar': {
  75. pattern: /->|=>|\||::/,
  76. alias: 'operator'
  77. },
  78. 'punctuation': /[()[\],]/,
  79. 'symbol': {
  80. pattern: /<:|-:|ø|@|#|\+|\||\*|\$|---|-|%|\/|\.\.|\^|~|=|<|>|\\/
  81. },
  82. 'boolean': {
  83. pattern: /\b(?:false|maybe|true)\b/
  84. }
  85. };
  86. Prism.languages.art = Prism.languages['arturo'];
  87. }(Prism));