main
Last change
on this file since e48199a was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.4 KB
|
Line | |
---|
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 | // symlink
|
---|
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 | // folder
|
---|
47 |
|
---|
48 | // remove trailing /
|
---|
49 | env.content = env.content.replace(folderPattern, '$1');
|
---|
50 | classes.push('dir');
|
---|
51 | } else {
|
---|
52 | // file
|
---|
53 |
|
---|
54 | // remove trailing file marker
|
---|
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 | // Ex. 'foo.min.js' would become '<span class="token keyword ext-min-js ext-js">foo.min.js</span>'
|
---|
61 | classes.push('ext-' + parts.join('-'));
|
---|
62 | }
|
---|
63 | }
|
---|
64 |
|
---|
65 | if (env.content[0] === '.') {
|
---|
66 | classes.push('dotfile');
|
---|
67 | }
|
---|
68 | }
|
---|
69 | });
|
---|
70 | }());
|
---|
Note:
See
TracBrowser
for help on using the repository browser.