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-vala.js | |
| parent | ab355897a12b7bda1089a44de326d41455a0f7a3 (diff) | |
chore: add prismjs for syntax highlighting
Diffstat (limited to 'public/prism/prism-vala.js')
| -rw-r--r-- | public/prism/prism-vala.js | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/public/prism/prism-vala.js b/public/prism/prism-vala.js new file mode 100644 index 0000000..b98969c --- /dev/null +++ b/public/prism/prism-vala.js @@ -0,0 +1,89 @@ +Prism.languages.vala = Prism.languages.extend('clike', { + // Classes copied from prism-csharp + 'class-name': [ + { + // (Foo bar, Bar baz) + pattern: /\b[A-Z]\w*(?:\.\w+)*\b(?=(?:\?\s+|\*?\s+\*?)\w)/, + inside: { + punctuation: /\./, + }, + }, + { + // [Foo] + pattern: /(\[)[A-Z]\w*(?:\.\w+)*\b/, + lookbehind: true, + inside: { + punctuation: /\./, + }, + }, + { + // class Foo : Bar + pattern: + /(\b(?:class|interface)\s+[A-Z]\w*(?:\.\w+)*\s*:\s*)[A-Z]\w*(?:\.\w+)*\b/, + lookbehind: true, + inside: { + punctuation: /\./, + }, + }, + { + // class Foo + pattern: + /((?:\b(?:class|enum|interface|new|struct)\s+)|(?:catch\s+\())[A-Z]\w*(?:\.\w+)*\b/, + lookbehind: true, + inside: { + punctuation: /\./, + }, + }, + ], + keyword: + /\b(?:abstract|as|assert|async|base|bool|break|case|catch|char|class|const|construct|continue|default|delegate|delete|do|double|dynamic|else|ensures|enum|errordomain|extern|finally|float|for|foreach|get|if|in|inline|int|int16|int32|int64|int8|interface|internal|is|lock|long|namespace|new|null|out|override|owned|params|private|protected|public|ref|requires|return|set|short|signal|sizeof|size_t|ssize_t|static|string|struct|switch|this|throw|throws|try|typeof|uchar|uint|uint16|uint32|uint64|uint8|ulong|unichar|unowned|ushort|using|value|var|virtual|void|volatile|weak|while|yield)\b/i, + function: /\b\w+(?=\s*\()/, + number: + /(?:\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)(?:f|u?l?)?/i, + operator: /\+\+|--|&&|\|\||<<=?|>>=?|=>|->|~|[+\-*\/%&^|=!<>]=?|\?\??|\.\.\./, + punctuation: /[{}[\];(),.:]/, + constant: /\b[A-Z0-9_]+\b/, +}); + +Prism.languages.insertBefore('vala', 'string', { + 'raw-string': { + pattern: /"""[\s\S]*?"""/, + greedy: true, + alias: 'string', + }, + 'template-string': { + pattern: /@"[\s\S]*?"/, + greedy: true, + inside: { + interpolation: { + pattern: /\$(?:\([^)]*\)|[a-zA-Z]\w*)/, + inside: { + delimiter: { + pattern: /^\$\(?|\)$/, + alias: 'punctuation', + }, + rest: Prism.languages.vala, + }, + }, + string: /[\s\S]+/, + }, + }, +}); + +Prism.languages.insertBefore('vala', 'keyword', { + regex: { + pattern: + /\/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[imsx]{0,4}(?=\s*(?:$|[\r\n,.;})\]]))/, + greedy: true, + inside: { + 'regex-source': { + pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/, + lookbehind: true, + alias: 'language-regex', + inside: Prism.languages.regex, + }, + 'regex-delimiter': /^\//, + 'regex-flags': /^[a-z]+$/, + }, + }, +}); |
