efront 4.0.53 → 4.0.55

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.
@@ -609,6 +609,7 @@ var init = function (url, then, prebuilds) {
609
609
  if (error) return crack(error);
610
610
 
611
611
  var module = loadedModules[key];
612
+ if (!module) return;
612
613
  var args = module.args || [];
613
614
 
614
615
  if (!args || !args.length) {
@@ -75,7 +75,7 @@ class Table extends Array {
75
75
  if (isEmpty(name) || !isString(name)) continue;
76
76
  if (name === searchtext) this.hasFullmatch = true;
77
77
  var [p, m] = mark.power(name, searchtext);
78
- power += p;
78
+ if (p > power) power = p;
79
79
  if (p >= searchtext.length) this.coverCount++;
80
80
  if (!isEmpty(f.key)) o[f.key] = m;
81
81
  else o.name = m, o.toString = returnName, o.valueOf = returnName;
@@ -0,0 +1,54 @@
1
+ function readCSV(data) {
2
+ var reg = /""?|,|\r\n|\r|\n|\u2028|\u2029/g;
3
+ var str = [];
4
+ var instr = false;
5
+ var lastIndex = 0;
6
+ var row = [];
7
+ var table = [];
8
+ while (true) {
9
+ var m = reg.exec(data);
10
+ if (!m) break;
11
+ var s = data.slice(lastIndex, m.index);
12
+ lastIndex = reg.lastIndex;
13
+ if (s) str.push(s);
14
+ switch (m[0]) {
15
+ case `""`:
16
+ str.push('"');
17
+ break;
18
+ case `"`:
19
+ instr = !instr;
20
+ break;
21
+ case `,`:
22
+ if (instr) {
23
+ str.push(',');
24
+ }
25
+ else {
26
+ row.push(str.join(''));
27
+ str = [];
28
+ }
29
+ break;
30
+ case "\r\n":
31
+ case "\r":
32
+ case "\n":
33
+ case "\u2028":
34
+ case "\u2029":
35
+ if (instr) {
36
+ str.push("\r\n");
37
+ }
38
+ else {
39
+ row.push(str.join(""));
40
+ table.push(row);
41
+ row = [];
42
+ str = [];
43
+ }
44
+ break;
45
+ }
46
+ }
47
+ if (str.length || row.length) row.push(str.join(''));
48
+ if (row.length) table.push(row);
49
+ row = [];
50
+ str = [];
51
+ var fields = table.shift();
52
+ if (fields) fields = fields.map((a, i) => { return { name: a, key: i } })
53
+ return Table.from(fields, table);
54
+ }
@@ -11,7 +11,7 @@ var exec_ = function (args, ok, oh, int) {
11
11
  fina();
12
12
  }
13
13
  else if (catches.length) {
14
- catch_ = catches.pop();
14
+ catch_ = catches[catches.length - 1];
15
15
  [index, p, throwed] = catch_;
16
16
  index += p & 0xffff;
17
17
  if (p >>> 16) {
@@ -19,6 +19,7 @@ var exec_ = function (args, ok, oh, int) {
19
19
  }
20
20
  else {
21
21
  e = err;
22
+ catches.pop();
22
23
  fina();
23
24
  }
24
25
  }
@@ -52,10 +53,10 @@ var exec_ = function (args, ok, oh, int) {
52
53
  }
53
54
  if (finished) return ok(r);
54
55
  }
55
- catch_ = null;
56
56
  while (index < args_length) {
57
57
  try {
58
58
  var a = args[index].call(t, p) || [1, 0];
59
+ catch_ = null;
59
60
  p = a[0];
60
61
  i = a[1];
61
62
  } catch (e) {
@@ -657,10 +657,13 @@ class Program {
657
657
  if (a instanceof Array) {
658
658
  a.forEach(a => {
659
659
  quote_map[a] = q;
660
- tokens[a.charAt(0)] = true;
660
+ if (a.length === 1) tokens[a] = true;
661
661
  });
662
662
  }
663
- else quote_map[a] = q, tokens[a.charAt(0)] = true;
663
+ else {
664
+ quote_map[a] = q
665
+ if (a.length === 1) tokens[a] = true;
666
+ }
664
667
  var r = q.slice(q[2] ? 2 : 3).concat(q[1]).map(q => {
665
668
  if (q instanceof Array) {
666
669
  q = q[q.length - 2];
@@ -688,11 +691,11 @@ class Program {
688
691
  var [a, b] = s;
689
692
  scope_entry[a] = b;
690
693
  scope_leave[b] = a;
691
- tokens[a] = true;
692
- tokens[b] = true;
694
+ if (a.length === 1) tokens[a] = true;
695
+ if (b.length === 1) tokens[b] = true;
693
696
  });
694
697
  this.stamps.forEach(s => {
695
- tokens[s] = true;
698
+ if (s.length === 1) tokens[s] = true;
696
699
  });
697
700
  var scopes = this.scopes.map(a => a.join("")).join("");
698
701
  scopes = this.compile(scopes);
@@ -1,4 +1,4 @@
1
- var { skipAssignment, snapSentenceHead, snapExpressFoot, EXPRESS, SCOPED, QUOTED, VALUE, STRAP, STAMP, number_reg, createString } = require("./common");
1
+ var { skipAssignment, snapSentenceHead, snapExpressFoot, EXPRESS, SPACE, SCOPED, QUOTED, VALUE, STRAP, STAMP, number_reg, createString } = require("./common");
2
2
  var strings = require("../basic/strings");
3
3
 
4
4
  var createRefId = function (o) {
@@ -206,6 +206,7 @@ function enumref(scoped) {
206
206
  continue;
207
207
  }
208
208
  if (!eq) break;
209
+ if (o.short) continue;
209
210
  o.type = eq.type;
210
211
  o.isdigit = true;
211
212
  o.text = eq.text;
@@ -26,4 +26,5 @@ t("for(;a=1;){ console.log(a)} console.log(a)", "for (; a = 1;) { console.log(1)
26
26
  t("for(;;a=1){ console.log(a)} console.log(a)", "for (;; a = 1) { console.log(a) } console.log(a)");
27
27
  t("for(var a = 1;;){ console.log(a)} console.log(a)", "for (var a = 1;;) { console.log(1) } console.log(1)");
28
28
  t("for(let a = 1;;){ console.log(a)} console.log(a)", "for (let a = 1;;) { console.log(a) } console.log(a)");
29
+ t("var a=-1; console.log(-a)", "var a = -1; console.log(- -1)");
29
30
  // t(fs.readFileSync(path.join(__dirname,"../zimoli/spacechar_test.js")).toString())
@@ -1107,7 +1107,8 @@ var createString = function (parsed) {
1107
1107
  else if (o.prev && o.type === STAMP && !/^([,;])$/.test(o.text)) {
1108
1108
  if (result[result.length - 1] === " " || (lasttype === PROPERTY || !o.isExpress && o.prev && o.prev.type !== LABEL) && o.text === ':') { }
1109
1109
  else if (lasttype === STAMP) {
1110
- result.push(" ");
1110
+ var prev = o.prev;
1111
+ if (!prev.unary || /[\+\-]$/.test(prev.text) && prev.text === o.text) result.push(" ");
1111
1112
  }
1112
1113
  else if (/^(\+\+|\-\-)$/.test(o.prev.text) && o.prev.prev) {
1113
1114
  var prev_prev = o.prev.prev;
@@ -1116,6 +1117,7 @@ var createString = function (parsed) {
1116
1117
  || prev_prev.type & (EXPRESS | VALUE)
1117
1118
  ) result.push(";");
1118
1119
  }
1120
+
1119
1121
  else if (o.text === '*') {
1120
1122
  if (keepspace && lasttype !== SPACE && (lasttype !== STRAP || o.prev && o.prev.text !== 'function')) result.push(" ");
1121
1123
  }
@@ -1127,6 +1129,9 @@ var createString = function (parsed) {
1127
1129
  if (/^0[0-7]+$/.test(o.text)) {
1128
1130
  o.text = '0o' + o.text.slice(1);
1129
1131
  }
1132
+ if (+o.text < 0 && /\-$/.test(result[result.length - 1])) {
1133
+ result.push(" ");
1134
+ }
1130
1135
  }
1131
1136
  result.push(o.text);
1132
1137
  }
@@ -5,6 +5,8 @@ class Richcss extends Program {
5
5
  quotes = this.quotes.slice(0, 2);
6
6
  scopes = [["{", "}"]]
7
7
  }
8
+ var presets = /^@(media|keyframes|layer|import|namespace|page|property|suppports|font-face|document|counter-style|charset|color-profile|container|font-feature-values|font-palette-values)(\s|\(|$)/i;
9
+
8
10
  Richcss.prototype.setType = function (o) {
9
11
  var p = o.prev;
10
12
  if (o.type !== SCOPED) {
@@ -34,10 +36,39 @@ Richcss.prototype.setType = function (o) {
34
36
  }
35
37
  }
36
38
  if (!q.entry && o.type !== SCOPED) {
39
+ var p = q.last;
40
+ if (p && p.type === STAMP && p.text === ':') {
41
+ if (p.keep) return;
42
+ }
43
+ else if (o.type === STAMP && o.text === ':') {
44
+ if (p.type & (EXPRESS | PROPERTY)) {
45
+ o.keep = true;
46
+ return;
47
+ }
48
+ }
37
49
  if (o.type !== STAMP || o.text !== ";") return false;
38
50
  }
39
51
  };
52
+
40
53
  Richcss.prototype.createScoped = function (code) {
54
+ var setVarsUsed = function (s) {
55
+ var vars = null, used = null;
56
+ for (var cx = s.length - 1; cx >= 0; cx--) {
57
+ var { p: k, v } = s[cx];
58
+ if (/^\-\-|^@[^\{]/.test(k) && !("used" in v) && v.length) {
59
+ if (!vars) vars = {};
60
+ vars[k] = v.join(" ");
61
+ s.splice(cx, 1);
62
+ }
63
+ else {
64
+ if (!used) used = [];
65
+ used.push({ p: k, v });
66
+ }
67
+ }
68
+ if (used) used.reverse();
69
+ s.used = used;
70
+ s.vars = vars;
71
+ };
41
72
  var run = function (o) {
42
73
  var props = [];
43
74
  var values = null;
@@ -65,29 +96,20 @@ Richcss.prototype.createScoped = function (code) {
65
96
  break;
66
97
  case SCOPED:
67
98
  var s = run(o.first);
68
- var vars = null, used = null;
69
- for (var { p: k, v } of s) {
70
- if (/^\-\-/.test(k)) {
71
- if (!vars) vars = {};
72
- vars[k] = v.join(" ");
73
- }
74
- else {
75
- if (!used) used = [];
76
- used.push({ p: k, v });
77
- }
78
- }
79
- values.used = used;
80
- values.vars = vars;
99
+ values.used = s.used;
100
+ values.vars = s.vars;
81
101
 
82
102
  }
83
103
  o = o.next;
84
104
  }
105
+ setVarsUsed(props);
85
106
  return props;
86
107
  };
87
108
  return run(code.first);
88
109
  };
89
110
  Richcss.prototype.createString = createString;
90
111
  var getFromScopeList = function (name, varsList, value) {
112
+ name = name.replace(/^@\{\s*(\S*)\s*\}$/g, '@$1');
91
113
  for (var cx = varsList.length - 1; cx >= 0; cx--) {
92
114
  var o = varsList[cx];
93
115
  if (name in o) return o[name];
@@ -96,6 +118,7 @@ var getFromScopeList = function (name, varsList, value) {
96
118
  }
97
119
  var fixBase = function (b, a) {
98
120
  return a.split(/,\s*/).map(a => {
121
+ if (presets.test(a)) a = `@{${a}}`;
99
122
  var replaced = false;
100
123
  return b.split(/\s*,\s*/).map(b => {
101
124
  var a1 = a.replace(/(:scope|&)/g, function (match) {
@@ -113,10 +136,11 @@ var fixBase = function (b, a) {
113
136
  }).join(",");
114
137
  }
115
138
  function evalscoped(scoped, scopeNames, base = '') {
116
- var root = scoped[":root"], scope = scoped[":scope"];
117
- var vars = Object.create(null);
139
+ var root = scoped[":root"], scope = scoped[":scope"], and = scoped["&"];
140
+ var vars = extend(Object.create(null), scoped.vars);
118
141
  if (root) root.forEach(r => extend(vars, r.vars));
119
142
  if (scope) scope.forEach(s => extend(vars, s.vars));
143
+ if (and) and.forEach(s => extend(vars, s.vars));
120
144
  scopeNames.forEach(s => {
121
145
  var ss = scoped[s];
122
146
  if (ss) ss.forEach(s => {
@@ -129,7 +153,7 @@ function evalscoped(scoped, scopeNames, base = '') {
129
153
  var queue = [];
130
154
  for (var k in vars) {
131
155
  var v = vars[k];
132
- while (/^\-\-/.test(v)) {
156
+ while (/^\-\-|^@[^\{]/.test(v)) {
133
157
  if (queue.indexOf(v) >= 0) throw `变量环形引用,无法初始化:${queue}`;
134
158
  queue.push(v);
135
159
  v = getFromScopeList(v, vlist);
@@ -138,6 +162,7 @@ function evalscoped(scoped, scopeNames, base = '') {
138
162
  }
139
163
  };
140
164
  initvars(vars);
165
+
141
166
  var eval2 = function (props) {
142
167
  var rest = [];
143
168
  var result = [];
@@ -154,7 +179,7 @@ function evalscoped(scoped, scopeNames, base = '') {
154
179
  return res;
155
180
  };
156
181
  var calcvars = function (v) {
157
- return v.replace(/(^|\s|[\]\)\(\[\-\+\*\/])(?:var\s*\(([\s\S]*?)\)|(--[^\s]+))/g, function (m, q, a, b) {
182
+ return v.replace(/(^|\s|[\]\)\(\[\-\+\*\/])(?:var\s*\(([\s\S]*?)\)|(--\S+|@[^\s\{\(\:\+\*\/]+|@\{[^\}@]*\}))/g, function (m, q, a, b) {
158
183
  return q + getFromScopeList(b || a.trim(), vlist, m.slice(q.length));
159
184
  });
160
185
  };
@@ -162,18 +187,23 @@ function evalscoped(scoped, scopeNames, base = '') {
162
187
  if (p.used) {
163
188
  var match = /^(@[^\s,]+)\s*\(\s*(@[^\s,]+\s*(?:,\s*@[^\s,]+\s*)*)?\)/.exec(k);
164
189
  if (!match) continue;
190
+ if (presets.test(match[1])) continue;
165
191
  p.base = base;
166
192
  var [, name, args] = match;
167
- args = args.split(",").map(a => a.trim());
168
- p.args = args;
193
+ args = args.split(",").map(a => a.trim().split(':'));
194
+ p.argDefaults = args.map(a => a[1]);
195
+ args = p.args = args.map(a => a[0]);
169
196
  p.reg = new RegExp(args.join("|"), 'g');
170
197
  if (!methods[name]) methods[name] = [];
171
198
  methods[name].push(function () {
172
199
  var body = evalthis(this);
173
200
  var valueMap = {};
174
- this.args.forEach((a, i) => {
175
- valueMap[a] = arguments[i];
176
- })
201
+ var argDefaults = p.argDefaults;
202
+ this.args.forEach((k, i) => {
203
+ var a = arguments[i];
204
+ if (a === undefined || a === null) a = argDefaults[i];
205
+ valueMap[k] = a;
206
+ });
177
207
  var replace = text => text.replace(this.reg, function (name) {
178
208
  if (name in valueMap) return valueMap[name];
179
209
  return name;
@@ -188,9 +218,10 @@ function evalscoped(scoped, scopeNames, base = '') {
188
218
  }
189
219
  for (var { p: k, v: p } of props) {
190
220
  if (p.isMethod) continue;
221
+ k = calcvars(k);
191
222
  if (p.used) {
192
223
  if (base && !p.rooted) p.base = fixBase(base, k);
193
- else p.base = k;
224
+ else p.base = presets.test(k) ? `@{${k}}` : k;
194
225
  var value = evalthis(p);
195
226
  if (value.rest.length) rest = rest.concat(value.rest);
196
227
  if (value.length) rest.push([p.base, '{', value.join(""), "}"]);
@@ -199,9 +230,9 @@ function evalscoped(scoped, scopeNames, base = '') {
199
230
  result.push(k, ":", calcvars(p.join(" ")), ';');
200
231
  }
201
232
  else {
202
- k = calcvars(k);
203
233
  var match = /^(@\S+)\s*\(([\s\S]*)\)$/.exec(k);
204
234
  if (!match) continue;
235
+ if (presets.test(match[1])) continue;
205
236
  var [, name, params] = match;
206
237
  params = params.split(",").map(a => a.trim());
207
238
  var method = getFromScopeList(name, mlist);
@@ -223,12 +254,13 @@ function evalscoped(scoped, scopeNames, base = '') {
223
254
  var rcss = null;
224
255
  function richcss(text, scopeName, compress) {
225
256
  if (!rcss) rcss = new Richcss;
257
+ rcss.debug = true;
226
258
  var code = scanner2(text, rcss);
227
259
  var scopeNames = [];
228
260
  if (scopeName) code.forEach(c => {
229
261
  if (c.type === PROPERTY) {
230
262
  var replaced = false;
231
- c.text = c.text.replace(/\:(scope|root)/g, function () {
263
+ c.text = c.text.replace(/\:(scope|root)|&/g, function () {
232
264
  replaced = true;
233
265
  return scopeName;
234
266
  });
@@ -239,5 +271,36 @@ function richcss(text, scopeName, compress) {
239
271
  })
240
272
  var { scoped } = code;
241
273
  var result = evalscoped(scoped, scopeNames, scopeName);
242
- return result.rest.map(a => a.join("")).concat(result).join(compress ? "" : "\r\n");
274
+ return result.rest.map(a => a.join("")).concat(result).map(a => {
275
+ var ats = [];
276
+ a = a.replace(/@\{(@[^\}]*)\}\s*/g, function (_, q) {
277
+ ats.push(q);
278
+ return ''
279
+ })
280
+ .replace(/((?:[\+\-]+\s*)?(?:\d+(?:\.\d*)?|\.\d+))\s*(px|%|pt|cm|mm|r?em)?\s*([\/\*\+\-])\s*((?:[\+\-]+\s*)?(?:\d+(?:\.\d*)?|\.\d+))(px|%|pt|cm|mm|r?em)?/ig, function (_, d1, p1 = '', c, d2, p2 = '') {
281
+ d1 = eval(d1);
282
+ d2 = eval(d2);
283
+ if (!p2) {
284
+ if (c === '*') {
285
+ return d1 * d2 + p1;
286
+ }
287
+ if (c === '/') {
288
+ return d1 / d2 + p1;
289
+ }
290
+ }
291
+ else if (p1 === p2) {
292
+ if (c === "+") {
293
+ return (+d1 + +d2) + p1;
294
+ }
295
+ if (c === '-') {
296
+ return (d1 - d2) + p1;
297
+ }
298
+ }
299
+ return _;
300
+ })
301
+ while (ats.length) {
302
+ a = ats.pop() + `{${a}}`;
303
+ }
304
+ return a;
305
+ }).join(compress ? "" : "\r\n");
243
306
  }
@@ -1,6 +1,8 @@
1
1
  var test = function (data, expect) {
2
2
  assert(richcss(data), expect);
3
3
  };
4
+ test(`&{--a:1}a{opacity:--a}`, `a{opacity:1;}`);
5
+ test(`:root{--a:1}a{opacity:--a}`, `a{opacity:1;}`);
4
6
  test(`:scope{--a:1}a{opacity:--a}`, `a{opacity:1;}`);
5
7
  test(`:scope{--b:--a;--a:1;}a{opacity:--b}`, `a{opacity:1;}`);
6
8
  test(`@a(@p,@b){@p{opacity:@b}}@a(a,1);`, `a{opacity:1;}`);
@@ -12,4 +14,14 @@ test(`a{ &b{a:1}}`,`ab{a:1;}`);
12
14
  test(`a{ &.b{a:1}}`,`a.b{a:1;}`);
13
15
  test(`a{ &[b]{a:1}}`,`a[b]{a:1;}`);
14
16
  test(`a{ &[b]:nth-child(1){a:1}}`,`a[b]:nth-child(1){a:1;}`);
15
- test(`a,b{c{a:1}}`,`a c,b c{a:1;}`);
17
+ test(`a,b{c{a:1}}`,`a c,b c{a:1;}`);
18
+ test(`@media(){div{a:1}}`,`@media(){div{a:1;}}`);
19
+ test(`@keyframes a{%1{a:1}}`,`@keyframes a{%1{a:1;}}`);
20
+ test(`@media screen and (max-width:200px){@keyframes a{%1{a:1}}}`,`@media screen and (max-width:200px){@keyframes a{%1{a:1;}}}`);
21
+ test(`@a:1`, ``);
22
+ test(`@a:1;a{a:@a}`, `a{a:1;}`);
23
+ test(`@a:1;a{@{a}:@a}`, `a{1:1;}`);
24
+ test(`@a:1;a{@a:2;@{a}:@a}`, `a{2:2;}`);
25
+ test(`@a:1;@a{@a:2;@{a}:@a}`, `1{2:2;}`);
26
+ test(`@b(@a:1){@a{a:b}}@b(2)`, `2{a:b;}`);
27
+ test(`@a:1; a{a:@a/2}`, `a{a:0.5;}`);
@@ -121,6 +121,10 @@ function testQuote() {
121
121
  var m = scanner(`(sizeof(("table")) / sizeof(("table")[0]))`);
122
122
  console.log(m.toString());
123
123
  }
124
+ function testMinus() {
125
+ var m = scanner(`a- - -!!!b`);
126
+ console.log(m.toString());
127
+ }
124
128
  Program.debug = true;
125
129
  // testSpeed();
126
130
  // testVariables();
@@ -136,6 +140,7 @@ Program.debug = true;
136
140
  // testArrow();
137
141
  // testUnicode();
138
142
  // testComment();
139
- testQuote();
143
+ // testQuote();
144
+ testMinus();
140
145
  // var typescript = require("../typescript/index");
141
146
  // typescript.transpile(data.toString(), { noEmitHelpers: true });
@@ -148,7 +148,7 @@
148
148
  o.text = keys.map(k => /^\</.test(k) || !k ? k : `<express>${k}</express>`).join(".");
149
149
  break;
150
150
  case STRAP:
151
- if (/^(if|else|switch|case|do|while|for|break|continue|default|import|from|as|export|try|catch|finally|await|yield|return)$/.test(text))
151
+ if (/^(if|else|switch|case|do|while|for|break|continue|default|import|from|as|export|try|catch|finally|throw|await|yield|return)$/.test(text))
152
152
  o.text = `<flow>${o.text}</flow>`;
153
153
  else o.text = `<strap>${o.text}</strap>`;
154
154
  break;
@@ -20,24 +20,28 @@ var h = function (text) {
20
20
  var p = function (text) {
21
21
  if (text.length) return new Element("p", text);
22
22
  };
23
+ var p2 = function (text) {
24
+ if (text.length) return new Element('div', text);
25
+ }
23
26
  var li = function (c) {
24
27
  var li = new Element(li, c.replace(/^\*\s+|^[\d]+\.\s+/, ''));
25
28
  return li;
26
29
  }
27
30
  var list_elem = null, list_tag;
28
- var list = function (tag, text, li = 'li') {
31
+ var list = function (tag, text, indent, li = 'li') {
29
32
  if (!list_elem || list_tag !== tag || list_elem !== content[content.length - 1]) {
30
33
  list_elem = new Element(tag);
34
+ list_elem.indent = indent;
31
35
  list_tag = tag;
32
36
  content.push(list_elem);
33
37
  }
34
38
  list_elem.appendChild(new Element(li, text.replace(/^\*\s+|^\d+\.\s+/, '')));
35
39
  };
36
- var ul = function (content) {
37
- return list('ul', content);
40
+ var ul = function (content, indent) {
41
+ return list('ul', content, indent);
38
42
  };
39
- var ol = function (content) {
40
- return list('ol', content);
43
+ var ol = function (content, indent) {
44
+ return list('ol', content, indent);
41
45
  };
42
46
  var tr = function (line) {
43
47
  if (/^[\|\-\s]+$/.test(line)) {
@@ -64,22 +68,31 @@ var tr = function (line) {
64
68
  return;
65
69
  }
66
70
  line = line.replace(/^\||\|$/g, '').split("|").map(t => `<td>${t}</td>`).join('');
67
- return list('table', line, 'tr');
71
+ return list('table', line, NaN, 'tr');
68
72
  }
69
73
  function richtext(line) {
70
- line = line.trim();
74
+ var tagIndent = /^\s+/.exec(line);
75
+ if (!tagIndent) tagIndent = 0;
76
+ else tagIndent = tagIndent[0].length;
77
+ line = line.slice(tagIndent);
71
78
  line = line.replace(/\[([\s\S]*?)\](?:\(([\s\S]*?)\))?|<(\w+)>[\s\S]*?<\/\3>/g, function (_, content, href) {
72
79
  if (/^\</.test(_)) return _;
73
80
  if (href) var href1 = ` href=${strings.recode(href)}`;
74
81
  return `<a${href1}>${content || href}</a>`;
75
82
  });
76
83
  var a;
77
- if (/^#/.test(line)) a = h(line);
78
- else if (/^\*\s+/.test(line)) ul(line);
79
- else if (/^\d+\.\s+/.test(line)) ol(line);
84
+ if (/^#/.test(line)) content.push(h(line));
85
+ else if (/^\*\s+/.test(line)) ul(line, tagIndent);
86
+ else if (/^\d+\.\s+/.test(line)) ol(line, tagIndent);
80
87
  else if (/^\|/.test(line)) tr(line);
81
- else a = p(line);
82
- if (a) content.push(a);
88
+ else {
89
+ if (list_elem && list_elem === content[content.length - 1] && list_elem.indent <= tagIndent) {
90
+ list_elem.appendChild(p(line));
91
+ }
92
+ else {
93
+ content.push(p2(line));
94
+ }
95
+ }
83
96
  }
84
97
  /**
85
98
  * @type {Element}
@@ -87,7 +100,7 @@ function richtext(line) {
87
100
  var content;
88
101
  function markdown(text) {
89
102
  var c = content = [];
90
- text.replace(/ *(`+|\*+)(\S[\s\S]*?)\1 */g, function (_, q, c, i) {
103
+ text.replace(/([ \t\v]*)(`+|\*+)(\S[\s\S]*?)\2([ \t\v]*)/g, function (_, s1, q, c, s2, i) {
91
104
  if (/^\*/.test(q)) {
92
105
  var m = q.length;
93
106
  if (m & 1) c = `<i>${c}</i>`;
@@ -96,11 +109,11 @@ function markdown(text) {
96
109
  }
97
110
  _ = codetext.encode(_.trim()).slice(1, -1);
98
111
  if (/[\*#\.]\s/.test(text.slice(i - 1, i + 1))) _ = " " + _;
99
- if (q.length === 1) return `<m>${_}</m>`;
112
+ if (q.length === 1) return `${s1}<m>${_}</m>${s2}`;
100
113
  var t = /^\S+/.exec(c);
101
114
  if (t) t = t[0]; c = c.slice(t.length).replace(/^(\r\n|\r|\n)|\s+$/g, '');
102
115
  try {
103
- return codetext(t, c);
116
+ return s1 + codetext(t, c) + s2;
104
117
  } catch (e) {
105
118
  console.error(e);
106
119
  return c;
@@ -1,6 +1,10 @@
1
1
  & {
2
2
  white-space: nowrap;
3
3
  overflow: auto;
4
+ background: #421;
5
+ border-top: 10px solid #000;
6
+ padding: 20px 40px 60px 40px;
7
+ // perspective: 3000px; 多嵌套一层,不起作用
4
8
  }
5
9
 
6
10
  &>div {
@@ -11,7 +15,11 @@
11
15
  z-index: 2;
12
16
  width: 60px;
13
17
  text-align: center;
14
- color: green;
18
+ text-transform: uppercase;
19
+ font-family: 'Times New Roman', Times, serif;
20
+ font-style: italic;
21
+ font-weight: 900;
22
+ color: #999;
15
23
 
16
24
  &:before {
17
25
  content: "c";
@@ -26,6 +34,32 @@
26
34
 
27
35
  button {
28
36
  pointer-events: all;
37
+ transform-style: preserve-3d;
38
+
39
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
40
+ position: relative;
41
+
42
+ &.hover {
43
+ >.track {
44
+ box-shadow: none;
45
+ background: #fff1;
46
+ }
47
+
48
+ box-shadow: 0 0 12px -4px #0003;
49
+ }
50
+
51
+ &.active {
52
+ z-index: 0;
53
+
54
+ >.track {
55
+ background: #0003;
56
+ background: linear-gradient(0deg, #0003, #0000);
57
+ }
58
+
59
+ transform-origin: 30px -270px -10px;
60
+ transform:rotateX(-7deg);
61
+ }
62
+
29
63
  }
30
64
 
31
65
  &.odd {
@@ -34,10 +68,9 @@
34
68
  margin: 0 2px;
35
69
  width: 56px;
36
70
  background: #fff;
37
- color: #333;
71
+ color: #aaa;
38
72
  height: 280px;
39
73
  padding: 80px 0 0 0;
40
-
41
74
  box-shadow: 0 0 20px -6px rgba(0, 0, 0, .3);
42
75
 
43
76
  span {
@@ -52,7 +85,7 @@
52
85
 
53
86
  button {
54
87
  width: 40px;
55
- margin: 0 10px;
88
+ margin: 10px 10px;
56
89
  box-shadow: 0 0 20px -6px rgba(0, 0, 0, .3);
57
90
 
58
91
  &:nth-child(1) {
@@ -68,7 +101,7 @@
68
101
  color: #fff;
69
102
  height: 120px;
70
103
 
71
- &:nth-child(7n+2) {
104
+ &:nth-child(2) {
72
105
  margin-right: 70px;
73
106
  }
74
107
  }