1 | (function (Prism) {
|
---|
2 |
|
---|
3 | var schemeExpression = /\((?:[^();"#\\]|\\[\s\S]|;.*(?!.)|"(?:[^"\\]|\\.)*"|#(?:\{(?:(?!#\})[\s\S])*#\}|[^{])|<expr>)*\)/.source;
|
---|
4 | // allow for up to pow(2, recursivenessLog2) many levels of recursive brace expressions
|
---|
5 | // For some reason, this can't be 4
|
---|
6 | var recursivenessLog2 = 5;
|
---|
7 | for (var i = 0; i < recursivenessLog2; i++) {
|
---|
8 | schemeExpression = schemeExpression.replace(/<expr>/g, function () { return schemeExpression; });
|
---|
9 | }
|
---|
10 | schemeExpression = schemeExpression.replace(/<expr>/g, /[^\s\S]/.source);
|
---|
11 |
|
---|
12 |
|
---|
13 | var lilypond = Prism.languages.lilypond = {
|
---|
14 | 'comment': /%(?:(?!\{).*|\{[\s\S]*?%\})/,
|
---|
15 | 'embedded-scheme': {
|
---|
16 | pattern: RegExp(/(^|[=\s])#(?:"(?:[^"\\]|\\.)*"|[^\s()"]*(?:[^\s()]|<expr>))/.source.replace(/<expr>/g, function () { return schemeExpression; }), 'm'),
|
---|
17 | lookbehind: true,
|
---|
18 | greedy: true,
|
---|
19 | inside: {
|
---|
20 | 'scheme': {
|
---|
21 | pattern: /^(#)[\s\S]+$/,
|
---|
22 | lookbehind: true,
|
---|
23 | alias: 'language-scheme',
|
---|
24 | inside: {
|
---|
25 | 'embedded-lilypond': {
|
---|
26 | pattern: /#\{[\s\S]*?#\}/,
|
---|
27 | greedy: true,
|
---|
28 | inside: {
|
---|
29 | 'punctuation': /^#\{|#\}$/,
|
---|
30 | 'lilypond': {
|
---|
31 | pattern: /[\s\S]+/,
|
---|
32 | alias: 'language-lilypond',
|
---|
33 | inside: null // see below
|
---|
34 | }
|
---|
35 | }
|
---|
36 | },
|
---|
37 | rest: Prism.languages.scheme
|
---|
38 | }
|
---|
39 | },
|
---|
40 | 'punctuation': /#/
|
---|
41 | }
|
---|
42 | },
|
---|
43 | 'string': {
|
---|
44 | pattern: /"(?:[^"\\]|\\.)*"/,
|
---|
45 | greedy: true
|
---|
46 | },
|
---|
47 | 'class-name': {
|
---|
48 | pattern: /(\\new\s+)[\w-]+/,
|
---|
49 | lookbehind: true
|
---|
50 | },
|
---|
51 | 'keyword': {
|
---|
52 | pattern: /\\[a-z][-\w]*/i,
|
---|
53 | inside: {
|
---|
54 | 'punctuation': /^\\/
|
---|
55 | }
|
---|
56 | },
|
---|
57 | 'operator': /[=|]|<<|>>/,
|
---|
58 | 'punctuation': {
|
---|
59 | pattern: /(^|[a-z\d])(?:'+|,+|[_^]?-[_^]?(?:[-+^!>._]|(?=\d))|[_^]\.?|[.!])|[{}()[\]<>^~]|\\[()[\]<>\\!]|--|__/,
|
---|
60 | lookbehind: true
|
---|
61 | },
|
---|
62 | 'number': /\b\d+(?:\/\d+)?\b/
|
---|
63 | };
|
---|
64 |
|
---|
65 | lilypond['embedded-scheme'].inside['scheme'].inside['embedded-lilypond'].inside['lilypond'].inside = lilypond;
|
---|
66 |
|
---|
67 | Prism.languages.ly = lilypond;
|
---|
68 |
|
---|
69 | }(Prism));
|
---|