From a98b5ea6fe8e8cc98a55e0fd793e6e8660ea31c1 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Thu, 30 Dec 2021 19:47:21 +0100 Subject: chore: add prismjs for syntax highlighting --- public/prism/prism-csharp.min.js | 254 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 254 insertions(+) create mode 100644 public/prism/prism-csharp.min.js (limited to 'public/prism/prism-csharp.min.js') diff --git a/public/prism/prism-csharp.min.js b/public/prism/prism-csharp.min.js new file mode 100644 index 0000000..bb80a4c --- /dev/null +++ b/public/prism/prism-csharp.min.js @@ -0,0 +1,254 @@ +!(function (s) { + function a(e, s) { + return e.replace(/<<(\d+)>>/g, function (e, n) { + return '(?:' + s[+n] + ')'; + }); + } + function t(e, n, s) { + return RegExp(a(e, n), s || ''); + } + function e(e, n) { + for (var s = 0; s < n; s++) + e = e.replace(/<>/g, function () { + return '(?:' + e + ')'; + }); + return e.replace(/<>/g, '[^\\s\\S]'); + } + var n = + 'bool byte char decimal double dynamic float int long object sbyte short string uint ulong ushort var void', + r = 'class enum interface record struct', + i = + 'add alias and ascending async await by descending from(?=\\s*(?:\\w|$)) get global group into init(?=\\s*;) join let nameof not notnull on or orderby partial remove select set unmanaged value when where with(?=\\s*{)', + o = + 'abstract as base break case catch checked const continue default delegate do else event explicit extern finally fixed for foreach goto if implicit in internal is lock namespace new null operator out override params private protected public readonly ref return sealed sizeof stackalloc static switch this throw try typeof unchecked unsafe using virtual volatile while yield'; + function l(e) { + return '\\b(?:' + e.trim().replace(/ /g, '|') + ')\\b'; + } + var d = l(r), + p = RegExp(l(n + ' ' + r + ' ' + i + ' ' + o)), + c = l(r + ' ' + i + ' ' + o), + u = l(n + ' ' + r + ' ' + o), + g = e('<(?:[^<>;=+\\-*/%&|^]|<>)*>', 2), + b = e('\\((?:[^()]|<>)*\\)', 2), + h = '@?\\b[A-Za-z_]\\w*\\b', + f = a('<<0>>(?:\\s*<<1>>)?', [h, g]), + m = a('(?!<<0>>)<<1>>(?:\\s*\\.\\s*<<1>>)*', [c, f]), + k = '\\[\\s*(?:,\\s*)*\\]', + y = a('<<0>>(?:\\s*(?:\\?\\s*)?<<1>>)*(?:\\s*\\?)?', [m, k]), + w = a('(?:<<0>>|<<1>>)(?:\\s*(?:\\?\\s*)?<<2>>)*(?:\\s*\\?)?', [ + a('\\(<<0>>+(?:,<<0>>+)+\\)', [ + a('[^,()<>[\\];=+\\-*/%&|^]|<<0>>|<<1>>|<<2>>', [g, b, k]), + ]), + m, + k, + ]), + v = { keyword: p, punctuation: /[<>()?,.:[\]]/ }, + x = "'(?:[^\r\n'\\\\]|\\\\.|\\\\[Uux][\\da-fA-F]{1,8})'", + $ = '"(?:\\\\.|[^\\\\"\r\n])*"'; + (s.languages.csharp = s.languages.extend('clike', { + string: [ + { + pattern: t('(^|[^$\\\\])<<0>>', ['@"(?:""|\\\\[^]|[^\\\\"])*"(?!")']), + lookbehind: !0, + greedy: !0, + }, + { pattern: t('(^|[^@$\\\\])<<0>>', [$]), lookbehind: !0, greedy: !0 }, + ], + 'class-name': [ + { + pattern: t('(\\busing\\s+static\\s+)<<0>>(?=\\s*;)', [m]), + lookbehind: !0, + inside: v, + }, + { + pattern: t('(\\busing\\s+<<0>>\\s*=\\s*)<<1>>(?=\\s*;)', [h, w]), + lookbehind: !0, + inside: v, + }, + { pattern: t('(\\busing\\s+)<<0>>(?=\\s*=)', [h]), lookbehind: !0 }, + { pattern: t('(\\b<<0>>\\s+)<<1>>', [d, f]), lookbehind: !0, inside: v }, + { + pattern: t('(\\bcatch\\s*\\(\\s*)<<0>>', [m]), + lookbehind: !0, + inside: v, + }, + { pattern: t('(\\bwhere\\s+)<<0>>', [h]), lookbehind: !0 }, + { + pattern: t('(\\b(?:is(?:\\s+not)?|as)\\s+)<<0>>', [y]), + lookbehind: !0, + inside: v, + }, + { + pattern: t( + '\\b<<0>>(?=\\s+(?!<<1>>|with\\s*\\{)<<2>>(?:\\s*[=,;:{)\\]]|\\s+(?:in|when)\\b))', + [w, u, h] + ), + inside: v, + }, + ], + keyword: p, + number: + /(?:\b0(?:x[\da-f_]*[\da-f]|b[01_]*[01])|(?:\B\.\d+(?:_+\d+)*|\b\d+(?:_+\d+)*(?:\.\d+(?:_+\d+)*)?)(?:e[-+]?\d+(?:_+\d+)*)?)(?:[dflmu]|lu|ul)?\b/i, + operator: />>=?|<<=?|[-=]>|([-+&|])\1|~|\?\?=?|[-+*/%&|^!=<>]=?/, + punctuation: /\?\.?|::|[{}[\];(),.:]/, + })), + s.languages.insertBefore('csharp', 'number', { + range: { pattern: /\.\./, alias: 'operator' }, + }), + s.languages.insertBefore('csharp', 'punctuation', { + 'named-parameter': { + pattern: t('([(,]\\s*)<<0>>(?=\\s*:)', [h]), + lookbehind: !0, + alias: 'punctuation', + }, + }), + s.languages.insertBefore('csharp', 'class-name', { + namespace: { + pattern: t( + '(\\b(?:namespace|using)\\s+)<<0>>(?:\\s*\\.\\s*<<0>>)*(?=\\s*[;{])', + [h] + ), + lookbehind: !0, + inside: { punctuation: /\./ }, + }, + 'type-expression': { + pattern: t( + '(\\b(?:default|sizeof|typeof)\\s*\\(\\s*(?!\\s))(?:[^()\\s]|\\s(?!\\s)|<<0>>)*(?=\\s*\\))', + [b] + ), + lookbehind: !0, + alias: 'class-name', + inside: v, + }, + 'return-type': { + pattern: t( + '<<0>>(?=\\s+(?:<<1>>\\s*(?:=>|[({]|\\.\\s*this\\s*\\[)|this\\s*\\[))', + [w, m] + ), + inside: v, + alias: 'class-name', + }, + 'constructor-invocation': { + pattern: t('(\\bnew\\s+)<<0>>(?=\\s*[[({])', [w]), + lookbehind: !0, + inside: v, + alias: 'class-name', + }, + 'generic-method': { + pattern: t('<<0>>\\s*<<1>>(?=\\s*\\()', [h, g]), + inside: { + function: t('^<<0>>', [h]), + generic: { pattern: RegExp(g), alias: 'class-name', inside: v }, + }, + }, + 'type-list': { + pattern: t( + '\\b((?:<<0>>\\s+<<1>>|record\\s+<<1>>\\s*<<5>>|where\\s+<<2>>)\\s*:\\s*)(?:<<3>>|<<4>>|<<1>>\\s*<<5>>|<<6>>)(?:\\s*,\\s*(?:<<3>>|<<4>>|<<6>>))*(?=\\s*(?:where|[{;]|=>|$))', + [d, f, h, w, p.source, b, '\\bnew\\s*\\(\\s*\\)'] + ), + lookbehind: !0, + inside: { + 'record-arguments': { + pattern: t('(^(?!new\\s*\\()<<0>>\\s*)<<1>>', [f, b]), + lookbehind: !0, + greedy: !0, + inside: s.languages.csharp, + }, + keyword: p, + 'class-name': { pattern: RegExp(w), greedy: !0, inside: v }, + punctuation: /[,()]/, + }, + }, + preprocessor: { + pattern: /(^[\t ]*)#.*/m, + lookbehind: !0, + alias: 'property', + inside: { + directive: { + pattern: + /(#)\b(?:define|elif|else|endif|endregion|error|if|line|nullable|pragma|region|undef|warning)\b/, + lookbehind: !0, + alias: 'keyword', + }, + }, + }, + }); + var _ = $ + '|' + x, + B = a('/(?![*/])|//[^\r\n]*[\r\n]|/\\*(?:[^*]|\\*(?!/))*\\*/|<<0>>', [_]), + E = e(a('[^"\'/()]|<<0>>|\\(<>*\\)', [B]), 2), + R = + '\\b(?:assembly|event|field|method|module|param|property|return|type)\\b', + z = a('<<0>>(?:\\s*\\(<<1>>*\\))?', [m, E]); + s.languages.insertBefore('csharp', 'class-name', { + attribute: { + pattern: t( + '((?:^|[^\\s\\w>)?])\\s*\\[\\s*)(?:<<0>>\\s*:\\s*)?<<1>>(?:\\s*,\\s*<<1>>)*(?=\\s*\\])', + [R, z] + ), + lookbehind: !0, + greedy: !0, + inside: { + target: { pattern: t('^<<0>>(?=\\s*:)', [R]), alias: 'keyword' }, + 'attribute-arguments': { + pattern: t('\\(<<0>>*\\)', [E]), + inside: s.languages.csharp, + }, + 'class-name': { pattern: RegExp(m), inside: { punctuation: /\./ } }, + punctuation: /[:,]/, + }, + }, + }); + var S = ':[^}\r\n]+', + j = e(a('[^"\'/()]|<<0>>|\\(<>*\\)', [B]), 2), + A = a('\\{(?!\\{)(?:(?![}:])<<0>>)*<<1>>?\\}', [j, S]), + F = e( + a('[^"\'/()]|/(?!\\*)|/\\*(?:[^*]|\\*(?!/))*\\*/|<<0>>|\\(<>*\\)', [ + _, + ]), + 2 + ), + P = a('\\{(?!\\{)(?:(?![}:])<<0>>)*<<1>>?\\}', [F, S]); + function U(e, n) { + return { + interpolation: { + pattern: t('((?:^|[^{])(?:\\{\\{)*)<<0>>', [e]), + lookbehind: !0, + inside: { + 'format-string': { + pattern: t('(^\\{(?:(?![}:])<<0>>)*)<<1>>(?=\\}$)', [n, S]), + lookbehind: !0, + inside: { punctuation: /^:/ }, + }, + punctuation: /^\{|\}$/, + expression: { + pattern: /[\s\S]+/, + alias: 'language-csharp', + inside: s.languages.csharp, + }, + }, + }, + string: /[\s\S]+/, + }; + } + s.languages.insertBefore('csharp', 'string', { + 'interpolation-string': [ + { + pattern: t( + '(^|[^\\\\])(?:\\$@|@\\$)"(?:""|\\\\[^]|\\{\\{|<<0>>|[^\\\\{"])*"', + [A] + ), + lookbehind: !0, + greedy: !0, + inside: U(A, j), + }, + { + pattern: t('(^|[^@\\\\])\\$"(?:\\\\.|\\{\\{|<<0>>|[^\\\\"{])*"', [P]), + lookbehind: !0, + greedy: !0, + inside: U(P, F), + }, + ], + char: { pattern: RegExp(x), greedy: !0 }, + }), + (s.languages.dotnet = s.languages.cs = s.languages.csharp); +})(Prism); -- cgit v1.2.3