@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.
@@ -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
- let tags = (_a = node['tags']) !== null && _a !== void 0 ? _a : [];
7
- if (!node['tags']) {
8
- const lines = [];
9
- const comments = (node.leadingComments || [])
10
- .slice(-1)
11
- .map((comment) => comment.value)
12
- .join('\r\n')
13
- .split('\r\n');
14
- for (const comment of comments) {
15
- let line = comment.trimStart();
16
- if (line.startsWith('*'))
17
- line = line.slice(1);
18
- if (!line)
19
- continue;
20
- const isTag = line.trim().startsWith('@');
21
- if (isTag || !lines.length)
22
- lines.push(line);
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
- for (const line of lines) {
27
- let value = line.trim();
28
- if (!value.startsWith('@')) {
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@htmlplus/element",
3
- "version": "0.4.8",
3
+ "version": "0.4.9",
4
4
  "license": "MIT",
5
5
  "author": "Masood Abdolian <m.abdolian@gmail.com>",
6
6
  "description": "Compiler of HTMLPlus",