@htmlplus/element 0.4.8 → 0.4.9
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/compiler/utils/tags.js +21 -32
- package/package.json +1 -1
package/compiler/utils/tags.js
CHANGED
|
@@ -2,39 +2,28 @@ export const getTag = (node, key) => {
|
|
|
2
2
|
return getTags(node, key).pop();
|
|
3
3
|
};
|
|
4
4
|
export const getTags = (node, filter) => {
|
|
5
|
-
var _a;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
else
|
|
24
|
-
lines[lines.length - 1] += line;
|
|
5
|
+
var _a, _b, _c, _d;
|
|
6
|
+
const tags = [];
|
|
7
|
+
const lines = (_d = (_c = (_b = (_a = node.leadingComments) === null || _a === void 0 ? void 0 : _a.map((comment) => {
|
|
8
|
+
const { type, value } = comment;
|
|
9
|
+
if (type == 'CommentLine')
|
|
10
|
+
return value;
|
|
11
|
+
return value.replace(/\r\n/g, '\n').split('\n');
|
|
12
|
+
})) === null || _b === void 0 ? void 0 : _b.flat()) === null || _c === void 0 ? void 0 : _c.filter((line) => line.trim().replace(/\*/g, ''))) === null || _d === void 0 ? void 0 : _d.map((line) => line.replace(/^( +)?(\*+)?( +)?/, ''));
|
|
13
|
+
for (const line of lines || []) {
|
|
14
|
+
const has = !!tags.length;
|
|
15
|
+
const isTag = line.startsWith('@');
|
|
16
|
+
if (isTag) {
|
|
17
|
+
const [key, ...values] = line.split(' ');
|
|
18
|
+
tags.push({
|
|
19
|
+
key: key.slice(1).trim(),
|
|
20
|
+
value: values.join(' ').trimStart()
|
|
21
|
+
});
|
|
22
|
+
continue;
|
|
25
23
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
tags.push({ value });
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
const sections = value.split(' ');
|
|
33
|
-
const key = sections[0].slice(1);
|
|
34
|
-
value = sections.slice(1).join(' ').trim();
|
|
35
|
-
tags.push({ key, value });
|
|
36
|
-
}
|
|
37
|
-
node['tags'] = tags;
|
|
24
|
+
if (!has)
|
|
25
|
+
tags.push({ key: '', value: '' });
|
|
26
|
+
tags[tags.length - 1].value += line;
|
|
38
27
|
}
|
|
39
28
|
return tags.filter((tag) => !filter || filter === tag.key);
|
|
40
29
|
};
|