Skip to content

Commit 0d49553

Browse files
Added support for PlantUML (#3372)
1 parent 554ff32 commit 0d49553

20 files changed

+1011
-3
lines changed

components.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components.json

+5
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,11 @@
10271027
"modify": "php",
10281028
"owner": "milesj"
10291029
},
1030+
"plant-uml": {
1031+
"title": "PlantUML",
1032+
"alias": "plantuml",
1033+
"owner": "RunDevelopment"
1034+
},
10301035
"plsql": {
10311036
"title": "PL/SQL",
10321037
"require": "sql",

components/prism-plant-uml.js

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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));

components/prism-plant-uml.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/prism-plant-uml.html

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<h2>Full example</h2>
2+
<pre><code>' Source: https://plantuml.com/sequence-diagram
3+
@startuml
4+
participant Participant as Foo
5+
actor Actor as Foo1
6+
boundary Boundary as Foo2
7+
control Control as Foo3
8+
entity Entity as Foo4
9+
database Database as Foo5
10+
collections Collections as Foo6
11+
queue Queue as Foo7
12+
Foo -> Foo1 : To actor
13+
Foo -> Foo2 : To boundary
14+
Foo -> Foo3 : To control
15+
Foo -> Foo4 : To entity
16+
Foo -> Foo5 : To database
17+
Foo -> Foo6 : To collections
18+
Foo -> Foo7 : To queue
19+
@enduml
20+
</code></pre>

plugins/autoloader/prism-autoloader.js

+1
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@
227227
"objectpascal": "pascal",
228228
"px": "pcaxis",
229229
"pcode": "peoplecode",
230+
"plantuml": "plant-uml",
230231
"pq": "powerquery",
231232
"mscript": "powerquery",
232233
"pbfasm": "purebasic",

plugins/autoloader/prism-autoloader.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/show-language/prism-show-language.js

+2
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@
187187
"php": "PHP",
188188
"phpdoc": "PHPDoc",
189189
"php-extras": "PHP Extras",
190+
"plant-uml": "PlantUML",
191+
"plantuml": "PlantUML",
190192
"plsql": "PL/SQL",
191193
"powerquery": "PowerQuery",
192194
"pq": "PowerQuery",

0 commit comments

Comments
 (0)