efront 4.22.9 → 4.22.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/coms/frame/route.js +16 -3
- package/coms/reptile/colored_console.js +15 -18
- package/coms/reptile/colored_console_test.js +1 -0
- package/coms/reptile/colors.js +7 -1
- package/coms/zimoli/zimoli.js +29 -21
- package/coms//350/214/250/350/217/260//346/240/207/347/255/276/345/214/226.js +46 -26
- package/coms//350/214/250/350/217/260//346/270/262/346/237/223.js +3 -6
- package/package.json +1 -1
- package/public/efront.js +1 -1
package/coms/frame/route.js
CHANGED
|
@@ -133,13 +133,12 @@
|
|
|
133
133
|
historys.forEach((a, i) => map[a] = i + 1);
|
|
134
134
|
result.splice(0, result.length);
|
|
135
135
|
var actived, actived_value = 0;
|
|
136
|
-
var zimoilPath = zimoli.getInitPath();
|
|
137
136
|
var a = function (menu) {
|
|
138
137
|
var res = checkroles(user.roles, menu.roles);
|
|
139
138
|
if (res) {
|
|
140
139
|
if (savedChildren[menu.id] instanceof Array) menu.children = savedChildren[menu.id].filter(a);
|
|
141
140
|
if (menu.path) {
|
|
142
|
-
if (!firstMenu
|
|
141
|
+
if (!firstMenu) firstMenu = menu;
|
|
143
142
|
if (map[menu.path] > actived_value) {
|
|
144
143
|
actived = menu;
|
|
145
144
|
actived_value = map[menu.path];
|
|
@@ -165,6 +164,19 @@
|
|
|
165
164
|
first_opened = false;
|
|
166
165
|
return result;
|
|
167
166
|
};
|
|
167
|
+
var findMenu = function (path) {
|
|
168
|
+
if (!path) return;
|
|
169
|
+
var run = function (list) {
|
|
170
|
+
for (var o of list) {
|
|
171
|
+
if (o.path === path) return o;
|
|
172
|
+
if (o.children) {
|
|
173
|
+
o = run(o.children);
|
|
174
|
+
if (o) return o;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
return run(result);
|
|
179
|
+
}
|
|
168
180
|
var setActive = function (p, active) {
|
|
169
181
|
while (p) {
|
|
170
182
|
p.active = active;
|
|
@@ -198,7 +210,8 @@
|
|
|
198
210
|
result.open = function (menu) {
|
|
199
211
|
if (!menu) {
|
|
200
212
|
if (first_opened && result.active) return;
|
|
201
|
-
|
|
213
|
+
var zimoilPath = zimoli.getInitPath();
|
|
214
|
+
menu = result.active || findMenu(zimoilPath) || firstMenu;
|
|
202
215
|
if (!menu?.path) return;
|
|
203
216
|
first_opened = true;
|
|
204
217
|
zimoli.switch(null, null, menu);
|
|
@@ -8,6 +8,7 @@ var strings = require("../basic/strings");
|
|
|
8
8
|
var lastLogLength = 0;
|
|
9
9
|
var needNextLine = false;
|
|
10
10
|
var getColor = function (c) {
|
|
11
|
+
if (c === 'wrap') return;
|
|
11
12
|
if (!c) return colors.Reset;
|
|
12
13
|
switch (c) {
|
|
13
14
|
case "red":
|
|
@@ -118,7 +119,7 @@ var formatRows = function (arg, rows, deep, entry, leave) {
|
|
|
118
119
|
if (rows.length === 0) return entry + leave;
|
|
119
120
|
var ci = circleobjs.indexOf(arg);
|
|
120
121
|
if (ci >= 0) {
|
|
121
|
-
entry =
|
|
122
|
+
entry = bindColor('cyan', `<引用点 *${ci + 1}> `) + entry;
|
|
122
123
|
}
|
|
123
124
|
if (deepobjs.length === 0) circleobjs.splice(0, circleobjs.length);
|
|
124
125
|
var space = new Array(deep).join(" ");
|
|
@@ -180,17 +181,17 @@ var format = function (arg, deep = 0) {
|
|
|
180
181
|
deep++;
|
|
181
182
|
if (arg === null) return String(arg);
|
|
182
183
|
if (typeof arg === 'string') {
|
|
183
|
-
if (deep > 1) return "
|
|
184
|
+
if (deep > 1) return bindColor("green", arg);
|
|
184
185
|
return arg;
|
|
185
186
|
}
|
|
186
|
-
if (typeof arg === 'function') return
|
|
187
|
-
if (/^(number|boolean)$/.test(typeof arg)) return '
|
|
188
|
-
if (arg === undefined) return
|
|
187
|
+
if (typeof arg === 'function') return bindColor('cyan', `[${arg.constructor.name}${arg.name ? ": " + arg.name : " (匿名)"}]`);
|
|
188
|
+
if (/^(number|boolean)$/.test(typeof arg)) return bindColor('yellow', arg);
|
|
189
|
+
if (arg === undefined) return bindColor('gray', 'undefined');
|
|
189
190
|
if (typeof arg === "object") {
|
|
190
191
|
if (deepobjs.indexOf(arg) >= 0) {
|
|
191
192
|
var ci = circleobjs.indexOf(arg);
|
|
192
193
|
if (ci < 0) ci = circleobjs.length, circleobjs.push(arg);
|
|
193
|
-
return
|
|
194
|
+
return bindColor("cyan", `[循环点 *${ci + 1}]`);
|
|
194
195
|
}
|
|
195
196
|
if (arg instanceof Error) {
|
|
196
197
|
if (deep > 1) return String(arg.message);
|
|
@@ -198,7 +199,7 @@ var format = function (arg, deep = 0) {
|
|
|
198
199
|
}
|
|
199
200
|
if (arg instanceof Buffer || arg instanceof ArrayBuffer || arg instanceof SharedArrayBuffer) {
|
|
200
201
|
var data = new Uint8Array(arg.buffer || arg, arg.byteOffset || 0, arg.byteLength);
|
|
201
|
-
return
|
|
202
|
+
return bindColor('magenta', `<${arg.constructor.name} ${Array.prototype.slice.call(data, 0, 20).map(a => a < 16 ? "0" + a.toString(16) : a.toString(16)).join(' ')}${arg.byteLength > 20 ? ` ... 其他 ${arg.byteLength - 20} 字节` : ''}>`);
|
|
202
203
|
}
|
|
203
204
|
else if (isFinite(arg.length)) {
|
|
204
205
|
var entry = "[";
|
|
@@ -209,26 +210,26 @@ var format = function (arg, deep = 0) {
|
|
|
209
210
|
deepobjs.push(arg);
|
|
210
211
|
var res = Array.prototype.slice.call(arg, 0, 100).map(a => format(a, deep));
|
|
211
212
|
deepobjs.pop();
|
|
212
|
-
if (arg.length > res.length) res.push(
|
|
213
|
+
if (arg.length > res.length) res.push(bindColor('gray', `.. 其他 ${arg.length - res.length} 项`));
|
|
213
214
|
return formatRows(arg, res, deep, entry, leave);
|
|
214
215
|
}
|
|
215
216
|
if (arg.constructor === Date) {
|
|
216
|
-
return '
|
|
217
|
+
return bindColor('purple', formatDate.call(arg));
|
|
217
218
|
}
|
|
218
219
|
if (arg.constructor === RegExp) {
|
|
219
|
-
return
|
|
220
|
+
return bindColor('red2', `/${arg.source}/`) + bindColor('cyan', arg.flags);
|
|
220
221
|
}
|
|
221
222
|
var keys = Object.keys(arg);
|
|
222
223
|
var ks = keys.slice(0, 100);
|
|
223
224
|
if (deep > 3 && deep + keys.length > 5) {
|
|
224
225
|
var kvs = [];
|
|
225
|
-
if (keys.length > 0) kvs.push(
|
|
226
|
+
if (keys.length > 0) kvs.push(bindColor('gray', `.. 共 ${keys.length} 个属性`));
|
|
226
227
|
}
|
|
227
228
|
else {
|
|
228
229
|
deepobjs.push(arg);
|
|
229
230
|
var kvs = ks.map(k => `${/[\:'"`\[\{\(\r\n\u2028\u2029]|^\s|\s$/.test(k) ? format(k, deep) : k}: ${format(arg[k], deep)}`);
|
|
230
231
|
deepobjs.pop();
|
|
231
|
-
if (keys.length > ks.length) kvs.push(
|
|
232
|
+
if (keys.length > ks.length) kvs.push(bindColor('gray', `.. 其他 ${keys.length - ks.length} 个属性`));
|
|
232
233
|
}
|
|
233
234
|
var entry = '{';
|
|
234
235
|
if (arg.constructor && arg.constructor !== Object) entry = arg.constructor.name + entry;
|
|
@@ -281,7 +282,7 @@ colored.log = function () {
|
|
|
281
282
|
if (needNextLine) needNextLine = false;
|
|
282
283
|
_log.apply(console, arguments);
|
|
283
284
|
};
|
|
284
|
-
colored.wrap = function (c, content) {
|
|
285
|
+
var bindColor = colored.wrap = function (c, content) {
|
|
285
286
|
var c = getColor(c);
|
|
286
287
|
if (!c) throw new Error(i18n`${c}不是有效的色彩信息`);
|
|
287
288
|
return c + content + colors.Reset;
|
|
@@ -300,11 +301,7 @@ colored.clear = function (tag) {
|
|
|
300
301
|
write1(false, '');
|
|
301
302
|
if (tag) write1(true, tag);
|
|
302
303
|
};
|
|
303
|
-
colored.format =
|
|
304
|
-
a = format(a);
|
|
305
|
-
a = renderColor(a);
|
|
306
|
-
return a;
|
|
307
|
-
};
|
|
304
|
+
colored.format = format;
|
|
308
305
|
if (typeof i18n !== 'undefined') {
|
|
309
306
|
colored.info.tip = i18n`提示`;
|
|
310
307
|
colored.warn.tip = i18n`注意`;
|
package/coms/reptile/colors.js
CHANGED
|
@@ -80,4 +80,10 @@ class Color {
|
|
|
80
80
|
}
|
|
81
81
|
for (var k in colors) {
|
|
82
82
|
colors[k] = new Color(k, colors[k]);
|
|
83
|
-
}
|
|
83
|
+
}
|
|
84
|
+
var reset = colors.Reset;
|
|
85
|
+
colors.wrap = function (content, label) {
|
|
86
|
+
var c = colors[label];
|
|
87
|
+
if (!c) return content;
|
|
88
|
+
return c + content + reset;
|
|
89
|
+
};
|
package/coms/zimoli/zimoli.js
CHANGED
|
@@ -36,6 +36,7 @@ onhashchange(window, function (event) {
|
|
|
36
36
|
var currentHash = getCurrentHash();
|
|
37
37
|
if (currentHash && currentHash === targetHash) return;
|
|
38
38
|
var targetpath = pathFromHash(targetHash);
|
|
39
|
+
if (targetpath === popupHashlessPath) return fixurl();
|
|
39
40
|
if (pathFromHash(currentHash) === popupHashlessPath) {
|
|
40
41
|
backward();
|
|
41
42
|
return;
|
|
@@ -379,7 +380,7 @@ function create(pagepath, args, from, needroles) {
|
|
|
379
380
|
return alert(i18n`没有权限!`, 0);
|
|
380
381
|
}
|
|
381
382
|
if (!pg) return;
|
|
382
|
-
history[current_history].wardable = true;
|
|
383
|
+
if (history[current_history]) history[current_history].wardable = true;
|
|
383
384
|
var _with_length = _with_elements.length;
|
|
384
385
|
state.onback = function (handler) {
|
|
385
386
|
_pageback_listener = handler;
|
|
@@ -419,6 +420,7 @@ function create(pagepath, args, from, needroles) {
|
|
|
419
420
|
var createEmptyHistory = function (emptyState, allowForward = true) {
|
|
420
421
|
var h = [emptyState];
|
|
421
422
|
h.index = 0;
|
|
423
|
+
h.lastIndex = 0;
|
|
422
424
|
h.wardable = allowForward;
|
|
423
425
|
return h;
|
|
424
426
|
}
|
|
@@ -484,10 +486,10 @@ var pushstate = function (path_name, history_name) {
|
|
|
484
486
|
_history.index++;
|
|
485
487
|
}
|
|
486
488
|
if (_history[_history.index] !== path_name) {
|
|
487
|
-
_history.lastIndex = index;
|
|
488
489
|
_history.splice(_history.index, _history.length - _history.index);
|
|
489
490
|
_history[_history.index] = path_name;
|
|
490
491
|
}
|
|
492
|
+
_history.lastIndex = index;
|
|
491
493
|
}
|
|
492
494
|
savestate();
|
|
493
495
|
return isBack;
|
|
@@ -515,34 +517,40 @@ var getCurrentHash = function () {
|
|
|
515
517
|
var targeturl = `#${history_name}${_historylist.length ? _historylist[_historylist.index] : ""}`;
|
|
516
518
|
return encodeURI(targeturl);
|
|
517
519
|
};
|
|
520
|
+
var fixlock = false;
|
|
521
|
+
var fixUnlock = function () {
|
|
522
|
+
fixlock = false;
|
|
523
|
+
}
|
|
524
|
+
var fixNext = function (d) {
|
|
525
|
+
fixlock = true;
|
|
526
|
+
var h = history[current_history];
|
|
527
|
+
h.lastIndex = h.index;
|
|
528
|
+
preventNextHashChange = true;
|
|
529
|
+
window_history.go(d);
|
|
530
|
+
setTimeout(fixUnlock, 60);
|
|
531
|
+
setTimeout(fixurl, 60);
|
|
532
|
+
};
|
|
518
533
|
var fixurl = function () {
|
|
534
|
+
if (fixlock) return;
|
|
519
535
|
if (false === fullfill_is_dispatched) return;
|
|
520
536
|
var zimoli_hash = getCurrentHash();
|
|
521
537
|
var location_hash = getLocationHash();
|
|
522
538
|
if (location_hash === zimoli_hash) return;
|
|
523
539
|
var location_path = pathFromHash(location_hash);
|
|
524
540
|
if (location_path === popupHashlessPath) {
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
location_hash = getCurrentHash();
|
|
528
|
-
location_path = pathFromHash(location_hash);
|
|
541
|
+
fixNext(-1);
|
|
542
|
+
return;
|
|
529
543
|
};
|
|
530
|
-
if (zimoli_hash === location_hash) return;
|
|
531
544
|
var zimoli_path = pathFromHash(zimoli_hash);
|
|
532
545
|
if (zimoli_path === popupHashlessPath) return setLocationHash(zimoli_hash);
|
|
533
546
|
if (zimoli_hash) {
|
|
534
547
|
if (!location_hash) setLocationHash(zimoli_hash);
|
|
535
548
|
else {
|
|
536
549
|
var _history = history[current_history];
|
|
537
|
-
var
|
|
538
|
-
if (
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
var d = c - b;
|
|
542
|
-
preventNextHashChange = true;
|
|
543
|
-
window_history.go(d);
|
|
544
|
-
location_hash = getLocationHash();
|
|
545
|
-
}
|
|
550
|
+
var d = _history.index - _history.lastIndex;
|
|
551
|
+
if (d) {
|
|
552
|
+
fixNext(d);
|
|
553
|
+
return;
|
|
546
554
|
}
|
|
547
555
|
if (location_hash !== zimoli_hash) {
|
|
548
556
|
setLocationHash(zimoli_hash);
|
|
@@ -552,11 +560,8 @@ var fixurl = function () {
|
|
|
552
560
|
else if (location_path !== getInitPath()) {
|
|
553
561
|
var _history = history[current_history];
|
|
554
562
|
var i = _history.indexOf(location_path);
|
|
555
|
-
if (i === -1) i = _history.lastIndex;
|
|
556
|
-
if (i > 0)
|
|
557
|
-
preventNextHashChange = true;
|
|
558
|
-
window_history.go(-i);
|
|
559
|
-
}
|
|
563
|
+
if (i === -1) i = _history.lastIndex, _history.lastIndex = _history.index;
|
|
564
|
+
if (i > 0) fixNext(-i);
|
|
560
565
|
}
|
|
561
566
|
};
|
|
562
567
|
var checkonback = function (elements) {
|
|
@@ -687,6 +692,8 @@ var _switch = zimoli.switch = function (history_name = default_history, target_b
|
|
|
687
692
|
setZimoliParams(pagepath, { roles, data: args, id, options });
|
|
688
693
|
emptyState = pagepath;
|
|
689
694
|
}
|
|
695
|
+
}
|
|
696
|
+
if (isString(emptyState)) {
|
|
690
697
|
if (!history[current_history]) root_path = (history[current_history] = createEmptyHistory(emptyState))[0];
|
|
691
698
|
else {
|
|
692
699
|
var _history = history[current_history];
|
|
@@ -749,6 +756,7 @@ zimoli.createState = createState;
|
|
|
749
756
|
// 家中进了贼,我们是把家让给它,还是找机会把贼杀了。
|
|
750
757
|
var getInitPath = zimoli.getInitPath = function () {
|
|
751
758
|
var h = history[current_history];
|
|
759
|
+
if (!h) return locationInitHash;
|
|
752
760
|
if (h.length < 2) return pathFromHash(locationInitHash);
|
|
753
761
|
return h[0];
|
|
754
762
|
};
|
|
@@ -6,7 +6,20 @@ predefs.exports = true;
|
|
|
6
6
|
predefs["module.exports"] = true;
|
|
7
7
|
predefs.Promise = true;
|
|
8
8
|
[Boolean, Number, String, Function, Object, Array, Date, RegExp, Error].forEach(p => predefs[p.name] = true);
|
|
9
|
+
var wrapLabel = function (content, typeName) {
|
|
10
|
+
return `<${content}>${content}</${typeName}>`;
|
|
11
|
+
};
|
|
12
|
+
var amp = a => `&#${a.charCodeAt()};`;
|
|
13
|
+
var encodeAmp = function (a) {
|
|
14
|
+
return a.replace(/[\<\>\|&]/g, amp);
|
|
15
|
+
};
|
|
9
16
|
var codecolor = function (c, encode) {
|
|
17
|
+
var wrap = arguments[2];
|
|
18
|
+
if (encode?.length === 2) wrap = encode, encode = arguments[2];
|
|
19
|
+
if (!wrap) {
|
|
20
|
+
wrap = wrapLabel;
|
|
21
|
+
if (!encode) encode = encodeAmp;
|
|
22
|
+
}
|
|
10
23
|
var envs = c.envs;
|
|
11
24
|
var deep = 0;
|
|
12
25
|
var used = c.used;
|
|
@@ -45,17 +58,25 @@ var codecolor = function (c, encode) {
|
|
|
45
58
|
return false;
|
|
46
59
|
};
|
|
47
60
|
var setExpress = function (o, label) {
|
|
48
|
-
if (!o.text ||
|
|
61
|
+
if (!o.text || o.wraped) return;
|
|
62
|
+
o.wraped = true;
|
|
49
63
|
var keys = o.text.split(".");
|
|
64
|
+
var invoked = null;
|
|
65
|
+
var endi = keys.length - 1;
|
|
50
66
|
if (isInvoke(o)) {
|
|
51
|
-
if (!/^[
|
|
67
|
+
if (!/^[\?]/.test(keys[endi])) invoked = wrap(keys[endi], "invoke");
|
|
52
68
|
}
|
|
69
|
+
else endi++;
|
|
53
70
|
var [name] = keys;
|
|
54
|
-
if (
|
|
55
|
-
else
|
|
56
|
-
else name = `<${label}>${name}</${label}>`;
|
|
71
|
+
if (!o.isprop && o.text !== name && isConstValue(name)) name = wrap(name, "strap");
|
|
72
|
+
else name = wrap(name, label);
|
|
57
73
|
keys[0] = name;
|
|
58
|
-
|
|
74
|
+
for (var cx = 1, dx = endi; cx < dx; cx++) {
|
|
75
|
+
var k = keys[cx];
|
|
76
|
+
keys[cx] = /^[\?]/.test(k) || !k ? k : wrap(k, 'express');
|
|
77
|
+
}
|
|
78
|
+
if (endi === keys.length - 1) keys[endi] = invoked;
|
|
79
|
+
o.text = keys.join('.');
|
|
59
80
|
};
|
|
60
81
|
var setPredef = o => setExpress(o, 'predef');
|
|
61
82
|
var setOutside = o => setExpress(o, 'outside');
|
|
@@ -66,8 +87,8 @@ var codecolor = function (c, encode) {
|
|
|
66
87
|
if (spaceReg) var unspaceReg = new RegExp(`(?:[^${光标}])+`, 'g');
|
|
67
88
|
var wraptext = function (t, l) {
|
|
68
89
|
if (unspaceReg) t = t.replace(unspaceReg, a => {
|
|
69
|
-
a = encode(a);
|
|
70
|
-
return
|
|
90
|
+
if (encode) a = encode(a);
|
|
91
|
+
return wrap(a, l);
|
|
71
92
|
});
|
|
72
93
|
return t;
|
|
73
94
|
};
|
|
@@ -78,13 +99,13 @@ var codecolor = function (c, encode) {
|
|
|
78
99
|
var text = o.text;
|
|
79
100
|
switch (o.type) {
|
|
80
101
|
case LABEL:
|
|
81
|
-
o.text =
|
|
102
|
+
o.text = wrap(o.text, 'label');
|
|
82
103
|
break;
|
|
83
104
|
case QUOTED:
|
|
84
105
|
if (o.length || !o.text) {
|
|
85
106
|
o.forEach(setcolor);
|
|
86
|
-
o.entry =
|
|
87
|
-
o.leave =
|
|
107
|
+
o.entry = wrap(o.entry, 'text');
|
|
108
|
+
o.leave = wrap(o.leave, 'text');
|
|
88
109
|
break;
|
|
89
110
|
}
|
|
90
111
|
if (/^\//.test(o.text)) {
|
|
@@ -101,30 +122,30 @@ var codecolor = function (c, encode) {
|
|
|
101
122
|
}
|
|
102
123
|
case PIECE:
|
|
103
124
|
if (o.queue && o.queue.tag) {
|
|
104
|
-
o.text = encode(o.text);
|
|
125
|
+
if (encode) o.text = encode(o.text);
|
|
105
126
|
}
|
|
106
127
|
else o.text = wraptext(o.text, 'text');
|
|
107
128
|
break;
|
|
108
129
|
break;
|
|
109
130
|
case ELEMENT:
|
|
110
131
|
if (o.attributes) o.attributes.forEach(setcolor);
|
|
111
|
-
if (o.tag_entry) o.tag_entry =
|
|
112
|
-
if (o.tag_leave) o.tag_leave =
|
|
113
|
-
if (o.entry) o.entry =
|
|
114
|
-
if (o.leave) o.leave =
|
|
115
|
-
o.tag =
|
|
132
|
+
if (o.tag_entry) o.tag_entry = wrap(o.tag_entry, 'stamp');
|
|
133
|
+
if (o.tag_leave) o.tag_leave = wrap(o.tag_leave, 'stamp');
|
|
134
|
+
if (o.entry) o.entry = wrap(o.entry, 'stamp');
|
|
135
|
+
if (o.leave) o.leave = wrap(o.leave, 'stamp');
|
|
136
|
+
o.tag = wrap(o.tag, 'label');
|
|
116
137
|
o.forEach(setcolor);
|
|
117
138
|
break;
|
|
118
139
|
case SCOPED:
|
|
119
140
|
deep++;
|
|
120
141
|
o.forEach(setcolor);
|
|
121
142
|
deep--;
|
|
122
|
-
o.entry =
|
|
123
|
-
o.leave =
|
|
143
|
+
o.entry = wrap(o.entry, 'deep' + deep);
|
|
144
|
+
o.leave = wrap(o.leave, 'deep' + deep);
|
|
124
145
|
break;
|
|
125
146
|
case VALUE:
|
|
126
|
-
if (o.isdigit) o.text =
|
|
127
|
-
else o.text =
|
|
147
|
+
if (o.isdigit) o.text = wrap(o.text, 'digit');
|
|
148
|
+
else o.text = wrap(o.text, 'value');
|
|
128
149
|
break;
|
|
129
150
|
case PROPERTY:
|
|
130
151
|
var next = o.next;
|
|
@@ -138,13 +159,11 @@ var codecolor = function (c, encode) {
|
|
|
138
159
|
setExpress(o, o.istype || o.isdef || o.next?.needle ? 'predef' : 'express');
|
|
139
160
|
break;
|
|
140
161
|
case STRAP:
|
|
141
|
-
if (control_reg?.test(text)) o.text =
|
|
142
|
-
else o.text =
|
|
162
|
+
if (control_reg?.test(text)) o.text = wrap(o.text, 'flow');
|
|
163
|
+
else o.text = wrap(o.text, 'strap');
|
|
143
164
|
break;
|
|
144
165
|
case STAMP:
|
|
145
|
-
if (/^(=>)$/.test(o.text) || o.text === "*" && o.prev && o.prev.type === STRAP) o.text =
|
|
146
|
-
// else if (!/^[<\/>]+$/.test(o.text));
|
|
147
|
-
// else o.text = `<stamp>${encode(o.text)}</stamp>`;
|
|
166
|
+
if (/^(=>)$/.test(o.text) || o.text === "*" && o.prev && o.prev.type === STRAP) o.text = wrap(encode ? encode(o.text) : o.text, 'strap');
|
|
148
167
|
break;
|
|
149
168
|
case COMMENT:
|
|
150
169
|
o.text = wraptext(o.text, 'comment');
|
|
@@ -154,4 +173,5 @@ var codecolor = function (c, encode) {
|
|
|
154
173
|
c.forEach(setcolor);
|
|
155
174
|
return c;
|
|
156
175
|
}
|
|
176
|
+
codecolor.encode = encodeAmp;
|
|
157
177
|
return codecolor;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
|
|
2
2
|
var { SCOPED, QUOTED, SPACE, STAMP, STRAP, EXPRESS, PROPERTY } = compile$common;
|
|
3
|
-
var encode = function (text) {
|
|
4
|
-
return text.replace(/[\<\>\|]/g, a => `&#${a.charCodeAt()};`);
|
|
5
|
-
};
|
|
6
3
|
|
|
7
4
|
var rows = function (type, text) {
|
|
8
5
|
if (typeof text !== 'string') {
|
|
@@ -12,11 +9,11 @@ var rows = function (type, text) {
|
|
|
12
9
|
type = String(type).toLowerCase();
|
|
13
10
|
if (type in 语言) {
|
|
14
11
|
var c = 语言[type](text);
|
|
15
|
-
标签化(c
|
|
12
|
+
标签化(c);
|
|
16
13
|
text = c.toString();
|
|
17
14
|
|
|
18
15
|
}
|
|
19
|
-
else text = encode(text);
|
|
16
|
+
else text = 标签化.encode(text);
|
|
20
17
|
|
|
21
18
|
var codes = text.split(/\r\n|\r|\n/);
|
|
22
19
|
var minSpace = Infinity;
|
|
@@ -41,5 +38,5 @@ function 茨菰(type, text) {
|
|
|
41
38
|
};
|
|
42
39
|
|
|
43
40
|
茨菰.rows = rows;
|
|
44
|
-
茨菰.encode = encode;
|
|
41
|
+
茨菰.encode = 标签化.encode;
|
|
45
42
|
return 茨菰;
|