1 | (function (Prism) {
|
---|
2 | var variable = /\$\w+|%[a-z]+%/;
|
---|
3 |
|
---|
4 | var arrowAttr = /\[[^[\]]*\]/.source;
|
---|
5 | var arrowDirection = /(?:[drlu]|do|down|le|left|ri|right|up)/.source;
|
---|
6 | var arrowBody = '(?:-+' + arrowDirection + '-+|\\.+' + arrowDirection + '\\.+|-+(?:' + arrowAttr + '-*)?|' + arrowAttr + '-+|\\.+(?:' + arrowAttr + '\\.*)?|' + arrowAttr + '\\.+)';
|
---|
7 | var arrowLeft = /(?:<{1,2}|\/{1,2}|\\{1,2}|<\||[#*^+}xo])/.source;
|
---|
8 | var arrowRight = /(?:>{1,2}|\/{1,2}|\\{1,2}|\|>|[#*^+{xo])/.source;
|
---|
9 | var arrowPrefix = /[[?]?[ox]?/.source;
|
---|
10 | var arrowSuffix = /[ox]?[\]?]?/.source;
|
---|
11 | var arrow =
|
---|
12 | arrowPrefix +
|
---|
13 | '(?:' +
|
---|
14 | arrowBody + arrowRight +
|
---|
15 | '|' +
|
---|
16 | arrowLeft + arrowBody + '(?:' + arrowRight + ')?' +
|
---|
17 | ')' +
|
---|
18 | arrowSuffix;
|
---|
19 |
|
---|
20 | Prism.languages['plant-uml'] = {
|
---|
21 | 'comment': {
|
---|
22 | pattern: /(^[ \t]*)(?:'.*|\/'[\s\S]*?'\/)/m,
|
---|
23 | lookbehind: true,
|
---|
24 | greedy: true
|
---|
25 | },
|
---|
26 | 'preprocessor': {
|
---|
27 | pattern: /(^[ \t]*)!.*/m,
|
---|
28 | lookbehind: true,
|
---|
29 | greedy: true,
|
---|
30 | alias: 'property',
|
---|
31 | inside: {
|
---|
32 | 'variable': variable
|
---|
33 | }
|
---|
34 | },
|
---|
35 | 'delimiter': {
|
---|
36 | pattern: /(^[ \t]*)@(?:end|start)uml\b/m,
|
---|
37 | lookbehind: true,
|
---|
38 | greedy: true,
|
---|
39 | alias: 'punctuation'
|
---|
40 | },
|
---|
41 |
|
---|
42 | 'arrow': {
|
---|
43 | pattern: RegExp(/(^|[^-.<>?|\\[\]ox])/.source + arrow + /(?![-.<>?|\\\]ox])/.source),
|
---|
44 | lookbehind: true,
|
---|
45 | greedy: true,
|
---|
46 | alias: 'operator',
|
---|
47 | inside: {
|
---|
48 | 'expression': {
|
---|
49 | pattern: /(\[)[^[\]]+(?=\])/,
|
---|
50 | lookbehind: true,
|
---|
51 | inside: null // see below
|
---|
52 | },
|
---|
53 | 'punctuation': /\[(?=$|\])|^\]/
|
---|
54 | }
|
---|
55 | },
|
---|
56 |
|
---|
57 | 'string': {
|
---|
58 | pattern: /"[^"]*"/,
|
---|
59 | greedy: true
|
---|
60 | },
|
---|
61 | 'text': {
|
---|
62 | pattern: /(\[[ \t]*[\r\n]+(?![\r\n]))[^\]]*(?=\])/,
|
---|
63 | lookbehind: true,
|
---|
64 | greedy: true,
|
---|
65 | alias: 'string'
|
---|
66 | },
|
---|
67 |
|
---|
68 | 'keyword': [
|
---|
69 | {
|
---|
70 | pattern: /^([ \t]*)(?:abstract\s+class|end\s+(?:box|fork|group|merge|note|ref|split|title)|(?:fork|split)(?:\s+again)?|activate|actor|agent|alt|annotation|artifact|autoactivate|autonumber|backward|binary|boundary|box|break|caption|card|case|circle|class|clock|cloud|collections|component|concise|control|create|critical|database|deactivate|destroy|detach|diamond|else|elseif|end|end[hr]note|endif|endswitch|endwhile|entity|enum|file|folder|footer|frame|group|[hr]?note|header|hexagon|hide|if|interface|label|legend|loop|map|namespace|network|newpage|node|nwdiag|object|opt|package|page|par|participant|person|queue|rectangle|ref|remove|repeat|restore|return|robust|scale|set|show|skinparam|stack|start|state|stop|storage|switch|title|together|usecase|usecase\/|while)(?=\s|$)/m,
|
---|
71 | lookbehind: true,
|
---|
72 | greedy: true
|
---|
73 | },
|
---|
74 | /\b(?:elseif|equals|not|while)(?=\s*\()/,
|
---|
75 | /\b(?:as|is|then)\b/
|
---|
76 | ],
|
---|
77 |
|
---|
78 | 'divider': {
|
---|
79 | pattern: /^==.+==$/m,
|
---|
80 | greedy: true,
|
---|
81 | alias: 'important'
|
---|
82 | },
|
---|
83 |
|
---|
84 | 'time': {
|
---|
85 | pattern: /@(?:\d+(?:[:/]\d+){2}|[+-]?\d+|:[a-z]\w*(?:[+-]\d+)?)\b/i,
|
---|
86 | greedy: true,
|
---|
87 | alias: 'number'
|
---|
88 | },
|
---|
89 |
|
---|
90 | 'color': {
|
---|
91 | pattern: /#(?:[a-z_]+|[a-fA-F0-9]+)\b/,
|
---|
92 | alias: 'symbol'
|
---|
93 | },
|
---|
94 | 'variable': variable,
|
---|
95 |
|
---|
96 | 'punctuation': /[:,;()[\]{}]|\.{3}/
|
---|
97 | };
|
---|
98 |
|
---|
99 | Prism.languages['plant-uml'].arrow.inside.expression.inside = Prism.languages['plant-uml'];
|
---|
100 |
|
---|
101 | Prism.languages['plantuml'] = Prism.languages['plant-uml'];
|
---|
102 |
|
---|
103 | }(Prism));
|
---|