@kobalab/liulian 1.1.3 → 1.1.5
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/ChangeLog.md +9 -0
- package/lib/module/core.js +6 -2
- package/lib/text/liulian.js +26 -10
- package/package.json +1 -1
package/ChangeLog.md
CHANGED
package/lib/module/core.js
CHANGED
|
@@ -30,7 +30,7 @@ module.exports = class Core {
|
|
|
30
30
|
this._req = parser._r._req;
|
|
31
31
|
this._inline = ['img','color','size','br','clear','class','lang'];
|
|
32
32
|
this._block = ['title','contents','nav','footnote','include','img',
|
|
33
|
-
'clear','class','style','icon','lang','redirect',
|
|
33
|
+
'size','clear','class','style','icon','lang','redirect',
|
|
34
34
|
'script'];
|
|
35
35
|
this._np = ['style','script'];
|
|
36
36
|
}
|
|
@@ -189,7 +189,11 @@ module.exports = class Core {
|
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
size(type, param, value) {
|
|
192
|
-
|
|
192
|
+
if (type == '#')
|
|
193
|
+
return `<div style="font-size:${cdata(param)}">\n`
|
|
194
|
+
+ `${value}</div>\n\n`;
|
|
195
|
+
else
|
|
196
|
+
return `<span style="font-size:${cdata(param)}">${value}</span>`;
|
|
193
197
|
}
|
|
194
198
|
|
|
195
199
|
br(type, param) {
|
package/lib/text/liulian.js
CHANGED
|
@@ -28,10 +28,7 @@ class LiuLian {
|
|
|
28
28
|
insertText(text, head) {
|
|
29
29
|
let lines = [];
|
|
30
30
|
for (let line of text.replace(/\r?\n$/,'').split(/\r?\n/)) {
|
|
31
|
-
|
|
32
|
-
lines[lines.length - 1]
|
|
33
|
-
= lines[lines.length - 1].replace(/\\$/,'') + line;
|
|
34
|
-
else lines.push(line);
|
|
31
|
+
lines.push(line);
|
|
35
32
|
}
|
|
36
33
|
if (head) this._lines = lines.concat(this._lines);
|
|
37
34
|
else this._lines = this._lines.concat(lines);
|
|
@@ -50,8 +47,27 @@ class LiuLian {
|
|
|
50
47
|
}
|
|
51
48
|
}
|
|
52
49
|
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
nextline(npb) {
|
|
51
|
+
if (this.eod) return;
|
|
52
|
+
if (npb) return this._lines[0];
|
|
53
|
+
let line = '';
|
|
54
|
+
for (let l of this._lines) {
|
|
55
|
+
line += l;
|
|
56
|
+
if (line.substr(-1) != '\\') break;
|
|
57
|
+
line = line.replace(/\\$/,'');
|
|
58
|
+
}
|
|
59
|
+
return line;
|
|
60
|
+
}
|
|
61
|
+
readline(npb) {
|
|
62
|
+
if (this.eod) return;
|
|
63
|
+
if (npb) return this._lines.shift();
|
|
64
|
+
let line = this._lines.shift();
|
|
65
|
+
while (line.substr(-1) == '\\') {
|
|
66
|
+
line = line.replace(/\\$/,'');
|
|
67
|
+
line += this._lines.shift();
|
|
68
|
+
}
|
|
69
|
+
return line;
|
|
70
|
+
}
|
|
55
71
|
|
|
56
72
|
get(key) { return this._[key] }
|
|
57
73
|
noteref(note) {
|
|
@@ -73,7 +89,7 @@ class LiuLian {
|
|
|
73
89
|
this.eod = eod;
|
|
74
90
|
let text = '';
|
|
75
91
|
while (! this.eod) {
|
|
76
|
-
let line = this.readline();
|
|
92
|
+
let line = this.readline(1);
|
|
77
93
|
text += line + '\n';
|
|
78
94
|
}
|
|
79
95
|
this.reset(eod);
|
|
@@ -292,9 +308,9 @@ class LiuLian {
|
|
|
292
308
|
pre() {
|
|
293
309
|
let html = '<pre>';
|
|
294
310
|
for (;;) {
|
|
295
|
-
html += cdata(this.readline().replace(/^\ /,'')) + '\n';
|
|
311
|
+
html += cdata(this.readline(1).replace(/^\ /,'')) + '\n';
|
|
296
312
|
|
|
297
|
-
let line = this.nextline();
|
|
313
|
+
let line = this.nextline(1);
|
|
298
314
|
if (! line || ! line.match(/^\s/)) break;
|
|
299
315
|
}
|
|
300
316
|
return html.replace(/\n$/,'') + '</pre>\n\n';
|
|
@@ -328,7 +344,7 @@ class LiuLian {
|
|
|
328
344
|
this.readline();
|
|
329
345
|
let html = '<pre>';
|
|
330
346
|
while (! this.eod) {
|
|
331
|
-
let line = this.readline();
|
|
347
|
+
let line = this.readline(1);
|
|
332
348
|
if (line == '||<') break;
|
|
333
349
|
html += this.inline(line) + '\n';
|
|
334
350
|
}
|