1 |
|
2 |
|
3 | (function (Prism) {
|
4 |
|
5 | var ID = '(?:' + [
|
6 |
|
7 | /[a-zA-Z_\x80-\uFFFF][\w\x80-\uFFFF]*/.source,
|
8 |
|
9 | /-?(?:\.\d+|\d+(?:\.\d*)?)/.source,
|
10 |
|
11 | /"[^"\\]*(?:\\[\s\S][^"\\]*)*"/.source,
|
12 |
|
13 | /<(?:[^<>]|(?!)*>/.source
|
14 | ].join('|') + ')';
|
15 |
|
16 | var IDInside = {
|
17 | 'markup': {
|
18 | pattern: /(^<)[\s\S]+(?=>$)/,
|
19 | lookbehind: true,
|
20 | alias: ['language-markup', 'language-html', 'language-xml'],
|
21 | inside: Prism.languages.markup
|
22 | }
|
23 | };
|
24 |
|
25 | /**
|
26 | * @param {string} source
|
27 | * @param {string} flags
|
28 | * @returns {RegExp}
|
29 | */
|
30 | function withID(source, flags) {
|
31 | return RegExp(source.replace(/<ID>/g, function () { return ID; }), flags);
|
32 | }
|
33 |
|
34 | Prism.languages.dot = {
|
35 | 'comment': {
|
36 | pattern: /\/\/.*|\/\*[\s\S]*?\*\/|^#.*/m,
|
37 | greedy: true
|
38 | },
|
39 | 'graph-name': {
|
40 | pattern: withID(/(\b(?:digraph|graph|subgraph)[ \t\r\n]+)<ID>/.source, 'i'),
|
41 | lookbehind: true,
|
42 | greedy: true,
|
43 | alias: 'class-name',
|
44 | inside: IDInside
|
45 | },
|
46 | 'attr-value': {
|
47 | pattern: withID(/(=[ \t\r\n]*)<ID>/.source),
|
48 | lookbehind: true,
|
49 | greedy: true,
|
50 | inside: IDInside
|
51 | },
|
52 | 'attr-name': {
|
53 | pattern: withID(/([\[;, \t\r\n])<ID>(?=[ \t\r\n]*=)/.source),
|
54 | lookbehind: true,
|
55 | greedy: true,
|
56 | inside: IDInside
|
57 | },
|
58 | 'keyword': /\b(?:digraph|edge|graph|node|strict|subgraph)\b/i,
|
59 | 'compass-point': {
|
60 | pattern: /(:[ \t\r\n]*)(?:[ewc_]|[ns][ew]?)(?![\w\x80-\uFFFF])/,
|
61 | lookbehind: true,
|
62 | alias: 'builtin'
|
63 | },
|
64 | 'node': {
|
65 | pattern: withID(/(^|[^-.\w\x80-\uFFFF\\])<ID>/.source),
|
66 | lookbehind: true,
|
67 | greedy: true,
|
68 | inside: IDInside
|
69 | },
|
70 | 'operator': /[=:]|-[->]/,
|
71 | 'punctuation': /[\[\]{};,]/
|
72 | };
|
73 |
|
74 | Prism.languages.gv = Prism.languages.dot;
|
75 |
|
76 | }(Prism));
|