1 | (function () {
|
2 |
|
3 | if (typeof Prism === 'undefined') {
|
4 | return;
|
5 | }
|
6 |
|
7 | Prism.languages.treeview = {
|
8 | 'treeview-part': {
|
9 | pattern: /^.+/m,
|
10 | inside: {
|
11 | 'entry-line': [
|
12 | {
|
13 | pattern: /\|-- |├── /,
|
14 | alias: 'line-h'
|
15 | },
|
16 | {
|
17 | pattern: /\| {3}|│ {3}/,
|
18 | alias: 'line-v'
|
19 | },
|
20 | {
|
21 | pattern: /`-- |└── /,
|
22 | alias: 'line-v-last'
|
23 | },
|
24 | {
|
25 | pattern: / {4}/,
|
26 | alias: 'line-v-gap'
|
27 | }
|
28 | ],
|
29 | 'entry-name': {
|
30 | pattern: /.*\S.*/,
|
31 | inside: {
|
32 |
|
33 | 'operator': / -> /,
|
34 | }
|
35 | }
|
36 | }
|
37 | }
|
38 | };
|
39 |
|
40 | Prism.hooks.add('wrap', function (env) {
|
41 | if (env.language === 'treeview' && env.type === 'entry-name') {
|
42 | var classes = env.classes;
|
43 |
|
44 | var folderPattern = /(^|[^\\])\/\s*$/;
|
45 | if (folderPattern.test(env.content)) {
|
46 |
|
47 |
|
48 |
|
49 | env.content = env.content.replace(folderPattern, '$1');
|
50 | classes.push('dir');
|
51 | } else {
|
52 |
|
53 |
|
54 |
|
55 | env.content = env.content.replace(/(^|[^\\])[=*|]\s*$/, '$1');
|
56 |
|
57 | var parts = env.content.toLowerCase().replace(/\s+/g, '').split('.');
|
58 | while (parts.length > 1) {
|
59 | parts.shift();
|
60 |
|
61 | classes.push('ext-' + parts.join('-'));
|
62 | }
|
63 | }
|
64 |
|
65 | if (env.content[0] === '.') {
|
66 | classes.push('dotfile');
|
67 | }
|
68 | }
|
69 | });
|
70 | }());
|