reslop 0.1.4 → 0.1.6
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 +19 -1
- package/README.md +19 -20
- package/lib/cli.js +20 -16
- package/lib/detect.js +2 -40
- package/lib/diff.js +71 -2
- package/lib/files.js +5 -1
- package/lib/git.js +322 -12
- package/lib/highlight/bash.js +228 -0
- package/lib/highlight/core.js +194 -0
- package/lib/highlight/css.js +76 -0
- package/lib/highlight/csv.js +66 -0
- package/lib/highlight/dart.js +261 -0
- package/lib/highlight/dot.js +54 -0
- package/lib/highlight/html.js +90 -0
- package/lib/highlight/js.js +571 -0
- package/lib/highlight/json.js +54 -0
- package/lib/highlight/log.js +60 -0
- package/lib/highlight/txt.js +41 -0
- package/lib/highlight.js +32 -1299
- package/lib/keys.js +98 -26
- package/lib/render.js +574 -84
- package/lib/review.js +145 -3
- package/lib/select.js +7 -12
- package/lib/session.js +759 -50
- package/lib/sys.js +4 -0
- package/lib/update.js +302 -0
- package/package.json +1 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { emit } = require('./core.js');
|
|
4
|
+
|
|
5
|
+
const langs = ['log'];
|
|
6
|
+
|
|
7
|
+
const LOG_DATETIME_RE = new RegExp(
|
|
8
|
+
'^(\\d{4}-\\d{2}-\\d{2}[T ]\\d{2}:\\d{2}:\\d{2}' +
|
|
9
|
+
'(?:\\.\\d+)?(?:Z|[+-]\\d{2}:?\\d{2})?)',
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
const LOG_TAG_STYLE = {
|
|
13
|
+
error: 'logError',
|
|
14
|
+
err: 'logError',
|
|
15
|
+
warn: 'logWarn',
|
|
16
|
+
warning: 'logWarn',
|
|
17
|
+
info: 'logInfo',
|
|
18
|
+
debug: 'logDebug',
|
|
19
|
+
log: 'plain',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const highlightLogLine = (line) => {
|
|
23
|
+
if (!line) return [];
|
|
24
|
+
const out = [];
|
|
25
|
+
let rest = line;
|
|
26
|
+
const dm = rest.match(LOG_DATETIME_RE);
|
|
27
|
+
if (dm) {
|
|
28
|
+
emit(out, 'logDate', dm[1]);
|
|
29
|
+
rest = rest.slice(dm[1].length);
|
|
30
|
+
}
|
|
31
|
+
const tag = rest.match(/^(\s*)(\[[^\]]+\])/);
|
|
32
|
+
if (tag) {
|
|
33
|
+
emit(out, 'plain', tag[1]);
|
|
34
|
+
const name = tag[2].replace(/^\[|\]$/g, '').toLowerCase();
|
|
35
|
+
emit(out, LOG_TAG_STYLE[name] || 'plain', tag[2]);
|
|
36
|
+
rest = rest.slice(tag[0].length);
|
|
37
|
+
}
|
|
38
|
+
if (rest.includes('\t')) {
|
|
39
|
+
const parts = rest.split('\t');
|
|
40
|
+
for (let i = 0; i < parts.length; i += 1) {
|
|
41
|
+
if (i) emit(out, 'plain', '\t');
|
|
42
|
+
emit(out, `logCol${i}`, parts[i]);
|
|
43
|
+
}
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
46
|
+
if (rest) emit(out, 'logCol0', rest);
|
|
47
|
+
return out;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const highlight = (source) => {
|
|
51
|
+
const lines = source.split('\n');
|
|
52
|
+
const out = [];
|
|
53
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
54
|
+
if (i) emit(out, 'plain', '\n');
|
|
55
|
+
for (const t of highlightLogLine(lines[i])) out.push(t);
|
|
56
|
+
}
|
|
57
|
+
return out;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
module.exports = { langs, highlight };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { emit } = require('./core.js');
|
|
4
|
+
|
|
5
|
+
const langs = ['txt', 'py', 'md'];
|
|
6
|
+
|
|
7
|
+
const aliases = {
|
|
8
|
+
text: 'txt',
|
|
9
|
+
plain: 'txt',
|
|
10
|
+
markdown: 'md',
|
|
11
|
+
python: 'py',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const highlightTxtLine = (line) => {
|
|
15
|
+
if (!line) return [];
|
|
16
|
+
const out = [];
|
|
17
|
+
const re = /(https?:\/\/[^\s<>"']+|www\.[^\s<>"']+)/g;
|
|
18
|
+
let last = 0;
|
|
19
|
+
let m = re.exec(line);
|
|
20
|
+
while (m !== null) {
|
|
21
|
+
if (m.index > last) emit(out, 'plain', line.slice(last, m.index));
|
|
22
|
+
emit(out, 'string', m[0]);
|
|
23
|
+
last = m.index + m[0].length;
|
|
24
|
+
m = re.exec(line);
|
|
25
|
+
}
|
|
26
|
+
if (last < line.length) emit(out, 'plain', line.slice(last));
|
|
27
|
+
if (!out.length) emit(out, 'plain', line);
|
|
28
|
+
return out;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const highlight = (source) => {
|
|
32
|
+
const lines = source.split('\n');
|
|
33
|
+
const out = [];
|
|
34
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
35
|
+
if (i) emit(out, 'plain', '\n');
|
|
36
|
+
for (const t of highlightTxtLine(lines[i])) out.push(t);
|
|
37
|
+
}
|
|
38
|
+
return out;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
module.exports = { langs, aliases, highlight };
|